DM41 and HP 41C: Lagrangian Interpolation
Introduction
The program LARG estimates a point (x, y) using the Lagrangian interpolating polynomial below:
y =
y0 * (x - x1) * (x - x2) ÷ ((x0 - x1) * (x0 - x2))
+ y1 * (x - x0) * (x - x2) ÷ ((x1 - x0) * (x1 - x2))
+ y2 * (x - x0) * (x - x1) ÷ ((x2 - x0) * (x2 - x1))
The polynomial has three set points that defined points (x0, y0), (x1, y1), and (x2, y2).
This program is based off the Interpolations program for the HP 67 and HP 97 calculators. (see source below)
Swiss Micros DM41/HP41C Program LARG
01 LBL ᵀ LARG
02 SF 27
03 CF 00
04 STOP
05 LBL A
06 STO 01
07 x<>y
08 STO 04
09 RTN
10 LBL B
11 STO 02
12 x<>y
13 STO 05
14 RTN
15 LBL C
16 STO 03
17 x<>y
18 STO 06
19 CF 00
20 RTN
21 LBL D
22 STO 00
23 FS? 00
24 GTO 15
25 RCL 04
26 RCL 05
27 -
28 RCL 04
29 RCL 06
30 -
31 *
32 ST/ 01
33 RCL 05
34 RCL 04
35 -
36 RCL 05
37 RCL 06
38 -
39 *
40 ST/ 02
41 RCL 06
42 RCL 04
43 -
44 RCL 06
45 RCL 05
46 -
47 *
48 ST/ 03
49 SF 00
50 LBL 15
51 RCL 00
52 RCL 05
53 -
54 STO 07
55 RCL 00
56 RCL 06
57 -
58 STO 08
59 *
60 RCL 01
61 *
62 RCL 00
63 RCL 04
64 -
65 STO 09
66 RCL 08
67 *
68 RCL 02
69 *
70 +
71 RCL 09
72 RCL 07
73 *
74 RCL 03
75 *
76 +
77 STOP
78 LBL E
79 CF 27
80 CF 00
81 END
Memory Registers Used:
R01 = y0
R02 = y1
R03 = y2
R04 = x0
R05 = x1
R06 = x2
R07, R08, R09
Flag 0 is used to allow for multiple calculations.
Flag 27 is the User keyboard flag.
Label 15 is a local label. Any labels 15-99 are local labels that can be placed anywhere in the program.
ST/ is STO÷.
STOP is the R/S key.
Instructions
The program LARG is set up to use the USER keyboard as follows:
Key A ([Σ+]): Enter the point (x0, y0). Type x0, press [ENTER], type y0, press [Σ+].
Key B ([1/x]): Enter the point (x1, y1). Type x1, press [ENTER], type y1, press [1/x].
Key C ([√]): Enter the point (x2, y2). Type x2, press [ENTER], type y2, press [√].
Key D ([LOG]): Calculate y.
Key E ([LN]): Exits the program and turns off the user keyboard.
Example
An estimated polynomial runs through the points (1, 7), (3, 9), and (5, 4). Estimate the point at x = 2 and x = 6.
XEQ LARG
1 ENTER 7 [Σ+] (A)
3 ENTER 9 [1/x] (B)
5 ENTER 4 [√] (C)
2 [LOG] (D) returns about 8.8750
6 [LOG] (D) returns about -1.1250
When done, press [LN] (E) to exit or turn off the user keyboard.
Source
HP 67/97 Math Pac I. Hewlett Packard. Corvallis, OR. 1976
Eddie
All original content copyright, © 2011-2023. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.