Post Reply 
Lagrangian Interpolation
12-18-2013, 06:04 AM (This post was last modified: 01-17-2014 05:18 AM by Namir.)
Post: #1
Lagrangian Interpolation
Langrangian Interpolation of 3 points

Usage

A program prompts you to enter 3 points and the
interpolated x

Enter y1 and the x1 at first prompt
Enter y2 and the x2 at second prompt
Enter y3 and the x3 at third prompt
Enter xint at fourth prompt
Note calculator displays 1, 2, 3 at the first, second,
and thir dprompt



B program prompts you to enter the interpolated x

Program calculates and display the value of the interpolated Y.

Algorithm

Code:
INPUT N, array X(1..N), Y(1..N), and Xint
Yint = 0
FOR I = 1 TO N
  Product = Y(I)
  FOR J = 1 to N
    IF I <> J THEN
      Product = Product * (Xint - X(J)) / (X(I) - X(J))
    ENDIF
  NEXT J
  Yint = Yint + Product
NEXT I

Show Yint

Memory Map

R00 = x1
R01 = x2
R02 = X3
R03 = y1
R04 = y2
R05 = y3
R06 = x
R07 = y
R08 = Product
R09 = used
A = I for X(I)
B = J for X(J)
C = I for Y(I)


Source Code

Code:

1 LBL A
2 1
3 R/S        # enter Y1 and X1
4 STO 0
5 x<>y
6 STO 3
7 2
8 R/S        # enter Y2 and X2
9 STO 1
10 x<>y
11 STO 4
12 3
13 R/S        # enter Y2 and X3
14 STO 2
15 x<>y
16 STO 5
17 R/S        # enter Xint
18 LBL B
19 STO 6
20 2
21 STO B        # set J for X(J)
22 5
23 STO C        # set I for Y(I)
24 0
25 STO 7        # y = 0
26 LBL 0        # outer loop starts
27 RCL C
28 GSB 9
29 STO 8
30 2
31 STO A        # set I fo X(I)
32 LBL 1        # inner loop starts
33 RCL A
34 RCL B
35 x=y?        if I = J the skip iteration
36 GTO 2
37 RCL 6
38 RCL A
39 GSB 9
40 STO 9
41 -
42 RCL B 
43 GSB 9
44 RCL 9
45 -
46 /
47 STO* 8        # update product
48 LBL 2
49 RCL A
50 1
51 -
52 STO A
53 x>0?
54 GTO 1        # inner loop ends
55 x=0?
56 GTO 1
57 RCL 8
58 STO+ 7
59 RCL B
60 1
61 -
62 STO B
63 RCL C
64 1
65 -
66 STO C
67 RCL B
68 x>0?
69 GTO 0        # outer loop ends
70 x=0?
71 GTO 0
72 RCL 7
73 R/S
74 GTO B
75 LBL 9        # INDIRECT ADDRESS
76 STO I
77 RDN
78 RCL (I)
79 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 - 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)