HP Forums
Polynomial Interpolation for HP-67 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Polynomial Interpolation for HP-67 (/thread-18349.html)



Polynomial Interpolation for HP-67 - Matt Agajanian - 05-11-2022 01:04 AM

Hi all.

In the Math/Utilities module for the TI-58/59, there’s an interpolation program that fits an n-th degree polynomial to n+1 data pairs. It then allows for the calculation when an x value is entered. I would have liked to have a version of that program which would also reveal the polynomial coefficients.

I no longer have my TI-58C nor the module. So, I can’t download and print the program so I could write an HP-67 version.

Does anyone have an HP-67 or even a 29C polynomial fitting/interpolation program so I could add that to my program library?

Thanks


RE: Polynomial Interpolation for HP-67 - Thomas Klemm - 05-11-2022 05:31 AM

(05-11-2022 01:04 AM)Matt Agajanian Wrote:  Does anyone have an HP-67 or even a 29C polynomial fitting/interpolation program so I could add that to my program library?

In Lagrangian Interpolation you can find some programs for the HP-67, HP-25 and HP-15C.
However these are limited to 3 points.

In the program of (42S) Newton Polynomial Interpolation the number of points is only limited by memory.
Furthermore points can be added if the interpolation is not considered sufficient.
It should be possible to rewrite these programs for the HP-67 even though some of the commands that access the stack registers are missing.

(05-11-2022 01:04 AM)Matt Agajanian Wrote:  I would have liked to have a version of that program which would also reveal the polynomial coefficients.

It may not be exactly what you want, but you get the coefficients of the Newton polynomial:
(03-09-2019 04:49 PM)Thomas Klemm Wrote:  Example:

Find a quadratic polynomial given these 3 points: \(P_0(-5, 12)\), \(P_1(1, 13)\) and \(P_2(2, 11)\)

0 STO 00

-5 ENTER 12
XEQ "P+"

1 ENTER 13
XEQ "P+"

2 ENTER 11
XEQ "P+"


These are the coefficients of the Newton polynomial:

R03: 12.000000
R05:  0.166667
R07: -0.309524

This leads to the formula:

\(f(x) = 12 + (x+5)(\frac{1}{6} - (x-1)\frac{13}{42})\)

But you can expand it to get:

\(
-\frac{13 x^2}{42} - \frac{15 x}{14} + \frac{302}{21}
\)


RE: Polynomial Interpolation for HP-67 - KeithB - 05-11-2022 12:16 PM

I have 3 or 4 routines written in C-Adjacent languages that you might be able to adapt. They use the Least Squares method (so you can put more than N data points) from Advanced Engineering Mathematics.

I keep re-inventing the wheel. 8^)


RE: Polynomial Interpolation for HP-67 - Albert Chan - 05-11-2022 12:27 PM

(05-11-2022 05:31 AM)Thomas Klemm Wrote:  \(f(x) = 12 + (x+5)(\frac{1}{6} - (x-1)\frac{13}{42})\)

But you can expand it to get:

\(
-\frac{13 x^2}{42} - \frac{15 x}{14} + \frac{302}{21}
\)

We can do synthetic multiplication, to transform "offset" polynomial to "normal" polynomial.
We do it inside out, first (x-1), then (x+5)

Code:
    -13/42      1/6       12
-1            13/42
----------------------------
    -13/42    10/21       12  
+5           -65/42    50/21
----------------------------
    -13/42   -15/14   302/21

Or, we can convert 1 set of polynomial offsets, to another, in 1 shot.
see Funny Factorials and Slick Sums

We don't see much benefits here, because "normal" polynomial have zero offsets.

a(n) x^n + a(n-1) x^(n-1) + ... = (x-0) * (a(n) + (x-0) * (a(n-1) + ...

From offsets (-1,5) → (0,0):
Code:
      -13/42       1/6        12      
-1 0> -13/42     10/21    302/21
+5 0> -13/42    -15/14

(-1+0)*(-13/42) + 1/6   =  10/21
(+5+0)*(+10/21) + 12    = 302/21
(+5+0)*(-13/42) + 10/21 = -15/14



RE: Polynomial Interpolation for HP-67 - Thomas Klemm - 05-11-2022 09:37 PM

(05-11-2022 05:31 AM)Thomas Klemm Wrote:  It should be possible to rewrite these programs for the HP-67 even though some of the commands that access the stack registers are missing.

Done.