octave-patch-tracker
[Top][All Lists]
Advanced

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

[Octave-patch-tracker] [patch #9095] Additional note for ppval and/or mk


From: Martin Kunz
Subject: [Octave-patch-tracker] [patch #9095] Additional note for ppval and/or mkpp documentation
Date: Mon, 22 Aug 2016 15:16:07 +0000 (UTC)
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0

URL:
  <http://savannah.gnu.org/patch/?9095>

                 Summary: Additional note for ppval and/or mkpp documentation
                 Project: GNU Octave
            Submitted by: mkunz
            Submitted on: Mon 22 Aug 2016 03:16:04 PM GMT
                Category: Core : other
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

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 to this item at:

  <http://savannah.gnu.org/patch/?9095>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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