HP Prime: Hermite
Interpolation – 2 Points Known
Hermite Interpolation: Many calculations of divided differences |
The program HERMITE2 interpolates two data points to determine
the value of an unknown function at a third point. What is unique about Hermite Interpolation is
that that not only the two data points are known, but the slopes (first derivatives)
are also given. Hermite Interpolation will require a lot of
calculations, especially when more than two points are 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.
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)
The arguments of HERMITE2 are as follows: x0, y0, y’0 (labeled dx0), x1, y1, y’1
(labeled dx1), x.
HP Prime: Program
HERMITE2
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
Until next time everyone, happy computing! Eddie
This blog is property of Edward Shore. 2016