help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ppval subtracts break from XI - extend documentation?


From: Martin Kunz
Subject: ppval subtracts break from XI - extend documentation?
Date: Fri, 12 Aug 2016 10:22:53 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Hi,

It took me a while to realise why the evaluation of piecewise polynomials constructed with mkpp does not work as I expected. Consider this example (a test case from ppval):

b = 1:3;
c = ones (2);
pp = mkpp (b, c);
ppval (pp, 1.1)

I thought we would calculate 1*xi + 1 at xi=1.1 and expected the answer to be 2.1, but in fact this computation yields 1.1. The reason is that ppval subtracts the left break from xi and calculates 1*0.1 + 1 = 1.1.

I tried this code in MATLAB and got the same result, so the behaviour is consistent and we should not change it. If the piecewise polynomials are created by spline or interp1, all is fine (probably, I did not test), but when they are generated "by hand" with mkpp great confusion can arise. Therefore I suggest to add a note to the help of ppval and/or mkpp:

"Note that ppval evaluates polynomials at XI - BREAKS(i), i.e. subtracts the the lower endpoint of the current interval from XI. This has to be taken into account when creating piecewise polynomial objects with mkpp."

By the way, MATLAB includes a remark on this behaviour in the help on mkpp, but I find it rather cryptic: "Notice that mkpp shifts the polynomial in each interval down by (X-breaks(i))." I would even say it is wrong because mkpp shifts nothing.

Best regards,
Martin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]