CHAPTER3-Polynomial Inetrpolation
CHAPTER3-Polynomial Inetrpolation
Time t (sec) 0 1 2 3 4
Distance X (m) 0 5 15 0 3
We want to calculate the position of the object at t = 3.25 seconds or the speed of
the object at a given time. To do this, we need an analytical form of X as a function
of t, denoted X(t). This form must at least
R 4 coincide with the points provided in the
dX
table. We can then calculate X(3.25), 0 X(t) dt, or the velocity v(t) = dt (t).
In this chapter, we will consider the approximation of X(t) by a polynomial
form, specifically:
X(t) = a0 + a1 t + a2 t2 + · · · + an tn
where ai (for i = 0, n) are coefficients to be determined. The polynomials we will
study differ only in the method used to determine the coefficients ai (for i = 0, n),
because for a given table of values, the interpolation polynomial is unique.
Interpolating Polynomial
Polynomial Interpolation
Interpolation Points
3
1
f(x)
0
(1, 0) (2, 0)
−1 (−2, 0)
−2
−1 0 1 2 3
x
37
Numerical Analysis
where the abscissas (xi )ni=0 are distinct, i.e., xi 6= xj for all i 6= j. The polynomial
interpolation problem consists of finding a polynomial P ∈ Pn [X] whose graph
passes through these (n + 1) points. In other words, we seek P ∈ Pn [X] such that:
where C0 , C1 , . . . , Cn ∈ R.
Remark
xi x0 ... xn
f (xi ) f (x0 ) . . . f (xn )
38
Numerical Analysis
Let f be a function known at (n + 1) distinct points (xi , f (xi ))ni=0 , where the
(xi )ni=0 are distinct. Then, there exists a unique polynomial Pn ∈ Pn [X] such
that:
Pn (xi ) = f (xi ), for all i = 0, . . . , n.
(Alternatively, Pn (xi ) = yi if the function f is not explicitly known.)
39
Numerical Analysis
Example
Let
f (0.2) = 0.5 (denote this as y0 )
and
f (0.6) = 1.5 (denote this as y1 ).
Our objective is to find the linear interpolation polynomial
P (x) = a0 + a1 x
The Vandermonde matrix for the points x0 = 0.2 and x1 = 0.6 is:
1 x0 1 0.2
=
1 x1 1 0.6
Set Up the System of Equations
We can express the system of equations as:
1 0.2 a0 y 0.5
= 0 =
1 0.6 a1 y1 1.5
Solve the system
To solve the system, we need to find the inverse of the Vandermonde matrix and
multiply it by the vector of outputs.
−1
a0 1 0.2 0.5
=
a1 1 0.6 1.5
−1
1 0.2 1 0.6 −0.2 1 0.6 −0.2 1.5 −0.5
= = =
1 0.6 0.6 − 0.2 −1 1 0.4 −1 1 −2.5 2.5
40
Numerical Analysis
a0 = 0 and a1 = 2.5.
The linear interpolation polynomial is:
P (x) = 2.5x
passes through the points (0.2, 0.5) and (0.6, 1.5). This polynomial can now be used
to estimate the value of the function at any x within the interval [0.2, 0.6].
n
Y x − xj (x − x0 ) (x − xi−1 ) (x − xi+1 ) (x − xn )
`i (x) = = ··· ···
x − xj
j=0 i
(xi − x0 ) (xi − xi−1 ) (xi − xi+1 ) (xi − xn )
j6=i
for i = 0, . . . , n. Note that under the initial assumption that no two xj are
identical, when i 6= j, xi − xj 6= 0, so this expression is always well-defined. For any
j 6= i, `i (x) includes the term (x − xj ) in the numerator, thus the entire product will
be zero at x = xj , meaning:
(
1 if i = j
`i (xj ) = δij =
0 if i 6= j
Consequently, yj `j (xj ) = yj , which shows that at each point xj ,
41
Numerical Analysis
α1 = α2 = . . . = αn = 0.
Since,
n
X
αi `i (xj ) = αj ,
i=0
we conclude that all αj must be zero. Therefore, the set {`0 , . . . , `n } forms a
basis for Pn , the vector space of polynomial functions over R with real coefficients,
of degree less than or equal to n.
From the above, we derive the following theorem.
Theorem
Given n + 1 points (x0 , y0 ), . . . , (xn , yn ). If the xi are distinct, then there
exists a unique polynomial pn of degree at most n such that pn (xi ) = yi for
i = 0, . . . , n, which can be expressed in the Lagrange form as
n
X
pn (x) = yi `i (x) (3.1)
i=0
where
n
Y x − xj
`i (x) = .
j=0
x i − x j
j6=i
Example
We want to find the polynomial p(x) that passes through the points : (1, 2),
(2, 3) and (3, 5).
We have:
x0 = 1, y0 = 2
x1 = 2, y1 = 3
x2 = 3, y2 = 5
42
Numerical Analysis
= x2 − 2x + 2
43
Numerical Analysis
It is clear that the family {Ni }ni=0 forms a basis for the space of polynomials of
degree less than or equal to n, since it is linearly independent.
To show linear independence, consider the equation:
n
X
αi Ni (x) = 0
i=0
αj Nj (xj ) = 0.
Since Nj (xj ) is non-zero, it follows that αj = 0. This reasoning holds for all j,
leading to the conclusion that all coefficients αi must be zero.
The problem of calculating the interpolation polynomial Pn , reduces to deter-
mining the coefficients ai such that:
n
X
Pn = ai Ni (x)
i=0
a0 = f (x0 ).
Next, we need to satisfy the condition Pn (x1 ) = f (x1 ), which can be expressed
as:
a0 + a1 (x1 − x0 ) = f (x1 ).
This allows us to isolate a1 :
f (x1 ) − f (x0 )
a1 = .
x 1 − x0
For the third coefficient a2 , we use:
44
Numerical Analysis
f (x2 ) − a0 − a1 (x2 − x0 )
a2 = .
(x2 − x0 )(x2 − x1 )
This can be simplified to:
1 f (x2 ) − f (x1 ) f (x1 ) − f (x0 ) f (x1 ) − f (x0 ) x2 − x0
a2 = + − · .
x2 − x0 x2 − x1 x2 − x1 x1 − x0 x2 − x1
a0 = f [x0 ];
f (x1 ) − f (x0 )
a1 = = f [x0 , x1 ];
x1 − x0
an = f [x0 , x1 , . . . , xn ]
The interpolation polynomials P1 , P2 in Newton’s form are given by:
45
Numerical Analysis
Lemma
If Pn (x) is a polynomial of degree n, its divided difference of order (n + 1) is
identically zero, that is,
f [x0 , x1 , . . . , xn , x] = 0
for any set of (n + 1) distinct numbers x0 , x1 , . . . , xn .
Proof. Let Pn (x) be a polynomial of degree n. The divided difference is given by:
Pn (x) − Pn (x0 )
f [x0 , x] = ,
x − x0
which results in a polynomial of degree n − 1.
Next, we have:
f [x1 , x] − f [x0 , x1 ]
f [x0 , x1 , x] = ,
x − x0
yielding a polynomial of degree n − 2.
By induction, we can establish that:
f [x0 , x1 , . . . , xn , x] = 0.
Theorem
The interpolation polynomial in Newton’s form passing through the points
(xi , f (xi )) for i = 0, . . . , n can be written as:
Proof. From the divided difference formulas to the polynomial Pn (x), we have:
Pn (x) − Pn (x0 )
f [x, x0 ] = =⇒ Pn (x) = Pn (x0 ) + f [x, x0 ](x − x0 ).
x − x0
Next, for three points, we can express:
46
Numerical Analysis
f [x, x0 ] − f [x0 , x1 ]
f [x, x0 , x1 ] = =⇒ f [x, x0 ] = f [x0 , x1 ] + f [x, x0 , x1 ](x − x1 ).
x − x1
xi f (xi ) f [xi , xi+1 ] f [xi , xi+1 , xi+2 ] f [xi , xi+1 , xi+2 , xi+3 ] ... f [x0 , x1 , . . . , xn ]
x0 f (x0 )
x1 f (x1 ) f [x0 , x1 ]
x2 f (x2 ) f [x1 , x2 ] f [x0 , x1 , x2 ]
x3 f (x3 ) f [x2 , x3 ] f [x1 , x2 , x3 ] f [x0 , x1 , x2 , x3 ]
.. .. .. .. .. .. ..
. . . . . . .
xn f (xn ) f [xn−1 , xn ] f [xn−2 , xn−1 , xn ] f [xn−3 , xn−2 , xn−1 , xn ] ... f [x0 , x1 , . . . , xn ]
Example
Find the Newton polynomial that passes through the following points: (0, 1),
(1, 4), (2, 8) and (3, 14)
To find the Newton polynomial P (x) that passes through the given points, we
will construct the divided difference table using the updated values:
47
Numerical Analysis
x0 = 0, f (x0 ) = 1,
x1 = 1, f (x1 ) = 4,
x2 = 2, f (x2 ) = 8,
x3 = 3, f (x3 ) = 14.
The divided difference table is as follows:
xi f (xi ) f [xi , xi+1 ] f [xi , xi+1 , xi+2 ] f [xi , xi+1 , xi+2 , xi+3 ]
x0 = 0 1
4−1
x1 = 1 4 f [x0 , x1 ] = 1−0
=3
8−4 4−3 1
x2 = 2 8 f [x1 , x2 ] = 2−1
=4 f [x0 , x1 , x2 ] = 2−0
= 2
14−8 6−4 1− 21 1
x3 = 3 14 f [x2 , x3 ] = 3−2
=6 f [x1 , x2 , x3 ] = 3−1
=1 f [x0 , x1 , x2 , x3 ] = 3−0
= 6
P (x) = f (x0 )+f [x0 , x1 ](x−x0 )+f [x0 , x1 , x2 ](x−x0 )(x−x1 )+f [x0 , x1 , x2 , x3 ](x−x0 )(x−x1 )(x−x2 ).
Substituting the computed values from the divided difference table:
1
P (x) = 1 + 3(x − 0) + 4(x − 0)(x − 1) + (x − 0)(x − 1)(x − 2).
6
The Newton polynomial P (x) that passes through the given points is:
1 17
P (x) = x3 + x + 1.
6 6
x0 ∈ R, x1 = x0 + h, x2 = x0 + 2h, . . . , xn = x0 + nh,
b−a
with h = n
> 0 representing the step size. Alternatively, this can be expressed
as:
48
Numerical Analysis
Definition. Let (n+1) equidistant points (xi , yi )ni=0 . The Forward Finite Differences
(F.F.D) of order k (where k = 0, . . . , n) are defined by the following expressions:
- For order 0:
∆0 yi = f (xi ) = yi , i = 0, . . . , n.
- For order 1:
∆1 yi = yi+1 − yi , i = 0, . . . , n − 1.
- For order 2:
∆2 yi = ∆1 yi+1 − ∆1 yi , i = 0, . . . , n − 2.
- For order n:
∆n y0 = ∆n−1 y1 − ∆n−1 y0 (i = 0).
∆k yi
= f [xi , xi+1 , . . . , xi+k ], k = 1, . . . , n; i = 0, . . . , n − k;
k!hk
where yi = f (xi ) for all i ∈ {0, . . . , n}.
0!
f [xi ] = yi = ∆0 yi , ∀i = 0, . . . , n.
h0
49
Numerical Analysis
2. **Inductive Step:** Assume the relation is true for all orders up to k. We will
demonstrate that it also holds for k + 1:
For every i = 0, . . . , n − k, we can express:
∆k yi
f [xi , xi+1 , . . . , xi+k ] =
k!hk
and
∆k yi+1
f [xi+1 , xi+1 , . . . , xi+k+1 ] = .
k!hk
Additionally, we can compute:
∆k yi+1 − ∆k yi ∆k+1 yi
f [xi , xi+1 , . . . , xi+k+1 ] = = .
k!hk · (k + 1)h (k + 1)!hk+1
i(i − 1) · · · (i − k + 1)
Cnk = for k > 0 and Cn0 = 1,
k!
we obtain:
n
X
Pn (x) = pn (x0 + ih) = Cnk ∆k f (x0 ).
k=0
50
Numerical Analysis
Example
Let’s determine the Newton Forward Formula associated with the function f
passing through the points (0, 2), (1, 3), (2, 5), and (3, 4).
- For order n:
∇n yn = ∇n−1 yn − ∇n−1 yn−1 (i = n).
51
Numerical Analysis
∇k yi+k
= f [xi , xi+1 , . . . , xi+k ], k = 1, . . . , n; i = 0, . . . , n − k.
k!hk
where yi = f (xi ) for all i ∈ {0, . . . , n}.
n k−1
X ∇k f (xn ) Y
Pn (x) = f (xn ) + (x − xn−j ).
k=1
k!hk j=0
52
Numerical Analysis
−3 −4
P3 (x) = 4 + (−1)(x − 3) + (x − 3)(x − 2) + (x − 3)(x − 2)(x − 1)
2 6
This simplifies to:
3 2
P3 (x) = 4 − (x − 3) − (x − 3)(x − 2) − (x − 3)(x − 2)(x − 1).
2 3
Finally, the formula is:
1 10
P3 (x) = x3 − 4x2 + x + 2.
3 3
f (x) ≈ Pn (x) ± .
Lemma
Let g be a continuous function on [a, b] and m times differentiable on ]a, b[.
Suppose there exist m + 1 points c0 < c1 < · · · < cm in [a, b] such that
g(ci ) = 0. Then there exists ξ ∈]c0 , cm [ such that g (m) (ξ) = 0.
53
Numerical Analysis
Theorem
Let x0 , x1 , . . . , xn ∈ [a, b] be n + 1 distinct points, and let f be a function that
is continuous on [a, b] and (n + 1) times continuously differentiable on ]a, b[,
where a = min0≤i≤n xi and b = max0≤i≤n xi . Then, for every x ∈ [a, b], there
exists a point ξx ∈]a, b[ such that
f (n+1) (ξx )
En (x) = f (x) − Pn (x) = (x − x0 )(x − x1 ) · · · (x − xn ).
(n + 1)!
Moreover, if f (n+1) is continuous on [a, b], then
Mn+1
|En (x)| ≤ |(x − x0 )(x − x1 ) · · · (x − xn )|,
(n + 1)!
where Mn+1 = maxx∈[a,b] |f (n+1) (x)|.
It is clear that g ∈ C n+1 ([a, b]); g(xi ) = 0 for all i ∈ {0, 1, . . . , n} and g(x) = 0.
Therefore, g has (n + 2) distinct roots in [a, b]. Hence, by the previous lemma, there
exists ξx ∈]a, b[ such that g (n+1) (ξx ) = 0.
n
(n+1) (n+1)
Y 1
g (ξx ) = 0 ⇐⇒ f (ξx ) − En (x) · · (n + 1)! = 0.
i=0
x − xi
54
Numerical Analysis
n
f (n+1) (ξx ) Y
En (x) = × (x − xi ).
(n + 1)! i=0
Therefore,
n
Mn+1 Y
|En (x)| ≤ (x − xi )
(n + 1)! i=0
Mn+1
≤ × (b − a)n .
(n + 1)!
The interpolation error can be expressed using the same general relation re-
gardless of the method used, whether it is Lagrange, Newton, or another. This
is because the interpolation polynomial obtained through any of these meth-
ods is identical, as ensured by the uniqueness of the interpolating polynomial.
One notable advantage of the Newton form of interpolation is that it provides
an explicit formula for the interpolation error:
Example
Five interpolation points give n = 4. Therefore, f (n+1) (x) = f (5) (x) = cos(x).
There exists a value ξ ∈ ]0, 1[ such that
f (5) (ξ) 1
1 1 1 1 1 1 1 3 1
sin − P4 = −0 − − − −1 .
3 3 5! 3 3 4 3 2 3 4 3
55
Numerical Analysis
Simplifying, we obtain:
cos(ξ) 1 · 1 · 5 · 2 · 1 cos(ξ) 10
= · = · .
5! 3 · 12 · 6 · 12 · 3 5! 1296
Taking maxξ∈[0,1] | cos(ξ)| = 1, we have:
1 1 10
sin − p4 ≤ ≈ 0.0000064.
3 3 1296 × 120
56