patchGNU Octave - Patches: patch #9095, Additional note for ppval and/or...

 
 

patch #9095: Additional note for ppval and/or mkpp documentation

Submitter:  Martin Kunz <mkunz>
Submitted:  Mon 22 Aug 2016 03:16:04 PM UTC
   
 
Category:  Core : other Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 11 Dec 2018 05:43:48 AM UTC, comment #2: 

I added a Programming Note to mkpp to try and make this point clearer.  See https://hg.savannah.gnu.org/hgweb/octave/rev/33e6ab3e1491.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Sat 27 Aug 2016 06:00:15 AM UTC, comment #1: 

New try to post the proposed note completely:


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.



Martin Kunz <mkunz>
Mon 22 Aug 2016 03:16:04 PM UTC, original submission:  

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

Martin Kunz <mkunz>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mkunz (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-11 rik5 StatusNone Done
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code