Post Reply 
Lagrangian Interpolation
07-09-2024, 12:58 PM
Post: #21
RE: Lagrangian Interpolation
Yes, you are right. It was in March 2019, I had forgotten, Sorry
Find all posts by this user
Quote this message in a reply
07-09-2024, 08:43 PM
Post: #22
RE: Lagrangian Interpolation
(03-14-2019 07:22 PM)PedroLeiva Wrote:  For 2nd order polynomials we can use your program, just loading three points;
so we cannot use it for 3rd. or 4th. order, considering we will need 4 or 5 points. Am I right?

Yes, you can!

It does not matter how many points. Example, for 5 points:
Code:
x1   y1
x2   y2  
x3   y3  y3'
x4   y4  y4'  
x5   y5  y5'  y5''

(x1,y1),(x2,y2),(x3,y3) --> (x3,y3')
(x1,y1),(x2,y2),(x4,y4) --> (x4,y4')
(x1,y1),(x2,y2),(x5,y5) --> (x5,y5')
(x3,y3'),(x4,y4'),(x5,y5') --> (x5,y5'')

This work with simple secant line too.

(03-07-2015 11:49 PM)bshoring Wrote:  A program for the HP-25 gave this example:

X1=-11 Y1=121 X2=3 Y2=9 X3=2 Y3=4
X=2.5 Y=6.25 etc.

Code:
    X   Y       Interpolate @ X=2.5
    2   4   
    3   9        6.5
  -11   121     -0.5    6.25

(2,4), (3,9) --> (2.5, 6.5)
(2,4), (-11,121) --> (2.5, -0.5)
(3,6.5), (-11,-0.5) --> (2.5, 6.25)
Find all posts by this user
Quote this message in a reply
07-10-2024, 05:09 AM
Post: #23
RE: Lagrangian Interpolation
(07-09-2024 08:43 PM)Albert Chan Wrote:  Yes, you can!

That's nice.

But because of the memory limitation of the HP-25 to only 8 registers, the HP memory extension™ must be used. (See picture)
In addition, the method is a bit tedious if the function is to be interpolated at several points.

[Image: attachment.php?aid=13704]


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
07-10-2024, 11:23 AM
Post: #24
RE: Lagrangian Interpolation
(07-10-2024 05:09 AM)Thomas Klemm Wrote:  But because of the memory limitation of the HP-25 to only 8 registers,
the HP memory extension™ must be used. (See picture)

Can scrap paper work too? Big Grin

Quote:In addition, the method is a bit tedious if the function is to be interpolated at several points.

We can use Acton Forman's method for polynomial coefficients too.

Instead of interpolating for a value, do divided difference (i.e. slope)
Code:
    X   Y      D   D^2
    2   4   
    3   9      5
  -11   121   -9   1

f(x) = 4 + (x-2)*(5 + (x-3)*1) = 4 + (x-2)*(x+2) = x^2
Find all posts by this user
Quote this message in a reply
07-10-2024, 11:34 AM
Post: #25
RE: Lagrangian Interpolation
(07-10-2024 11:23 AM)Albert Chan Wrote:  
(07-10-2024 05:09 AM)Thomas Klemm Wrote:  But because of the memory limitation of the HP-25 to only 8 registers,
the HP memory extension™ must be used. (See picture)

Can scrap paper work too? Big Grin

It can. but it's not anywhere near as collectible...

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-11-2024, 04:19 AM
Post: #26
RE: Lagrangian Interpolation
(07-10-2024 11:23 AM)Albert Chan Wrote:  
Code:
    X   Y      D   D^2
    2   4   
    3   9      5
  -11   121   -9   1

I assume that -9 should rather be -8:

\(
\frac{121 - 9}{-11 - 3} = \frac{112}{-14} = -8
\)

And then:

\(
\frac{-8 - 5}{-11 - 2} = \frac{-13}{-13} = 1
\)
Find all posts by this user
Quote this message in a reply
07-11-2024, 10:05 AM
Post: #27
RE: Lagrangian Interpolation
Hi, Thomas Klemm

Your way works too, but I prefer Acton's Forman style.
I like to do row-by-row, and this lined up numbers to use.


Acton Forman style
Code:
        f    D          D^2      D^3
  1     1   
  2     8   7/1=7
  5   125   124/4=31    24/3=8
  7   343   342/6=57    50/5=10  2/2=1


Conventional Divided Difference, we need to trace the diagonal for x's to use.
Code:
        f    D          D^2      D^3
  1     1
            7/1=7
  2     8               32/4=8
            117/3=39             6/6=1
  5   125               70/5=14
            218/2=109
  7   343

Both ways get the same [1,7,8,1] digaonal

f = 1 + (x-1)*(7 + (x-2)*(8 + (x-5)*1)) = x^3
Find all posts by this user
Quote this message in a reply
07-12-2024, 08:28 AM
Post: #28
RE: Lagrangian Interpolation
(03-14-2019 07:58 PM)Thomas Klemm Wrote:  Given the restrictions of the HP-25 I'm afraid we can't go further than 3 points.

(07-09-2024 08:43 PM)Albert Chan Wrote:  Yes, you can!

Here we go:
Code:
01: 24 00    : RCL 0
02: 41       : -
03: 23 06    : STO 6
04: 24 04    : RCL 4
05: 41       : -
06: 24 07    : RCL 7
07: 61       : *
08: 24 05    : RCL 5
09: 51       : +
10: 24 06    : RCL 6
11: 24 02    : RCL 2
12: 41       : -
13: 61       : *
14: 24 03    : RCL 3
15: 51       : +
16: 24 06    : RCL 6
17: 61       : *
18: 24 01    : RCL 1
19: 51       : +
20: 13 00    : GTO 00
21: 24 00    : RCL 0
22: 23 41 02 : STO - 2
23: 23 41 04 : STO - 4
24: 23 41 06 : STO - 6
25: 24 01    : RCL 1
26: 23 41 03 : STO - 3
27: 23 41 05 : STO - 5
28: 23 41 07 : STO - 7
29: 24 04    : RCL 4
30: 23 71 05 : STO / 5
31: 24 06    : RCL 6
32: 23 71 07 : STO / 7
33: 24 02    : RCL 2
34: 23 71 03 : STO / 3
35: 24 03    : RCL 3
36: 23 41 05 : STO - 5
37: 23 41 07 : STO - 7
38: 22       : Rv
39: 41       : -
40: 23 71 07 : STO / 7
41: 21       : x<->y
42: 14 73    : f LASTx
43: 41       : -
44: 23 71 05 : STO / 5
45: 24 05    : RCL 5
46: 23 41 07 : STO - 7
47: 22       : Rv
48: 41       : -
49: 23 71 07 : STO / 7

Example

Interpolation of the \(sin\) function using well known values:

\(
\begin{align}
(30&, 0.5) \\
(45&, \sqrt{0.5}) \\
(60&, \sqrt{0.75}) \\
(90&, 1) \\
\end{align}
\)

Enter the data

30 STO 0
.5 STO 1

45 STO 2
.5 \(\sqrt{x}\) STO 3

60 STO 4
.75 \(\sqrt{x}\) STO 5

90 STO 5
1 STO 6

Calculation of coefficients

GTO 21
R/S

Interpolation of values

37 R/S
0.6020

37 sin
0.6018

49 R/S
0.7546

49 sin
0.7547

73 R/S
0.9572

73 sin
0.9563
Find all posts by this user
Quote this message in a reply
Post Reply 




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