Post Reply 
Lagrangian Interpolation
03-11-2015, 08:04 AM
Post: #11
RE: Lagrangian Interpolation
For the sake of completeness I wrote a program using the Newton Polynomial

\(N(x) = [y_0] + [y_0,y_1](x-x_0) + \cdots + [y_0,\ldots,y_k](x-x_0)(x-x_1)\cdots(x-x_{k-1})\)

where

\([y_0,\ldots,y_j]\)

is the notation for divided differences.

Code:
001  31 25 11  : LBL A
002        01  : 1
003        84  : R/S
004     33 00  : STO 0
005     35 52  : x<>y
006     33 03  : STO 3
007        02  : 2
008        84  : R/S
009     33 01  : STO 1
010     35 52  : x<>y
011     33 04  : STO 4
012        03  : 3
013        84  : R/S
014     33 02  : STO 2
015     35 52  : x<>y
016     34 04  : RCL 4
017        51  : -
018     34 02  : RCL 2
019     34 01  : RCL 1
020        51  : -
021        81  : /
022     34 04  : RCL 4
023     34 03  : RCL 3
024        51  : -
025     34 01  : RCL 1
026     34 00  : RCL 0
027        51  : -
028        81  : /
029     33 04  : STO 4
030        51  : -
031     34 02  : RCL 2
032     34 00  : RCL 0
033        51  : -
034        81  : /
035     34 05  : STO 5
036        84  : R/S
037  31 25 12  : LBL B
038     35 33  : ST I
039     34 01  : RCL 1
040        51  : -
041     34 05  : RCL 5
042        71  : *
043     34 04  : RCL 4
044        61  : +
045     35 34  : RC I
046     34 00  : RCL 0
047        51  : -
048        71  : *
049     34 03  : RCL 3
050        61  : +
051     35 22  : RTN

It is a little shorter and maybe a little faster as well.

Cheers
Thomas


Thanks to its extended register arithmetic the program for the HP-15C is even 10 lines shorter:
Code:
001 - 42,21,11  LBL A       
002 -        1  1           
003 -       31  R/S         
004 -    44  0  STO 0       
005 -       34  x<>y        
006 -    44  3  STO 3       
007 -        2  2           
008 -       31  R/S         
009 -    44  1  STO 1       
010 -       34  x<>y        
011 -    44  4  STO 4       
012 -        3  3           
013 -       31  R/S         
014 -    44  2  STO 2       
015 -       34  x<>y        
016 - 45,30, 4  RCL- 4      
017 -    45  2  RCL 2       
018 - 45,30, 1  RCL- 1      
019 -       10  /           
020 -    45  4  RCL 4       
021 - 45,30, 3  RCL- 3      
022 -    45  1  RCL 1       
023 - 45,30, 0  RCL- 0      
024 -       10  /           
025 -    44  4  STO 4       
026 -       30  -           
027 -    45  2  RCL 2       
028 - 45,30, 0  RCL- 0      
029 -       10  /           
030 -    44  5  STO 5       
031 -       31  R/S         
032 - 42,21,12  LBL B       
033 -    44 25  STO I       
034 - 45,30, 1  RCL- 1      
035 - 45,20, 5  RCLx 5      
036 - 45,40, 4  RCL+ 4      
037 -    45 25  RCL I       
038 - 45,30, 0  RCL- 0      
039 -       20  x           
040 - 45,40, 3  RCL+ 3      
041 -    43 32  RTN
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Lagrangian Interpolation - Namir - 12-18-2013, 06:04 AM
RE: Lagrangian Interpolation - bshoring - 03-05-2015, 05:17 AM
RE: Lagrangian Interpolation - PedroLeiva - 03-05-2015, 09:33 PM
RE: Lagrangian Interpolation - bshoring - 03-07-2015, 11:49 PM
RE: Lagrangian Interpolation - PedroLeiva - 03-09-2015, 03:37 AM
RE: Lagrangian Interpolation - bshoring - 03-09-2015, 03:30 AM
RE: Lagrangian Interpolation - bshoring - 03-09-2015, 09:50 PM
RE: Lagrangian Interpolation - Thomas Klemm - 03-11-2015 08:04 AM
RE: Lagrangian Interpolation - bshoring - 03-13-2015, 05:33 AM
RE: Lagrangian Interpolation - PedroLeiva - 03-14-2019, 03:55 PM
RE: Lagrangian Interpolation - PedroLeiva - 03-14-2019, 07:22 PM
RE: Lagrangian Interpolation - PedroLeiva - 03-14-2019, 08:12 PM



User(s) browsing this thread: 1 Guest(s)