HP Prime: Hermite Interpolation – 2 Points Known
02-17-2016, 01:13 PM
Post: #1 Eddie W. Shore Senior Member Posts: 1,145 Joined: Dec 2013
HP Prime: Hermite Interpolation – 2 Points Known

The 2-Known Points Case

We have points (x0, y0, y’0) and (x1, y1, y’1) and we want to determine y for a given value of x. The approximation of y is determined by divided differences.

Code:
 For two points known:   z0:  x0, y0                 z01 = y’0         z1: x0, y0        z02 = (z12 – z01)/(x1 – x0)         z12 = (y1 – y0)/(x1 – x0)        z13 = (z13 – z02)/(x1 – x0) z2: x1, y1        z13 = (z23 – z12)/(x1 – x0)         z23 = y’1         z3: x1, y1

And y = H3(x) = y0 + y’0 * (x – x0) + z02 * (x – x0)^2 + z13 * (x – x0)^2 * (x – x1)

Program:
Code:
EXPORT HERMITE2(x0,y0,dy0,x1,y1,dy1,x) BEGIN // Hermite Interpolation // 2 points // 2016-02-16 LOCAL z12,dx,z02,z13,z03,y; dx:=x1-x0; z12:=(y1-y0)/dx; z02:=(z12-dy0)/dx; z13:=(dy1-z12)/dx; z03:=(z13-z02)/dx; y:=y0+dy0*(x-x0)+ z02*(x-x0)^2+ z03*(x-x0)^2*(x-x1); RETURN y; END;

Example:

Given: x0 = 0, y0 = 0, y’0 = 1; x1 = 1, y1 = 1, y’1 = 0.78
For x = 0.5, result is y = 0.5275
For x = 0.78, result is y = 0.80944656

Source:

Faires, J. Douglas and Burden, Richard. Numerical Methods – 3rd Edition Thompson Brooks/Cole: Pacific Grove, CA 2003
 « Next Oldest | Next Newest »

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