Saturday, November 30, 2024

TI-30Xa and HP 12C: Linear Interpolation

TI-30Xa and HP 12C: Linear Interpolation



Introduction


Linear interpolation allows us to estimate a point (x,y) given a linear relationship between points (x1,y1) and (x2,y2).


Given two points (x0, y0) and (x1, y1), and a point, x, we can easily estimate the y coordinate:


y = y0 + (x – x0) * (y1 – y0) / (x1 – x0)


Note that the slope of the line is:

m = (y1 – y0) / (x1 – x0)


This works the best when x is relatively real close to x0 and x1.


Fun fact, the y-intercept, where x = 0 can be calculated as:

b = y0 – x0 * m




TI-30Xa Algorithm: Linear Interpolation


This algorithm will require to enter information only once.


Store the following points:

x0 [ STO ] 1

y0 [ STO ] 2


Predict y:

[ ( ] x [ - ] [ RCL ] 1 [ ) ] [ × ] [ ( ] y1 [ - ] [ RCL ] 2 [ ) ] [ ÷ ] [ ( ] x1 [ - ] [ RCL ] 1 [ ) ] [ + ] y0 [ = ]




HP 12C Algorithm: Linear Interpolation


It turns out that we can use the linear regression functions for linear interpolation. Entering two points for linear regression will create a perfect line (with the correlation of 1 or -1). The algorithm presented is for the HP 12C, and a algorithm for other calculators can easily be made.


Keystrokes:


Enter (x0, y0) and (x1, y1):

[ f ] [ Clx ] (CLEAR FIN)

y0 [ ENTER ] x0 [ Σ+ ]

y1 [ ENTER ] x1 [ Σ+ ]


To calculate y:

x [ g ] [ 2 ] (y-hat, r)



Examples


Examples

X0

Y0

X1

Y1

X (Input)

Y (Output)

1

10

4.95

12

5.06

11

5.0050

2

21

48,057

23

52,165

22

50,111

3

1000

97.7

2000

94.2

1500

95.95



Source


“Linear interpolation” Wikipedia. Was Edited August 27, 2024. Retrieved September 4, 2024. https://en.wikipedia.org/wiki/Linear_interpolation


Until next time, as we head into the final month of 2024,



Eddie


All original content copyright, © 2011-2024. 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.