0% found this document useful (0 votes)
28 views92 pages

NA Ch3 Student

This document summarizes Chapter 3 of the textbook Numerical Analysis, which discusses interpolation and polynomial approximation. Section 3.1 introduces Lagrange polynomials as a method of interpolation that uses information from various points to construct a polynomial that passes through those points. It describes how Lagrange polynomials are defined for two points and verify that the polynomials take on the function values at those points. The section also discusses how Taylor polynomials provide less accurate approximations away from the center point compared to Lagrange polynomials.

Uploaded by

Ahiduzzaman Ahir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views92 pages

NA Ch3 Student

This document summarizes Chapter 3 of the textbook Numerical Analysis, which discusses interpolation and polynomial approximation. Section 3.1 introduces Lagrange polynomials as a method of interpolation that uses information from various points to construct a polynomial that passes through those points. It describes how Lagrange polynomials are defined for two points and verify that the polynomials take on the function values at those points. The section also discusses how Taylor polynomials provide less accurate approximations away from the center point compared to Lagrange polynomials.

Uploaded by

Ahiduzzaman Ahir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 92

MATH 4513 Numerical Analysis

Chapter 3. Interpolation and Polynomial Approximation

Xu Zhang

Department of Mathematics
Oklahoma State University

Text Book: Numerical Analysis (10th edition)


R. L. Burden, D. J. Faires, A. M. Burden

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 1 / 92
Chapter 3. Interpolation and Polynomial Approximation

Table of Contents

Chapter 3. Interpolation and Polynomial Approximation

3.1 Interpolation and Lagrange Polynomials


3.2 Divided Differences
3.3 Hermite Interpolation
3.4 Cubic Spline Interpolation
3.5 Parametric Curve

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 2 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

3.1 Interpolation and Lagrange Polynomials


One of the most useful classes of functions is polynomials:

Pn (x) = an xn + an−1 xn−1 + · · · + a1 x + a0 .

where n is a nonnegative integer and a0 , a1 , · · · , an are real


constants.

One reason is that any continuous function can be approximated


by a polynomial arbitrarily close. By this we mean that given any
continuous function, there exists a polynomial that is as “close” to
the given function as desired. (see Theorem 1)

Another important reason for considering the class of polynomials


in the approximation of functions is that the derivative and
indefinite integral of a polynomial are easy to determine and are
also polynomials.
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 3 / 92
P (x) = a x n + a
n PolynomialnApproximation
Chapter 3. Interpolation and n−1 3.1 +
x n−1 · · · + aand
Interpolation + a0 , Polynomials
1 x Lagrange

where n is a nonnegative integer and a0 , . . . , an are real constants. One reason for their
Theorem 1 (Weierstrass Approximation Theorem).
importance is that they uniformly approximate continuous functions. By this we mean that
given any function, defined and continuous on a closed and bounded interval, there exists
Suppose f ∈ C[a, b]. For each  > 0, there exists a polynomial P (x)
a polynomial that is as “close” to the given function as desired. This result is expressed
such that
precisely in the Weierstrass Approximation Theorem. (See Figure 3.1.)
|f (x) − P (x)| < , for all x ∈ [a, b].

y
y  f(x)  ε
y  P(x)
y  f(x)
y  f(x)  ε

a b x

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 4 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

A typical example for polynomial approximations is the Taylor polynomial.


f 00 (x0 ) f (n) (x0 )
Pn (x) = f (x0 ) + f 0 (x0 )(x − x0 ) + (x − x0 )2 + · · · + (x − x0 )n
2 n!

For example, using Taylor polynomials at x0 = 0 to approximate


f (x) = ex , we obtain
P0 (x) = 1,
P1 (x) = 1 + x,
x2
P2 (x) = 1 + x + ,
2
x2 x3
P3 (x) = 1 + x + + ,
2 6
x2 x3 x4
P4 (x) = 1 + x + + + ,
2 6 24
x2 x3 x4 x5
P5 (x) = 1 + x + + + + ,
2 6 24 120
···

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 5 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials
Figure 3.2
y

20
y  P5(x)
y  ex
y  P4(x)
15
y  P3(x)

10
y  P2(x)

5
y  P1(x)

y  P0(x)
1 1 2 3 x

Note that even for higher-degree polynomials, error becomes


Although better approximations are obtained for f (x) = ex if higher-degree Taylor
progressively worse
polynomials are used,as
thiswe move
is not true foraway fromConsider,
all functions. the point x0 =example,
as an extreme 0.
using Taylor polynomials of various degrees for f (x) = 1/x expanded about x0 = 1 to
approximate f (3) = 1/3. Since
f (3) = 20.0855
−1  −2  −3
P1 (3) = 4,f (x)P=2x(3), f=(x)8.5,
= −x , f (x) = (−1) 2 · x , 2
P3 (3) = 13, P4 (3) = 16.375.
and, in general,
Xu Zhang (Oklahoma State University) MATH
(k)
4513 Numerical
k
Analysis
−k−1
Fall 2020 6 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Remark on Taylor Polynomials


For Taylor polynomials, all information used in the approximation
is concentrated at the single number x0 , so these polynomials will
generally give inaccurate approximations as we move away from
x0 . This limits Taylor polynomial approximation to the situation in
which approximations are needed only at numbers close to x0 .

A good interpolation polynomial needs to provide a relatively


accurate approximation over an entire interval, and Taylor
polynomials do not generally do this.

It is usually more efficient to develop methods that use


information spreaded at various points.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 7 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Lagrange Interpolation Polynomials


Suppose that a function f (x) passes through two points (x0 , y0 ) and
(x1 , y1 ). Define the following linear Lagrange polynomials
x − x1 x − x0
L0 (x) = , L1 (x) = .
x0 − x1 x1 − x0

It is easy to verify that


L0 (x0 ) = 1, L0 (x1 ) = 0,

L1 (x0 ) = 0, L1 (x1 ) = 1.

The linear Lagrange interpolating polynomial through (x0 , y0 ) and


(x1 , y1 ) is
x − x1 x − x0
P (x) = y0 L0 (x) + y1 L1 (x) = y0 + y1 .
x0 − x1 x1 − x0
It can be verified that P (x0 ) = y0 and P (x1 ) = y1 . (Exercise)
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 8 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Example 2.
Determine the linear Lagrange interpolating polynomial that passes
through the points (2, 4) and (5, 1).

Solution
In this case, we have
x−5 1 x−2 1
L0 (x) = = − (x − 5), and L1 (x) = = (x − 2).
2−5 3 5−2 3
3.1 Interpolation and the Lagra

Then, the linear Lagrange interpolating polynomial is


Figure 3.3
y
P (x) = y0 L0 (x) + y1 L1 (x) (2,4)
4
1 1 3
= − (x − 5) · 4 + (x − 2) · 1
3 3 2
y  P(x) = x  6
4 20 1 2 1 (5,1)
=− x+ + x−
3 3 3 3
1 2 3 4 5 x
= −x + 6.
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 9 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials
To generalize the concept of linear interpolation, consider the construction of a poly-
nomial of degree at most n that passes through the n + 1 points
To generalize the concept of linear interpolation, consider the
(x0 , f (x0 )), (x1 , f (x1 )), . . . , (xn , f (xn )).
construction of a polynomial of degree at most n that passes
through the
(See Figure 3.4.)
following n + 1 points:

(x0 , f (x0 )), (x1 , f (x1 )), · · · , (xn , f (xn )).


ure 3.4
y

y  f (x)

y  P(x)

x0 x1 x2 xn x

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 10 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Construct for each k = 0, 1, · · · , n, a function Ln,k (x) such that


(
1 if i = k
Ln,k (xi ) = δik =
0 if i 6= k.

To satisfy Ln,k (xi ) = 0 for each i 6= k requires the numerator of


Ln,k (x) contains

(x − x0 ) · · · (x − xk−1 )(x − xk+1 ) · · · (x − xn )

To satisfy Ln,k (xk ) = 1 requires the denominator of Ln,k (x) must


be this same term but evaluated at xk

(xk − x0 ) · · · (xk − xk−1 )(xk − xk+1 ) · · · (xk − xn )

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 11 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Definition 3 (Lagrange Interpolating Polynomials).


The n-th Lagrange interpolating polynomials are defined by

(x − x0 ) · · · (x − xk−1 )(x − xk+1 ) · · · (x − xn )


Ln,k (x) =
(xk − x0 ) · · · (xk − xk−1 )(xk − xk+1 ) · · · (xk − xn )
n
Y (x − xi )
ER 3
=
Interpolation and Polynomial
for each k = 0, 1, · · · , n.
i6=k
(xApproximation
k − xi )
i=0
Figure 3.5
L n,k(x)

x0 x1 ... x k⫺1 xk x k⫹1 ... x n⫺1 xn x

We may write Ln,k (x) simply as Lk (x) when there is no confusion as to


its degree.
The interpolating polynomial is easily described once the form of Ln,k is known. This
Xu Zhang polynomial,
(Oklahoma State University)
called MATH 4513
the nth Lagrange Numerical Analysis
interpolating Fall 2020
polynomial, is defined in the following 12 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Theorem 4.
If x0 , x1 , · · · , xn are n + 1 distinct numbers and f is a function whose
values are given at these numbers, then a unique polynomial P (x) of
degree at most n exists with

f (xk ) = P (xk ), for each k = 0, 1, · · · , n.

This polynomial is given by


n
X
P (x) = f (x0 )Ln,0 (x) + · · · + f (xn )Ln,n (x) = f (xk )Ln,k (x),
k=0
where for each k = 0, 1, · · · , n
(x − x0 ) · · · (x − xk−1 )(x − xk+1 ) · · · (x − xn )
Ln,k (x) =
(xk − x0 ) · · · (xk − xk−1 )(xk − xk+1 ) · · · (xk − xn )
n
Y (x − xi )
= for each k = 0, 1, · · · , n.
i6=k
(x k − xi )
i=0

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 13 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Example 5.

Use the numbers (called nodes) x0 = 2, x1 = 2.75, and x2 = 4 to find the


second-degree Lagrange interpolating polynomial P2 (x) for the function
1 1
f (x) = . Then use this polynomial to approximate f (3) = .
x 3

Solution (1/2)
The Lagrange polynomials associated with x0 = 2, x1 = 2.75, and x2 = 4
are
(x − 2.75)(x − 4) 2
L0 (x) = = (x − 2.75)(x − 4).
(2 − 2.75)(2 − 4) 3
(x − 2)(x − 4) 16
L1 (x) = = − (x − 2)(x − 4).
(2.75 − 2)(2.75 − 4) 15
(x − 2)(x − 2.75) 2
L2 (x) = = (x − 2)(x − 2.75).
(2.75 − 2)(4 − 2.75) 5

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 14 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Solution (2/2)
Also,
1 4 1
f (x0 ) = f (2) = , f (x1 ) = f (2.75) = , and f (x2 ) = f (4) =
2 11 4
So the second-degree Lagrange Interpolating polynomial is
X 2
P2 (x) = f (xk )Lk (x)
k=0
1 2 4 16
= · (x − 2.75)(x − 4) − · (x − 2)(x − 4)
2 3 11 15
1 2
+ · (x − 2)(x − 2.75)
4 5
1 2 35 49
= x − x+
22 88 44

Use P2 (x) to approximate f (x) at x = 3


29
f (3) ≈ P2 (3) = = 0.32955. |f (3) − P2 (3)| = 0.03418
88
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 15 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

For the error bound of the Lagrange interpolation, we have the


following result.
Theorem 6 (Lagrange Interpolation Error Theorem).

Suppose x0 , x1 , · · · , xn are distinct numbers in the interval [a, b] and


f ∈ C n+1 [a, b]. Then, for each x ∈ [a, b], there exists a number ξ(x)
between min{x0 , x1 · · · xn } and max{x0 , x1 · · · xn }, and hence in [a, b],
such that

f (n+1) (ξ)
f (x) = P (x) + (x − x0 )(x − x1 ) · · · (x − xn ),
(n + 1)!

where P (x) is the interpolating polynomial of f (x).

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 16 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Comparison of Lagrange polynomials and Taylor polynomials


The nth-degree Taylor polynomial around x0 concentrates all the
known information at x0 , and has an error term of the form

f (n+1) (ξ)
(x − x0 )n+1 .
(n + 1)!

The nth-degree Lagrange polynomial uses information at distinct


numbers x0 , x1 , · · · , xn , and, in place of (x − x0 )n , its error
formula uses a product of the n + 1 terms:

f (n+1) (ξ)
(x − x0 )(x − x1 ) · · · (x − xn ).
(n + 1)!

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 17 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Example 7.
In Example 5, we found the 2nd-degree Lagrange polynomial P2 (x) for
1
f (x) = on [2, 4] using the nodes x0 = 2, x1 = 2.75, x2 = 4 Determine the
x
error form of this polynomial, and the maximum error when the polynomial is
used to approximate f (x) for x ∈ [2, 4].

Solution (1/2)

Since f (x) = x1 , we have

f 0 (x) = −x−2 , f 00 (x) = 2x−3 , f 000 (x) = −6x−4 .

By Theorem 6, we have on the interval [2, 4],

f 000 (ξ) 6ξ −4 1 1
|f (x) − P (x)| = g(x) = |g(x)| = 4 |g(x)| ≤ |g(x)|
3! 6 ξ 16
35 2 49
where, g(x) = (x − 2)(x − 2.75)(x − 4) = x3 − 4 x + 2 x − 22.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 18 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Solution (2/2)
We now need to determine the maximum value of |g(x)| on x ∈ [2, 4].
35 49 1
g 0 (x) = 3x2 −
x+ = (3x − 7)(2x − 7).
2 2 2
7 7
The critical points are x1 = and x2 = . The global extrema are
3 2
among the critical points and endpoints x = 2 and x = 4.
7 25 7 9
g(2) = 0, g( ) = , g( ) = − , g(4) = 0.
3 108 2 16
Hence, the maximum error is

1 9 9
max |f (x) − P (x)| ≤ − = ≈ 0.0351526.
x∈[2,4] 16 16 256

Note that in Example 5, we found the error at x = 3 is


|f (3) − P2 (3)| = 0.03418 < 0.0351526 = max |f (x) − P2 (x)|.
2≤x≤4

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 19 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Coding Exercise (1/2)


Write a MATLAB subroutine
L = LagP oly(dataX, k, x)

to realize the evaluation of the Lagrange polynomial


n
(x − x0 ) · · · (x − xk−1 )(x − xk+1 ) · · · (x − xn ) Y (x − xi )
Lk (x) = = .
(xk − x0 ) · · · (xk − xk−1 )(xk − xk+1 ) · · · (xk − xn ) i6=k (xk − xi )
i=0

the input dataX = [x0 , x1 , · · · , xn ] contains n + 1 distinct points.


the input k is the index of the Lagrange polynomial.
the input x is the point you want to evaluate.
the output L is the value of Lk (x).

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 20 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials

Coding Exercise (2/2)


Write a second MATLAB subroutine
y = LagInterp(dataX, dataY, x)

to realize the evaluation of the Lagrange interpolating polynomial


n
X
P (x) = yk Lk (x)
k=1

the input dataX = [x0 , x1 , · · · , xn ] stores n + 1 distinct points.


the input dataY = [y0 , y1 , · · · , yn ] stores n + 1 y-values.
the input x is the point you want to evaluate.
the output y is the value of P (x).
for evaluation of Lk (x), you can call the first subroutine

L = LagP oly(dataX, k, x)

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 21 / 92
olation and Polynomial Approximation
Chapter 3. Interpolation and Polynomial Approximation 3.1 Interpolation and Lagrange Polynomials
Introduction
Exercise
A census of the population of the United States is taken every 10 years. The following
tionA census tableofliststhe
thepopulation
population, inof the United
thousands States
of people, fromis1950
taken every
to 2000, and10
theyears.
data are The
also
f the following
population of the table lists
United States the
is taken population,
every in
10 years. The following thousands of people, from 1950 to
represented in the figure.
e population, in thousands of people, from 1950 to 2000, and the data are also
in the2000,
figure. and the data are also represented in the figure.

1950 Year
1960 1970 19801950 1990 1960
2000 1970 1980 1990 2000
151,326 179,323 203,302 226,542 249,633 281,422
) Population 151,326 179,323 203,302 226,542 249,633 281,422
(in thousands)

P(t)

3  10 8 In reviewing these data, we might ask


P(t) whether they could be used to provide a
reasonable estimate of the population,
2  10 8 3  10 8
say, in 1975 or even in the year 2020.
Population

We can construct the Lagrange


1  10 8
interpolation on these given data to
2  10 8 generate a fifth degree polynomial.
Population

1950 1960 1970 1980 1990 2000 t Then use the interpolation polynomial
Year for prediction.
1
Xu Zhang (Oklahoma State University)  10 8 MATH 4513 Numerical Analysis Fall 2020 22 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

3.2 Divided Differences


Recall the n-th Lagrange Interpolation Pn (x) of the function f (x) at n + 1
distinct points x0 , x1 · · · , xn .
n
X
Pn (x) = f (xk )Ln,k (x)
k=0

where
n
Y (x − xi )
Ln,k (x) = .
i6=k
(xk − xi )
i=0

Question: What if we have one more data point available


(xn+1 , f (xn+1 )), then how to construct a new n + 1-th degree
interpolation Pn+1 (x)?
Answer: We have to abandon all Lagrange polynomial Ln,k (x), and
reconstruct new Lagrange polynomials Ln+1,k (x).
Question: Is there a more efficient way for adding more data points?
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 23 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

Although the interpolation polynomial Pn (x) is unique, there are


alternative representations that are useful in certain situations.
In fact, we can write Pn (x) in the following form
Pn (x) = a0 + a1 (x − x0 ) + a2 (x − x0 )(x − x1 ) + · · ·
+ an (x − x0 )(x − x1 ) · · · (x − xn−1 ),
for appropriate constants a0 , a1 , · · · , an .
Note that
Pn (x0 ) = f (x0 ) =⇒ a0 = f (x0 )
Pn (x1 ) = f (x1 ) =⇒ a1 (x1 − x0 ) = f (x1 ) − f (x0 )
f (x1 ) − f (x0 )
=⇒ a1 =
x1 − x0
Exercise: verify that
f (x2 ) − f (x1 ) f (x1 ) − f (x0 )

x2 − x1 x1 − x0
a2 =
x2 − x0

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 24 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

We now introduce the divided-difference notation, which will be very useful


in determine the values of ai .
Definition 8 (Divided Difference).
The zeroth divided difference of the function f at xi is
f [xi ] = f (xi ).

The first divided difference of f at xi and xi+1 is

f [xi+1 ] − f [xi ]
f [xi , xi+1 ] =
xi+1 − xi
The second divided difference of f at xi , xi+1 and xi+2 is

f [xi+1 , xi+2 ] − f [xi , xi+1 ]


f [xi , xi+1 , xi+2 ] = .
xi+2 − xi
In general, the k-th divided difference of f at xi , xi+1 , · · · , xi+k is

f [xi+1 , xi+2 , · · · , xi+k ] − f [xi , xi+1 , · · · , xi+k−1 ]


f [xi , xi+1 , · · · , xi+k ] = .
xi+k − xi

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 25 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

It can be seen that


a0 = f (x0 ) = f [x0 ],
f (x1 ) − f (x0 )
a1 = = f [x0 , x1 ]
x1 − x0
f (x2 )−f (x1 ) f (x1 )−f (x0 )
x2 −x1 − x1 −x0
a2 = = f [x0 , x1 , x2 ]
x2 − x0

In general, we have
ak = f [x0 , x1 , · · · , xk ], for all k = 0, 1, · · · , n.

Interpolation with Newton’s Divided Difference


The Lagrange interpolation Pn (x) of f (x) at x0 , x1 , · · · , xn can be
written as
n
X
Pn (x) = f [x0 ] + f [x0 , · · · , xk ](x − x0 ) · · · (x − xk−1 ).
k=1

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 26 / 92
k=1
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences
The value of f [x0 , x1 , . . . , xk ] is independent of the order of the numbers x0 , x1 , . . . , xk , as
shown in Exercise 21.
The generation of the divided differences is outlined in Table 3.9. Two fourth and one
fifth difference can also be determined from these data.
Divided Difference Table
Table 3.9
First Second Third
x f (x) divided differences divided differences divided differences

x0 f [x0 ]
f [x1 ] − f [x0 ]
f [x0 , x1 ] =
x1 − x0
f [x1 , x2 ] − f [x0 , x1 ]
x1 f [x1 ] f [x0 , x1 , x2 ] =
x2 − x 0
f [x2 ] − f [x1 ] f [x1 , x2 , x3 ] − f [x0 , x1 , x2 ]
f [x1 , x2 ] = f [x0 , x1 , x2 , x3 ] =
x2 − x1 x3 − x0
f [x2 , x3 ] − f [x1 , x2 ]
x2 f [x2 ] f [x1 , x2 , x3 ] =
x3 − x1
f [x3 ] − f [x2 ] f [x2 , x3 , x4 ] − f [x1 , x2 , x3 ]
f [x2 , x3 ] = f [x1 , x2 , x3 , x4 ] =
x3 − x2 x4 − x 1
f [x3 , x4 ] − f [x2 , x3 ]
x3 f [x3 ] f [x2 , x3 , x4 ] =
x4 − x 2
f [x4 ] − f [x3 ] f [x3 , x4 , x5 ] − f [x2 , x3 , x4 ]
f [x3 , x4 ] = f [x2 , x3 , x4 , x5 ] =
x4 − x3 x5 − x2
f [x4 , x5 ] − f [x3 , x4 ]
x4 f [x4 ] f [x3 , x4 , x5 ] =
x5 − x 3
f [x5 ] − f [x4 ]
f [x4 , x5 ] =
x5 − x4
x5 f [x5 ]

ALGORITHM Newton’s Divided-Difference Formula


3.2
To obtain the divided-difference coefficients of the interpolatory polynomial P on the (n+1)
distinct numbers x0 , x1 , . . . , xn for the function f :
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 27 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

Example 9.
Compute a divided difference table for these function values:

x 3 1 5 6
f (x) 1 −3 2 4

Then determine the Newton interpolation polynomial.

Solution (1/2)
Arrange the table vertically to have

i xi f [xi ] f [xi−1 , xi ] f [xi−2 , xi−1 , xi ] f [xi−3 , xi−2 , xi−1 , xi ]


0 3 1
1 1 −3 2
2 5 2 5/4 −3/8
3 6 4 2 3/20 7/40

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 28 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

Solution (2/2)
Note that the values marked in red and blue will be used for constructing the
interpolating polynomial

i xi f [xi ] f [xi−1 , xi ] f [xi−2 , xi−1 , xi ] f [xi−3 , xi−2 , xi−1 , xi ]


0 3 1
1 1 −3 2
2 5 2 5/4 −3/8
3 6 4 2 3/20 7/40

The Newton interpolation polynomial is

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 )
3 7
= 1 + 2(x − 3) + − (x − 3)(x − 1) + (x − 3)(x − 1)(x − 5)
8 40
1
= (7x3 − 78x2 + 301x − 350)
40

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 29 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

Comparison of Lagrange and Newton


Lagrange Interpolation is sometimes said to require less work,
and is sometimes recommended for problems in which it’s known,
in advance, from previous experience, how many terms are
needed for sufficient accuracy.

The Newton’s Interpolation has the advantage that more data


points can be added, for improved accuracy, without re-doing the
whole problem.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 30 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

Algorithm for Generating Divided Differences Table


Inputs: dataX = [x0 , x1 , x2 , · · · , xn ], dataY = [y0 , y1 , y2 , · · · , yn ]
Output: C = [cij ] is an (n + 1) × (n + 1) divided difference matrix.

C = divdifTable(dataX,dataY)

For j = 1 : n
For i = 0 : n − j
ci+1,j−1 − ci,j−1
cij = (note: cij = f [xi , xi+1 , · · · , xi+j ])
xi+j − xi
End
End
x0 y0 c00 c01 c02 c03 · · · c0,n−1 c0n
x1 y1 c10 c11 c12 c13 · · · c1,n−1
x2 y2 c20 c21 c22 c23 · · ·
.. .. .. .. ..
. . . . .
xn−1 yn−1 cn−1,0 cn−1,1
xn yn cn0

note: ci,0 = yi , for i = 0, 1, · · · , n.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 31 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.2 Divided Differences

Properties of Divided Difference


If z0 , z1 , · · · , zn is a permutation of x0 , x1 , · · · , xn , then

f [z0 , z1 , · · · , zn ] = f [x0 , x1 , · · · , xn ].

(Hint: consider the leading coefficient of Pn (x).)

Suppose that f ∈ C n [a, b] and x0 , x1 , · · · , xn are distinct numbers


in [a, b]. Then there exists a number ξ ∈ (a, b) with

f (n) (ξ)
f [x0 , x1 , · · · , xn ] = .
n!
(Hint: use the generalized Rolle’s theorem.)

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 32 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

3.3 Hermite Interpolation


In previous sections, we introduced the interpolation P (x) of a
continuous function f (x) at some given points
x0 x1 x2 ··· xn
f (x0 ) f (x1 ) f (x2 ) · · · f (xn )

In some applications, we want not only the interpolation function P (x) to


match with f (x) at some points, but also the derivatives of P (x) to match
with the derivatives of f (x) at those points. These interpolating
polynomials are called osculating polynomials.

In particular, we look for a polynomial P (x) of the least degree such that
P (x) and P 0 (x) agrees with f and its derivative f 0 at n + 1 distinct points
x0 , x1 , · · · , xn , i.e.,
P (xi ) = f (xi )
i = 0, 1, · · · , n.
P 0 (xi ) = f 0 (xi )
This is called Hermite interpolation.
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 33 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Recall the nth-degree Lagrange interpolating polynomials:


n
Y (x − xi )
Ln,k (x) = k = 0, 1, · · · , n.
i6=k
(xk − xi )
i=0

They satisfy Ln,k (xi ) = δik .

Construction of Hermite Interpolation (1/3)


Define n + 1 polynomials:
 
Ak (x) = 1 − 2(x − xk )L0n,k (xk ) L2n,k (x) k = 0, 1, · · · , n.

It can be verified that


The degree of Ak is 2n + 1.

Ak (xi ) = δik .

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 34 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Construction of Hermite Interpolation (2/3)


Also, the derivative of Ak (x) is
   
A0k (x) = −2L0n,k (xk ) L2n,k (x)+ 1−2(x−xk )L0n,k (xk ) 2Ln,k (x)L0n,k (x).

Thus,
A0k (xk ) = −2L0k (xk ) + 2L0k (xi ) = 0,
and
A0k (xi ) = 0, for i 6= k.

In summary, we have

Ak (xi ) = δik , A0k (xi ) = 0.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 35 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Construction of Hermite Interpolation (3/3)


Define another n + 1 polynomials:

Bk (x) = (x − xk )L2n,k (x) k = 0, 1, · · · , n.

It can be verified that


The degree of Bk (x) is 2n + 1.
Bk (xi ) = (xi − xk )L2n,k (xi ) = 0 k = 0, 1, · · · , n.
The derivative of Bk (x) is

Bk0 (x) = L2n,k (x) + 2(x − xk )Ln,k (x)L0n,k (x).

Thus, so that Bk0 (xk ) = 1, and Bk0 (xi ) = 0, for i 6= k. Hence,

Bk (xi ) = 0, Bk0 (xi ) = δik .

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 36 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Hermite Interpolation
If f ∈ C 1 [a, b] and x0 , x1 · · · , xn ∈ [a, b] are distinct, the unique
polynomial of least degree agreeing with f and f 0 at x0 , x1 · · · , xn is
the Hermite polynomial of degree at most 2n + 1 given by
n
X n
X
H2n+1 (x) = f (xk )Ak (x) + f 0 (xk )Bk (x).
k=0 k=0

where
 
Ak (x) = 1 − 2(x − xk )L0n,k (xk ) L2n,k (x),
Bk (x) = (x − xk )L2n,k (x),
n
Y (x − xi )
and Ln,k (x) = .
i6=k
(xk − xi )
i=0

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 37 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Example 10.
Determine the Hermite polynomial that interpolates the data below
x 1 2
f (x) 1 −3
f 0 (x) −1 2

Solution(1/2)
First compute the Lagrange polynomials of the point x0 = 1 and x1 = 2.

L0 (x) = −(x − 2), L1 (x) = x − 1

Next, we compute third-order polynomials (n = 1, 2n + 1 = 3).

A0 (x) = (1 − 2(x − 1)(−1))(x − 2)2 = (2x − 1)(x − 2)2


A1 (x) = (1 − 2(x − 2))(x − 1)2 = −(2x − 5)(x − 1)2
B0 (x) = (x − 1)(x − 2)2 ,
B1 (x) = (x − 2)(x − 1)2

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 38 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Solution (2/2)
Then, the Hermite interpolating polynomial is

H3 (x) = f (x0 )A0 (x) + f (x1 )A1 (x) + f 0 (x0 )B0 (x) + f 0 (x1 )B1 (x)
= 1 · (2x − 1)(x − 2)2 + (−3) · −(2x − 5)(x − 1)2
+(−1) · (x − 1)(x − 2)2 + 2 · (x − 2)(x − 1)2
= 9x3 − 39x2 + 50x − 19.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 39 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

There is an alternative approach to construct Hermite


interpolation using Newton’s divided differences.
Since each data point xi is associated with two values f (xi ) and
f 0 (xi ). We denote

z2i = z2i+1 = xi , i = 0, 1, · · · n.

and conduct the divided difference table using z0 , z1 , · · · , z2n+1 .


Since z2i = z2i+1 = xi , we cannot define f [z2i = z2i+1 ] by the
standard first-divided difference formula
f [z2i+1 ] − f [z2i ]
f [z2i , z2i+1 ] = ,
z2i+1 − z2i

but instead, the reasonable substitution is

f [z2i , z2i+1 ] = f 0 (xi ).

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 40 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

The original data table

x0 x1 x2 ··· xn
f (x0 ) f (x1 ) f (x2 ) · · · f (xn )
f 0 (x0 ) f 0 (x1 ) f 0 (x2 ) · · · f 0 (xn )

can be represented by zi , 0 ≤ i ≤ 2n + 1

x0 x0 x1 x1 x2 ··· xn−1 xn xn
z0 z1 z2 z3 z4 ··· z2n−1 z2n z2n+1
f (z0 ) f (z1 ) f (z2 ) f (z3 ) f (z4 ) · · · f (z2n−1 ) f (z2n ) f (z2n+1 )
f (x0 ) f (x0 ) f (x1 ) f (x1 ) f (x2 ) · · · f (xn−1 ) f (xn ) f (xn )

The only difference is that the first divided difference


f [z1 ] − f [z0 ] f [x0 ] − f [x0 ]
f [z0 , z1 ] = = = f 0 (x0 ).
z1 − z0 x0 − x0

Similar argument applies for f [z2 , z3 ], f [z4 , z5 ], · · · , f [z2n , z2n+1 ].


Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 41 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

ER 3 Interpolation and Polynomial Approximation


Divided-Difference Table for Hermite Polynomial
Table 3.16 First divided Second divided
z f (z) differences differences
z0 = x0 f [z0 ] = f (x0 )
f [z0 , z1 ] = f  (x0 )
f [z1 , z2 ] − f [z0 , z1 ]
z1 = x0 f [z1 ] = f (x0 ) f [z0 , z1 , z2 ] =
z2 − z0
f [z2 ] − f [z1 ]
f [z1 , z2 ] =
z2 − z1
f [z2 , z3 ] − f [z1 , z2 ]
z2 = x1 f [z2 ] = f (x1 ) f [z1 , z2 , z3 ] =
z3 − z1
f [z2 , z3 ] = f  (x1 )
f [z3 , z4 ] − f [z2 , z3 ]
z3 = x1 f [z3 ] = f (x1 ) f [z2 , z3 , z4 ] =
z4 − z2
f [z4 ] − f [z3 ]
f [z3 , z4 ] =
z4 − z3
f [z4 , z5 ] − f [z3 , z4 ]
z4 = x2 f [z4 ] = f (x2 ) f [z3 , z4 , z5 ] =
z5 − z3
f [z4 , z5 ] = f  (x2 )
z5 = x2 f [z5 ] = f (x2 )

2n+1
xample 2 Use the data given in Example
X 1 and the divided difference method to determine the Hermite
H2n+1
polynomial approximation at xf=
(x) = f [z 0 ] + , z1 , · · · , zk ](x − z0 )(x − z1 ) · · · (x − zk−1 ).
[z01.5.
k=1
Solution The underlined entries in the first three columns of Table 3.17 are the data given
in Example 1. The remaining entries in this table are generated by the standard divided-
Xu Zhang (Oklahoma
differenceState University)
formula (3.9). MATH 4513 Numerical Analysis Fall 2020 42 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Example 11.
Determine the Hermite polynomial that interpolates the data below
x 1 2
f (x) 1 −3
f 0 (x) −1 2

using Newton’s divided differences table.

Solution
The divided difference table is
z0 =1 f [z0 ] = 1 f [z0 , z1 ] = −1 f [z0 , z1 , z2 ] = −3 f [z0 , z1 , z2 , z3 ] = 9
z1 =1 f [z1 ] = 1 f [z1 , z2 ] = −4 f [z1 , z2 , z3 ] = 6
z2 =2 f [z2 ] = −3 f [z2 , z3 ] = 2
z3 =2 f [z3 ] = −3

Then the 3rd-degree Hermite interpolating polynomial is


H3 (x) = 1 − (x − 1) − 3(x − 1)2 + 9(x − 1)2 (x − 2)
= 9x3 − 39x2 + 50x − 19.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 43 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

For the error bound of the Hermite interpolation, we have the following
result.
Theorem 12 (Hermite Interpolation Error Theorem).

Suppose x0 , x1 , · · · , xn are distinct numbers in the interval [a, b] and


f ∈ C 2n+2 [a, b]. Then, for each x ∈ [a, b], there exists a number ξ in
(a, b) (generally unknown), such that

f (2n+2) (ξ)
f (x) = H2n+1 (x) + (x − x0 )2 (x − x1 )2 · · · (x − xn )2 ,
(2n + 2)!

where P2n+1 (x) is the Hermite interpolating polynomial of f (x).

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 44 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Example 13.
A baseball pitcher throws a fastball from the pitcher’s mound to the catcher.
Although the distance from the mound to the home plate is 60 feet 6 inches,
the ball typically travels about 55 feet 6 inches. Suppose the initial velocity of
the ball is 95 miles per hour (mph), and the terminal velocity is 92 mph.
Construct a Hermite interpolating polynomial for the data

Time t (in seconds) 0 0.4


Distance d (in feet) 0 55.5
Speed (in mph) 95 92

1 Use the derivative of Hermite polynomial to estimate the speed of the


baseball in mph at t = 0.2 seconds.
2 Does the maximum velocity of the ball occur at t = 0, or does the
derivative of the Hermite polynomial have a maximum exceeding 95
mph? If so, does this seem reasonable?

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 45 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Solution (1/3)
Convert “miles per hour” to “feet per second” (note 1 mph = 1.46667 fps).
Rewrite the table as follow
Time t (in seconds) 0 0.4
Distance d(t) (in feet) 0 55.5
Speed s(t) = d0 (t)(in fps) 139.33 134.93

Generate the Div-Diff table


t0 =0 f [t0 ] = 0 f [t0 , t1 ] = 139.33 f [t0 , t1 , t2 ] = −1.45 f [t0 , t1 , t2 , t3 ] = −20.25
t1 =0 f [t1 ] = 0 f [t1 , t2 ] = 138.75 f [t1 , t2 , t3 ] = −9.55
t2 = 0.4 f [t2 ] = 55.5 f [t2 , t3 ] = 134.93
t3 = 0.4 f [t3 ] = 55.5

The Hermite interpolating polynomial is

d(t) = 0 + 139.33(t − 0) − 1.45(t − 0)(t − 0) − 20.25(t − 0)(t − 0)(t − 0.4)


= −20.25t3 + 6.65t2 + 139.33t.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 46 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Solution (2/3)
The speed can be approximated by

d(t) = −20.25t3 + 6.65t2 + 139.33t


s(t) = d0 (t) = −60.75t2 + 13.3t + 139.33

The speed at t = 0.2 is s(0.2) = 139.56 fps = 95.15 mph.


To find the maximum speed, we consider the acceleration

a(t) = s0 (t) = −121.5t + 13.3 = 0 =⇒ t = 0.1095

The maximum speed is smax = 140.06 fps = 95.49 mph, occurs at


t = 0.1095 second.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 47 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.3 Hermite Interpolation

Solution (3/3)

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 48 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

3.4 Cubic Spline Interpolation


In previous sections, we introduced the approximation of arbitrary
functions on closed intervals using a single polynomial.

However, high-degree polynomials can oscillate erratically, that is, a


8 minor fluctuation over a small portion of the interval can induce large
1.3 1.9 fluctuations
2.1 2.6 over
3.0 3.9 4.4 4.7 5.0 6.0 7.0the entire
8.0 9.2 range.
10.5 11.3 11.6 12.0 12.6 13.0 13.3
1.5 1.85 2.1 2.6 2.7 2.4 2.15 2.05 2.1 2.25 2.3 2.25 1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25
The following is a 20th degree Lagrange interpolation approximating the
back of a duck. Clearly this does not reflect the profile of the back.
2
f (x)

4 7

3 6

2 5

1 4

3
1 2 3 4 5 6 7 8 9 10 11 12 13 x
2

-1

-2
0 2 4 6 8 10 12 14

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 49 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

In this section, we introduce the interpolation using piecewise


polynomials. This will effectively prevent the oscillation.
The simplest piecewise-polynomial approximation is piecewise-linear
interpolation. Consider a set of data points:
x0 x1 x2 ··· xn
f (x0 ) f (x1 ) f (x2 ) · · · f (xn )
3.5 Cubic Spline Interpolation 145
The following is a piecewise linear polynomial interpolation of a smooth
curve. Figure 3.7

y  f (x)

x0 x1 x2 ... xj x j1 x j2 ... x n1 xn x

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 50 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

The disadvantage of using piecewise linear approximation is that


the approximation function is not ”smooth”, i.e., it is not
differentiable at nodes xi .

Often it is clear from physical conditions that smoothness is


required, so the approximating function must be continuously
differentiable.

Using Hermite polynomials could be a choice, however this


requires the known of the derivative values at nodes.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 51 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

The goal in this section is to develop a new interpolation so that


it uses piecewise polynomials (to avoid oscillation).
it is continuously differentiable over the entire domain (to ensure
the smoothness).
it requires no specific derivative information of the original
function, except perhaps at the two endpoints of the interval
(minimum information from original function).

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 52 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

The most common piecewise-polynomial approximation is called


CHAPTER 3 Interpolation and Polynomial Approximation
cubic spline interpolation.
The interpolation uses piecewise cubic polynomials, and globally
Figure 3.8
second-order differentiable (S ∈ C 2 ([x0 , xn ])).
S(x)

S n2
S n1
S1 Sj
S j1
S0
S j (x j1)  f (x j1)  S j1(x j1)
S j (x j1)  Sj1(x j1)
S j(x j1)  S j1
 (x j1)

x0 x1 x2 ... xj x j1 x j2 ... x n2 x n1 x n x

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 53 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Cubic Spline Interpolation (Natural Spline)


Consider a set of data points:

x0 x1 x2 ··· xn
f (x0 ) f (x1 ) f (x2 ) · · · f (xn )

We construct a cubic spline interpolant S(x) for f satisfies


1 On each subinterval [xj , xj+1 ], S(x) is a cubic polynomial,
denoted by Sj (x) for j = 0, 1, · · · , n − 1.
2 Sj (xj ) = f (xj ) and Sj (xj+1 ) = f (xj+1 ) for j = 0, 1, · · · , n − 1.
3 0
Sj+1 (xj+1 ) = Sj0 (xj+1 ) for j = 0, 1, · · · , n − 2.
00 (x 00
4 Sj+1 j+1 ) = Sj (xj+1 ) for j = 0, 1, · · · , n − 2.

5 the natural boundary conditions, S 00 (x0 ) = S 00 (xn ) = 0.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 54 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Example 14.

Construct a natural spline that passes through the points (1, 2), (2, 3), and
(3, 5).

Solution (1/2)
This spline consists of two cubics. The two subintervals are [1, 2] and
[2, 3]. We write the piecewise cubic polynomial as follows
(
S0 (x) = a0 + b0 (x − 1) + c0 (x − 1)2 + d0 (x − 1)3 , on [1, 2]
S(x) =
S1 (x) = a1 + b1 (x − 2) + c1 (x − 2)2 + d1 (x − 2)3 , on [2, 3].

There are eight constants to be determined, which requires 8 conditions.


Four conditions come from nodal values:

S0 (1) = 2 =⇒ a0 = 2,
S0 (2) = 3 =⇒ b0 + c0 + d0 = 1,
S1 (2) = 3 =⇒ a1 = 3,
S1 (3) = 5 =⇒ b1 + c1 + d1 = 2,
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 55 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (2/2)
Two conditions come from derivatives at interior nodes x1 = 2.

S00 (2) = S10 (2) =⇒ b0 + 2c0 + 3d0 = b1 ,


S000 (2) = S100 (2) =⇒ 2c0 + 6d0 = 2c1 .

The last two conditions are from the natural boundary conditions

S000 (1) = 0 =⇒ 2c0 = 0,


S100 (3) = 0 =⇒ 2c1 + 6d1 = 0.

Solve this system of the eight equations gives the spline


3 1

2 + (x − 1) + (x − 1)3 ,
 on [1, 2],
S(x) = 4 4
3 + 3 (x − 2) + 3 (x − 2)2 − 1 (x − 2)3 , on [2, 3].

2 4 4
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 56 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Construction of a natural cubic spline

Assume the following n + 1 distinct points

x0 x1 x2 ··· xn
f (x0 ) f (x1 ) f (x2 ) · · · f (xn )

subdivide the interval [x0 , xn ] into n subintervals: Ij = [xj , xj+1 ],


j = 0, 1, · · · , n − 1.

The cubic spline S(x) restricted on the interval Ij is a cubic


polynomial Sj (x) for each 0 ≤ j ≤ n − 1:

S(x)|Ij = Sj (x) = aj + bj (x − xj ) + cj (x − xj )2 + dj (x − xj )3 .

There are 4n constants aj , bj , cj , and dj to be determined.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 57 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

On the interval [xj , xj+1 ], denote the length hj = xj+1 − xj . We


note that

Sj (x) = aj + bj (x − xj ) + cj (x − xj )2 + dj (x − xj )3 .

It is easy to see that

aj = f (xj ), j = 0, 1, · · · , n − 1. (3.1)

If we also let an = f (xn ), then by some calculations we can


represent bj and dj in terms of cj for 0 ≤ j ≤ n − 1:
1 hj
bj = (aj+1 − aj ) − (2cj + cj+1 ),
hj 3
(3.2)
1
dj = (cj+1 − cj ).
3hj

Here, we also use the definition cn = Sn00 (xn )/2.


Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 58 / 92
Proof The boundary conditions in this case imply that cn = S (xn )/2 = 0 and that
conditions
Chapter S  (a)
3. Interpolation 0 and S Approximation
and=Polynomial (b) = 0. 3.4 Cubic Spline Interpolation
0 = S  (x0 ) = 2c0 + 6d0 (x0 − x0 ),
We obtain a linear system for c , 1 ≤ j ≤ n − 1:
Proof The boundary conditions in this case j imply that cn = S  (xn )/2 = 0 and that
so c0 = 0. The two equations c0 = 0 and cn = 0 together with the equations in (3.21)
0 = S by
(x0c 2c0 + 3
) =vector (x0 −Ax
6d0(a x0 ),= b, 3
(n + ×
hproduce
j−1 cj−1a +2(h
linear system
j−1 +hdescribed
j )cj +h j the
j+1 = equation j+1 −a j )−where A is j −a
(athe 1)).
j−1
(n + 1) matrix hj hj−1
so c0 = 0. The two equations c0 = 0 and cn = 0 together with the equations in (3.21)
⎡ system described by the vector equation Ax = b, where A is the⎤(n + 1) ×
produce a linear
Write it as a 1
(n + 1) matrix⎢linear 0
system Ax 0=. .. ..b.. .. ..where . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.
.... .. ⎥
⎢⎡ .... .. ⎤⎥
⎢h0 2(h0 + h1 ) h1 . . ⎥
⎢ 1 . . . . . . . . . . . . . . . . .
. .
. . . . . . . . . . . . . . . . 0. .. ⎥
.
⎢⎢ 0 0 ...
. .... ⎥⎥
⎢⎢0. . . . h1 . . . . 2(h1 .+. . h2 ) . . .h.2 . . . . . . . . . . . . .. . ⎥⎥ . .
A=⎢ ⎢ . . .
⎢⎢..h0 2(h. 0. .+
. h ) . . h . . . . . . . . . . . . ... . ⎥ . ⎥⎥,
⎢⎢. . . . .1 . . . . . . . 1 .... . .
. . . . . . . . . .... . . . . . .. 0 ⎥ ⎥
⎢⎢..0 . . . . . .
. . 1 .+ .h.2. ). h2 . . . . . . . . . . . . . . . . . ⎥⎥
. ⎥
⎢⎢ . .. . . . h1 . . . . . . .2(h . . . . . . . . . . . . . + h .). . . h.. ⎥⎥
. . . . . . ⎥
A =⎢⎢. . .... . .. .. .
n−1 ⎥
,
⎣⎢.. .. . . . . . . . . . . . . . . . . . . . . .h.n−2 . . .
2(h n−2. . . . n−1
.... 0 ⎥⎦
.
⎢ ... . . . . . . . . . . . ...... .. . . . . . ...... .. . . . .. .... . . . . . . .... ⎥
⎢0. .... . 0 0 . 1⎥
⎢ .. . . . . . hn−2 2(hn−2 + hn−1 ) hn−1 ⎥
⎣. .... ⎦
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .... .0.
and b and x are the0 .vectors 0 1
⎡ ⎤
0
and b and x are the vectors ⎡ ⎤
⎢⎡ 3
(a − a1 ) − h (a1 − a0 )
3

⎤⎥ c0
⎢ h1 2
0 0
⎢ ⎥ ⎢
⎡⎢c⎤ ⎥
⎢ .. 3 (a1 − a0 ) ⎥⎥
1⎥
b = ⎢⎢ (a − a1 ) −
3
⎢ h1 2 . ⎥⎥ and x = ⎢
c0 . ⎥ .
⎢⎢ 3 h0
⎥ ⎢⎣ .⎦
.
⎢⎢ (an − an−1 ) −. 3 (an−1 − an−2 )⎥ ⎥⎥

⎢ c1 ⎥
b =⎣⎢hn−1 .. hn−2 ⎥⎦ and x = ⎢ . c⎥n .
⎢ 3 0 3 ⎥ ⎣ .. ⎦
⎢ ⎥
⎣ hn−1 (an − an−1 ) − hn−2 (an−1 − an−2 )⎦ cn
Xu Zhang (Oklahoma State University) 0 Numerical Analysis
MATH 4513 Fall 2020 59 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

The matrix A is strictly diagonally dominant, that is,


n
X
|aii | > |aij |, for all i = 1, 2, · · · , n.
j=1

The matrix A is nonsingular and the linear system Ax = b has a


unique solution(more in Chapter 6).

To solve the linear system Ax = b with Matlab, we can use the


command “backslash”:
x = A \ b.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 60 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Matlab File /Users/xuzhang/Dr.../natural_spline_coef.m


for Natural Spline Coefficient
9/14/20 3:08 PM 1 of 1

function [a,b,c,d] = natural_spline_coef(dataX,dataY)


%% Cubic Spline (Natual Boundary) Interpolation
% On each sub-interval, generate four coefficients aj, bj, cj, and dj
% Sj(x) = aj + bj(x-xj) + cj(x-xj)^2 + dj(x-xj)^3.
%
% Inputs: dataX dataY are row vectors of same dimension.
% Output: a is the collum vector that stores {aj} for j=1,2,...,n+1
% b is the collum vector that stores {bj} for j=1,2,...,n+1
% c is the collum vector that stores {cj} for j=1,2,...,n+1
% d is the collum vector that stores {dj} for j=1,2,...,n+1

%% Initialize h
n = length(dataX) - 1;
h = zeros(1,n);
for j = 1:n
h(j) = dataX(j+1) - dataX(j);
end
%% Prepare for Matrix A
A = zeros(n+1,n+1);
A(1,1) = 1; A(n+1,n+1) = 1;
for j = 2:n
A(j,j-1) = h(j-1);
A(j,j+1) = h(j);
A(j,j) = 2*(h(j-1)+h(j));
end
%% Prepare for vector bb
bb = zeros(n+1,1);
for j = 2:n
bb(j) = 3/h(j)*(dataY(j+1)-dataY(j)) - 3/h(j-1)*(dataY(j)-dataY(j-1));
end
%% Solve A*c = bb
c = A\bb;
%% Find a,b,d.
a = reshape(dataY(1:n+1),n+1,1);
b = zeros(n,1);
d = zeros(n,1);
for j = 1:n
b(j) = 1/h(j)*(a(j+1)-a(j)) - h(j)/3*(2*c(j)+c(j+1));
d(j) = (c(j+1) - c(j))/(3*h(j));
end
%% Remove the last entries of a and c
a(n+1) = [];
c(n+1) = [];

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 61 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

9/14/20 3:13 PM /Users/xuzhang/Dropbox.../natural_spline.m 1 of 1


Matlab File for Natural Spline Interpolation
function y = natural_spline(dataX,dataY,x)
%% Cubic Spline (Natual Boundary) Interpolation
% On each sub-interval, generate four coefficients aj, bj, cj, and dj
% Sj(x) = aj + bj(x-xj) + cj(x-xj)^2 + dj(x-xj)^3.
%
% Inputs: dataX dataY are row vectors of same dimension.
% x is the query point(s).
% Output: y is the value of spline interpolation y=S(x) at query points x

%% Generate Spline Coefficient [ai,bi,ci,di] on each interval.


[a,b,c,d] = natural_spline_coef(dataX,dataY);

%% Evaluate the query points


y = zeros(size(x));
for n = 1:length(x)
for j = 1:length(dataX)-1
if dataX(j) <= x(n) && dataX(j+1) >= x(n)
k = j;
break
end
end
xk = dataX(k);
y(n) = a(k) + b(k)*(x(n)-xk) + c(k)*(x(n)-xk)^2 + d(k)*(x(n)-xk)^3;
end

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 62 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Example 15.
At the beginning of Chapter 3, we gave some Taylor polynomial to
approximate the exponential function f (x) = ex . Use the data points

x 0 1 2 3
f (x) 1 e e2 e3

to form a natural cubic spline S(x) that approximates f (x) = ex .

Solution (1/3)
Since this problem involves extensive calculation, we write a Matlab
code to solve this problem

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 63 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (2/3)
9/14/20 3:41 PM /Users/xuzhang/Dropbox/Teachi.../ex3_4_1.m 1 of 1
The MATLAB driver file for this example
% ex 3.4.1
clc
dataX = [0,1,2,3];
dataY = [exp(0),exp(1),exp(2),exp(3)];

%% generate coefficient of natural spline


[a,b,c,d] = natural_spline_coef(dataX,dataY);
disp(' a b c d')
disp('-----------------------------------------')
disp([a,b,c,d])

%% query point x
x = 0:0.01:3;
y = natural_spline(dataX,dataY,x);

%% plot
figure(1)
plot(dataX,dataY,'r*','linewidth',2)
hold on
plot(x,exp(x),'b-','linewidth',2)
plot(x,y,'k-.','linewidth',2)
lgd = legend('data points','y = e^x','y = S(x)');
hold off
grid on
lgd.FontSize = 16;
lgd.Location = 'NorthWest';

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 64 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (3/3)

 3
1.0000 + 1.4660x + 0.2523x ,
 on [0, 1],
2 3
S(x) = 2.7183 + 2.2229(x − 1) + 0.7569(x − 1) + 1.69107(x − 1) , on [1, 2],

7.3891 + 8.8098(x − 2) + 5.8301(x − 2)2 − 1.9434(x − 2)3 , on [2, 3].

20

data points
18
y = ex
16 y = S(x)

14

12

10

0
0 0.5 1 1.5 2 2.5 3

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 65 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Clamped Splines
The clamped spline is another type of cubic splines that use
different boundary conditions.
Comparing with the free boundary condition in the natural spline,

S 00 (a) = 0, S 00 (b) = 0,

the clamped spline specifies the slope at the endpoints, i.e.,

S 0 (a) = f 0 (a), S 0 (b) = f 0 (b).

So, the clamped spline requires additional information:


x0 x1 x2 ··· xn
f (x0 ) f (x1 ) f (x2 ) · · · f (xn )
f 0 (x0 ) f 0 (xn )
The rest of conditions are exactly the same as the natural splines.
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 66 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Example 16.
We revisit Example 14, and this time we construct a clamped spline that
passes through the points (1, 2), (2, 3), and (3, 5) that has S 0 (1) = 2 and
S 0 (3) = 1.

Solution (1/2)
There are two pieces in the spline S(x):

S0 (x) = a0 + b0 (x − 1) + c0 (x − 1)2 + d0 (x − 1)3 , on [1, 2]


2 3
S1 (x) = a1 + b1 (x − 2) + c1 (x − 2) + d1 (x − 2) , on [2, 3].

Most conditions (6 out of 8) are the same as the natural spline,


f (1) = 2 =⇒ a0 = 2, S0 (2) = 3 =⇒ b0 + c0 + d0 = 1.
f (2) = 3 =⇒ a1 = 3, S1 (3) = 5 =⇒ b1 + c1 + d1 = 2.

s00 (2) = s01 (2) =⇒ b0 + 2c0 + 3d0 = b1 .


s000 (2) = s001 (2) =⇒ 2c0 + 6d0 = 2c1 .
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 67 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (2/2)
The clamped boundary conditions yield

s00 (1) = 2 =⇒ b0 = 2,

s01 (3) = 1 =⇒ b1 + 2c1 + 3d1 = 1.

Solve the system for eight unknowns, we have


5 3

2 + 2(x − 1) − (x − 1)2 + (x − 1)3 , on [1, 2],

S(x) = 2 2
3 + 3 (x − 1) + 2(x − 2)2 − 3 (x − 2)3 , on [2, 3].

2 2

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 68 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Construction of a clamped cubic spline


Define the cubic polynomial on each interval to be

Sj (x) = aj +bj (x−xj )+cj (x−xj )2 +dj (x−xj )3 j = 0, 1, · · · , n−1.

The coefficients {aj }, {bj }, and {dj } are define as (3.1) and (3.2).

For j = 1, 2, · · · , n − 1 we have the following equations for cj

3 3
hj−1 cj−1 +2(hj−1 +hj )cj +hj cj+1 = (aj+1 −aj )− (aj −aj−1 ).
hj hj−1

In addition, we have the clamped boundary conditions:


3
2h0 c0 + h0 c1 = (a1 − a0 ) − 3f 0 (a)
h0
3
hn−1 cn−1 + 2hn−1 cn = 3f 0 (b) − (an − an−1 )
hn−1
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 69 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation
3.5 Cubic Spline Interpolation 1
3.5 Cubic Spline Interpolation 155
The clamped
determine spline
the linear Ax = b,
defined
system a = x0 < x1 < · · · < xn = b is
onwhere
unique. {cthe
determine ⎡linear
} satisfies
system the
Ax = linear
b, system Ax = b where
where ⎤
n
⎡ 2h0 h0 0 . .. .. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .⎤. 0.
⎢ .. .. ⎥
⎢2h0 h0 0 . .. .. .. . . . . . .. . . .. .. .. .. . . . . . . . . . . . . . . . . . . 0. . ⎥


.. ⎥ .. ⎥
h 2(h + h ) h . . .... . .... . ⎥

⎢ 0 0 1 1
. . . . ⎥

⎢h0 2(h0 + h1 ) h1 . ... . .. . ⎥ .. ⎥

⎢ 0. . . . .
⎢ h1 . . . . 2(h1 .+. . h2 ) h2 ...... .. . . . . . . . . . . . . ... ⎥ ⎥ .. ⎥
⎢ 0.. . . . .h.1 . .
A =⎢ . . . . 1 .+ h2 ). . . .h2 . . . . . ..... . . ⎥
⎢ .. .. . . . . . . . .. . . . 2(h . . . . . . . .. . . . . ... . . .⎥. ,. ⎥ ,
A =⎢
⎢ .. .
⎢ .... . . . . . . . . . . .. ..... . . . . . . . .. .. .. . . . . . . . ... . ⎥ ⎥ 0 ⎥
⎢ . ..
⎢ .... . . . . . . .
. . . . . . . .. .. .. .. . . . . . . .. .. .. . . . . . . . . . . . . . . . . . . .0. . .⎥ ⎥
⎢ .. .
⎢ . . . ... . . hn−2 . 2(hn−2 +. h. .n−1 ⎥ ⎥
⎢ . ..
⎢ ....
. . . . ) ⎥
h ⎥
⎣ .. .
⎢ . . . . . . h. .n−2 2(h + h ) h ⎥ n−1

⎣ . . . . . . . . . . . . . . . . . . . . . . . . .... .. .. . . .. .. .. n−2 n−1 n−1

0 . 0 h 2h
0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 hn−1 n−1 2hn−1 n−1

⎡  ⎤ ⎤
3 (a1 − a0 ) − 3f
(a − a0 ) − 3f  (a)(a)
3
h0h0 1

⎢ 3 3 (a2 − a1 ) − 3
(a − a ) ⎥ ⎥ ⎡ ⎤⎡ ⎤

⎢ (a
h1h1 2
− a1 ) − h3 (a h 1 −1 a0 ) 0 ⎥ ⎥ c0 c0

⎢ 0 0
⎥ ⎥ ⎢ ⎥⎢ ⎥

⎢ .. .. ⎥ ⎥ ⎢c1 ⎥⎢c1 ⎥
b= ⎢
=⎢ ⎥ , ⎥ and x=⎢ x= . ⎥⎢. .. ⎥ .

⎢ . . ⎥ ⎥ , and ⎣ . ⎦⎣ . ⎦
.
⎢ 33 (a − a ) − 3 3(a − a )⎥ ⎥


⎢hhn−1 (an n − n−1 an−1 ) −hn−2h n−1 (an−1 − n−2 an−2 ⎥ )⎥

⎣ n−1   n−2 ⎦ ⎦ cn cn
3f(b) (b)−−h 3(an(a−n a−n−1 ) )
3
3f an−1
hn−1
n−1

This matrix
This matrix AAisisalso
alsostrictly
strictlydiagonally dominant,
diagonally so itsosatisfies
dominant, the conditions
it satisfies of
the conditions
Theorem 6.21 in Section 6.6. Therefore, the linear system has a unique solution for
Theorem 6.21 in Section 6.6. Therefore, the linear system has a unique solution f
Xu Zhang c0 , c1 , . .State
(Oklahoma . , cnUniversity)
. MATH 4513 Numerical Analysis Fall 2020 70 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Matlab File
9/14/20 5:14 for Clamped Spline Coefficient
PM /Users/xuzhang/Dr.../clamped_spline_coef.m 1 of 1

function [a,b,c,d] = clamped_spline_coef(dataX,dataY,dFa,dFb)


%% Cubic Spline (Clamped Boundary) Interpolation
% On each sub-interval, generate four coefficients aj, bj, cj, and dj
% Sj(x) = aj + bj(x-xj) + cj(x-xj)^2 + dj(x-xj)^3.
%
% Inputs: dataX dataY are row vectors of same dimension.
% Output: a is the collum vector that stores {aj} for j=1,2,...,n+1
% b is the collum vector that stores {bj} for j=1,2,...,n+1
% c is the collum vector that stores {cj} for j=1,2,...,n+1
% d is the collum vector that stores {dj} for j=1,2,...,n+1

%% Initialize h
n = length(dataX) - 1;
h = zeros(1,n);
for j = 1:n
h(j) = dataX(j+1) - dataX(j);
end

%% Prepare for Matrix A


A = zeros(n+1,n+1);
A(1,1) = 2*h(1); A(1,2) = h(1); % Clamped Boundary Condition
A(n+1,n) = h(n); A(n+1,n+1) = 2*h(n); % Clamped Boundary Condition
for j = 2:n
A(j,j-1) = h(j-1);
A(j,j+1) = h(j);
A(j,j) = 2*(h(j-1)+h(j));
end
%% Prepare for vector bb
bb = zeros(n+1,1);
bb(1) = 3/h(j)*(dataY(2)-dataY(1)) - 3*dFa; % Clamped Boundary Condition
bb(n+1) = 3*dFb - 3/h(n)*(dataY(n+1)-dataY(n)); % Clamped Boundary Condition
for j = 2:n
bb(j) = 3/h(j)*(dataY(j+1)-dataY(j)) - 3/h(j-1)*(dataY(j)-dataY(j-1));
end
%% Solve A*c = bb
c = A\bb;
%% Find a,b,d.
a = reshape(dataY(1:n+1),n+1,1);
b = zeros(n,1);
d = zeros(n,1);
for j = 1:n
b(j) = 1/h(j)*(a(j+1)-a(j)) - h(j)/3*(2*c(j)+c(j+1));
d(j) = (c(j+1) - c(j))/(3*h(j));
end
a(n+1) = [];
c(n+1) = [];

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 71 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

9/14/20 5:15 PM /Users/xuzhang/Dropbox.../clamped_spline.m 1 of 1


Matlab File for Clamped Spline Interpolation
function y = clamped_spline(dataX,dataY,dFa,dFb,x)
%% Cubic Spline (Clamped Boundary) Interpolation
% On each sub-interval, generate four coefficients aj, bj, cj, and dj
% Sj(x) = aj + bj(x-xj) + cj(x-xj)^2 + dj(x-xj)^3.
%
% Inputs: dataX dataY are row vectors of same dimension.
% x is the query point(s).
% Output: y is the value of spline interpolation y=S(x) at query points x

%% Generate Spline Coefficient [ai,bi,ci,di] on each interval.


[a,b,c,d] = clamped_spline_coef(dataX,dataY,dFa,dFb);

%% Evaluate the query points


y = zeros(size(x));
for n = 1:length(x)
for j = 1:length(dataX)-1
if dataX(j) <= x(n) && dataX(j+1) >= x(n)
k = j;
break
end
end
xk = dataX(k);
y(n) = a(k) + b(k)*(x(n)-xk) + c(k)*(x(n)-xk)^2 + d(k)*(x(n)-xk)^3;
end

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 72 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Example 17.
We revisit the spline interpolation of f (x) = ex at the following points
x 0 1 2 3
f (x) 1 e e2 e3 .
This time we use the clamped spline with the additional information
f 0 (0) = 1, and f 0 (3) = e3 . Then, compare the accuracy with the natural
spline interpolation.

Solution (1/3)
Since it involved extensive calculation, we solve the problem using
Matlab programing.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 73 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

9/14/20
Solution5:24 PM /Users/xuzhang/Dropbox/Teachi.../ex3_4_2.m
(2/4) 1 of 1

% ex 3.4.2
clc
dataX = [0,1,2,3];
dataY = [exp(0),exp(1),exp(2),exp(3)];

%% generate coefficient of natural spline


[a,b,c,d] = natural_spline_coef(dataX,dataY);
[a2,b2,c2,d2] = clamped_spline_coef(dataX,dataY,exp(0),exp(3));
disp('Natural Spline')
disp(' a b c d')
disp('-----------------------------------------')
disp([a,b,c,d])
disp('Clamped Spline')
disp(' a b c d')
disp('-----------------------------------------')
disp([a2,b2,c2,d2])

%% query point x
x = 0:0.01:3;
y = natural_spline(dataX,dataY,x);
y2 = clamped_spline(dataX,dataY,exp(0),exp(3),x);

%% plot
figure(1)
plot(dataX,dataY,'r*','linewidth',2)
hold on
plot(x,exp(x),'b-','linewidth',2)
plot(x,y,'k-.','linewidth',2)
plot(x,y2,'g-.','linewidth',2)
lgd = legend('data points','y = e^x','Natural','Clamped');
hold off
grid on
lgd.FontSize = 16;
lgd.Location = 'NorthWest';

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 74 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (3/4)
The natural spline is
 3
1.0000 + 1.4660x + 0.2523x ,
 on [0, 1],
2 3
S(x) = 2.7183 + 2.2229(x − 1) + 0.7569(x − 1) + 1.6911(x − 1) , on [1, 2],

7.3891 + 8.8098(x − 2) + 5.8301(x − 2)2 − 1.9434(x − 2)3 , on [2, 3].

The clamped spline is


 2 3
1.0000 + 1.0000x + 0.4447x + 0.2736x ,
 on [0, 1],
2 3
S(x) = 2.7183 + 2.7102(x − 1) + 1.2655(x − 1) + 0.6951(x − 1) , on [1, 2],

7.3891 + 7.3265(x − 2) + 3.3509(x − 2)2 + 2.0191(x − 2)3 , on [2, 3].

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 75 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (4/4)
20

data points
18
y = ex
16 Natural
Clamped
14

12

10

0
0 0.5 1 1.5 2 2.5 3

From the plot, we can see that the clamped spline is more accurate than
the natural spline.
This is not surprise since the boundary conditions for the clamped spline
are exact.
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 76 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Theorem 18 (Error bound for Clamped Cubic Splines).


Let f ∈ C 4 [a, b] with
max |f (4) (x)| = M.
a≤x≤b

If S(x) is the unique clamped cubic spline interpolation to f with respect to


the nodes a = x0 < x1 < · · · < xn = b, then for all x ∈ [a, b],

5M
|f (x) − S(x)| ≤ max (xj+1 − xj )4 .
384 0≤j≤n−1

Remark
A fourth-order error bound also holds in the case of natural spline
interpolation, but it is more difficult to express.
There are other cubic spline interpolations that do not require the
derivative of f . For example, the popular “not-a-knot spline” requires that
the third-order derivative S 000 (x) is continuous at x1 and xn−1 .

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 77 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation
Table 3.18
Illustration Figure 3.11 shows a ruddy duck in flight. To approximate the top profile of the duck, we
have chosen points along
polation and Polynomial Approximation x 0.9the1.3 curve
1.9 2.1through
2.6 3.0 3.9 4.4 4.7
which 5.0 6.0 the
we want 7.0approximating
8.0 9.2 10.5 11.3curve
11.6 12.0 12.6 13.0 13.3
to pass.
Example 19.
Table 3.18 lists thefcoordinates
(x) 1.3 1.5 1.85of2.121
2.6data points
2.7 2.4 relative
2.15 2.05 2.1 2.25to2.3
the superimposed
2.25 coordinate
1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25

In this
gure 3.11 shows aexample,
ruddysystem we To
duck inshown
flight. approximate
in approximate
Figure 3.12. top the
theNotice top
that
profile theprofile
of more points
duck, we areof used
the whenducktheusing
curve iscubic
changing spline
ve chosen points along the curve through
rapidly whichitwe
than when iswant the approximating
changing more slowly.curve to pass.
interpolation.
ble 3.18 lists the coordinates of 21 data points relative
Figure 3.12 to the superimposed coordinate
stem shown in Figure 3.12. Notice that more points are used when the curve
f (x) is changing
Figure
pidly than when3.11
it is changing more slowly.
4
3
2
1

1 2 3 4 5 6 7 8 9 10 11 12 13 x

In general, the more points we use, the better approximation we can expect.
Using Algorithm 3.4 to generate the natural cubic spline for this data produces the coeffi-
We choose 21 data points as cients depicted above
shown in Table and
3.19. This splineshown below
curve is nearly identical toin
thethe
profile,table.
as shown in
Figure 3.13.
9
Note
2.1 Table
that
2.6 3.03.18
more points are placed where the curve is changing more rapidly.
3.9 4.4 4.7 5.0 6.0 7.0 8.0 9.2 10.5 11.3 11.6 12.0 12.6 13.0 13.3
85 2.1 2.6 2.7 2.4 2.15 2.05 2.1 2.25 2.3 2.25 1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25
x 0.9 1.3 1.9 2.1 2.6 3.0 3.9 4.4 4.7 5.0 6.0 7.0 8.0 9.2 10.5 11.3 11.6 12.0 12.6 13.0 13.3
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

f (x) 1.3 1.5 1.85 2.1 2.6 2.7 2.4 2.15 2.05 2.1 2.25 2.3 2.25 1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25

f (x)
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 78 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (1/4)
Since we don’t have derivative information, we use the natural spline
interpolation.
9/14/20 6:15 PM /Users/xuzhang/Dropbox/Teachi.../ex3_5_i.m 1 of 1
We write a Matlab driver file for this example.
% ex 3.5.illustration
clear; clc;

%% Input
dataX = [0.9 1.3,1.9 2.1 2.6 3.0 3.9 4.4 4.7 5.0 6.0 7.0 8.0 ...
9.2 10.5 11.3 11.6 12.0 12.6 13.0 13.3];
dataY = [1.3 1.5 1.85 2.1 2.6 2.7 2.4 2.15 2.05 2.1 2.25 2.3 2.25 ...
1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25];
[a,b,c,d] = natural_spline_coef(dataX,dataY); % coefficent of cubic spline

%% Display Outputs
disp('---------------------------------------------------')
disp(' j a b c d')
disp('---------------------------------------------------')
formatSpec = '%2i % .5f % .5f % .5f % .5f \n';
fprintf(formatSpec,[(0:length(dataX)-2)',a,b,c,d]')

%% Plot Spline
x = 0.9:0.01:13.3; % query points
y = natural_spline(dataX,dataY,x);
figure(1)
clf;
plot(x,y,'r-','linewidth',2)
hold on
plot(dataX,dataY,'b*','linewidth',2)
axis([0,14,-6,4])
grid on
hold off

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 79 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Table 3.18
Solution (2/4)
x 0.9 1.3 1.9 2.1 2.6 3.0 3.9 4.4 4.7 5.0 6.0 7.0 8.0 9.2 10.5 11.3 11.6 12.0 12.6 13.0 13.3

Plotting the natural spline


f (x) 1.3interpolation,
1.5 1.85 2.1 2.6 2.7 2.4 we observe
2.15 2.05 2.1 2.25 2.3 that
2.25 1.95the
1.4 spline curve
0.9 0.7 0.6 0.5 0.4 0.2

is accurately recovers the top profile of the duck.


Figure 3.12
4 f (x)
3
4
2 3

1
2
1
0

1 2 3 4 5 6 7 8 9 10 11 12 13 x
-1

-2

-3

-4

-5
0 2 4 6 8 10 12 14

To use a clamped spline we would need derivative approximations for


Using Algorithm 3.4 to generate the natural cubic spline for this data produces the coeffi
the endpoints. Even if these cients
approximations were
shown in Table 3.19. This available,
spline curve weto the
is nearly identical could
profile, as shown in
Figure 3.13.
expect little improvement because of the close agreement of the natural
cubic spline to the curve of the top profile.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 80 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (3/4)
9/14/20we
For comparison, 6:23
alsoPMuse/Users/xuzhang/Dropbox/Teach.../ex3_5_i2.m
Lagrange Interpolation. 1 of

% Duck Interpolation Comparison


clear; clc;

%% Input
dataX = [0.9 1.3,1.9 2.1 2.6 3.0 3.9 4.4 4.7 5.0 6.0 7.0 8.0 ...
9.2 10.5 11.3 11.6 12.0 12.6 13.0 13.3];
dataY = [1.3 1.5 1.85 2.1 2.6 2.7 2.4 2.15 2.05 2.1 2.25 2.3 2.25 ...
1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25];

%% Find Spline and Lagrange Interpolation


x = 0.9:0.01:13.3; % query points
y = natural_spline(dataX,dataY,x);
yy = LagrangeInterpolation(dataX,dataY,x);

%% Plot Interpolations
figure(1)
clf;
plot(dataX,dataY,'b*','linewidth',2)
hold on
plot(x,y,'r-','linewidth',2)
plot(x,yy,'k-','linewidth',2)
axis([0,14,-2,7])
hold off
grid on
lgd = legend('Data Point','Natural Spline','Lagrange');
lgd.FontSize = 16;
lgd.Location = 'NorthWest';

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 81 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.4 Cubic Spline Interpolation

Solution (4/4)
Plotting the Lagrange interpolation, we observe that the 20th-degree
polynomial 160oscillates
C H A P T E R wildly.
3 It produces
Interpolation aApproximation
and Polynomial very strange illustration of the
back of a duck.
Figure 3.14
f (x)

7
4

6
3
2
5

1
4

3 1 2 3 4 5 6 7 8 9 10 11 12 x
2

-1

-2
0 2 4 6 8 10 12 14

This example shows the superiority of the cubic spline interpolation.


To use a clamped spline to approximate this curve we would need derivative appr
tions for the endpoints. Even if these approximations were available, we could expe
improvement because of the close agreement of the natural cubic spline to the curv
Xu Zhang (Oklahoma State University) MATH 4513
top Numerical Analysis
profile. Fall 2020 82 / 92
Table 3.18 lists the coordinates of 21 data points
Chapter 3. Interpolation and Polynomial Approximation
relative to the superimposed coordinate
3.4 Cubic Spline Interpolation
system shown in Figure 3.12. Notice that more points are used when the curve is changing
rapidly than when it is changing more slowly.
Remark
Figure 3.11

Constructing a cubic spline to approximate the lower profile of the duck


would be more difficult since the curve for this portion cannot be
Table 3.18
expressed as a function of x, and at certain points the curve does not
x 0.9 1.3 1.9 2.1 2.6 3.0 3.9 4.4 4.7 5.0 6.0 7.0 8.0 9.2 10.5 11.3 11.6 12.0 12.6 13.0 13.3
appear to be smooth.
f (x) 1.3 1.5 1.85 2.1 2.6 2.7 2.4 2.15 2.05 2.1 2.25 2.3 2.25 1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25
These problems can be resolved by using separate splines to represent
various portions of the curve, but a more effective approach to
approximating curves of this type is considered in the next section.
Figure 3.12
f (x)

4
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 83 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

3.5 Parametric Curves


The techniques we developed so far in this 3.6chapter cannot
Parametric Curves 165
be used to
generate curves of the form shown below because this curve
on computer graphics will show how this technique can be extended to represent general
cannot be
expressed as a function y in=space.f (See,
curves and surfaces (x). for example, [FVFH].)

Figure 3.15
y
1

1 1 x

1

In this section wepolynomial


will see how
to connect to(x ,represent
the points y ), (x , y ), . . ., (x , y general
A straightforward parametric technique for determining a polynomial or piecewise
0 0
curves
) in the order given
1 1 n nis to use (even some
a parameter t on an interval [t , t ], with t < t < · · · < t , and construct approximation
hand-drawn curves) using
functions with parametric 0 n
forms. 0 1 n

x = x(t ) and y = y(t ), for each i = 0, 1, . . . , n.


This technique can The befollowing
extended to represent general curves/surfaces in
i i i i

example demonstrates the technique in the case where both approximat-


computer graphics.
ing functions are Lagrange interpolating polynomials.

Example 1 Construct a pair of Lagrange polynomials to approximate the curve shown in Figure 3.15,
Xu Zhang (Oklahoma State University) MATH
using the data points 4513
shown on theNumerical
curve. Analysis Fall 2020 84 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

Given a set of data points

x0 x1 x2 ··· xn
y0 y1 y2 ··· yn

we can use a parameter t, and construct polynomial or piecewise


polynomial approximation for

x = x(t), and y = y(t).

To do this, we specify an interval [t0 , tn ], with t0 < t1 < · · · < tn , and


construct two approximation functions with

xi = x(ti ), and yi = y(ti ), i = 0, 1, · · · , n.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 85 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

Example 20. 3.6 Parametric Curves 165

Construct a pair of Lagrange


curves and surfaces in polynomials to approximate the curve show
on computer graphics will show how this technique can be extended to represent general
space. (See, for example, [FVFH].)

below Figure 3.15


y
1

1 1 x

1

Solution (1/3) A straightforward parametric technique for determining a polynomial or piecewise


polynomial to connect the points (x0 , y0 ), (x1 , y1 ), . . ., (xn , yn ) in the order given is to use
a parameter t on an interval [t0 , tn ], with t0 < t1 < · · · < tn , and construct 4 approximation
There are five points, so we choose the points {t }i=0 equally spaced in [0,1]:
functions with i
xi = x(ti ) and yi = y(ti ), for each i = 0, 1, . . . , n.

i 0 1 2 3 4
The following example demonstrates the technique in the case where both approximat-
ing functions are Lagrange interpolating polynomials.

Example 1
t 0 0.25 0.5 0.75 1
Construct aipair of Lagrange polynomials to approximate the curve shown in Figure 3.15,
using the data points shown on the curve.
x i 1 0 1 0 −1
Solution There is flexibility in choosing the parameter, and we will choose the points
yi spaced−1
{t } equally
4
i i=0 0 the0.5
in [0,1], which gives data in Table 3.20.1 0
Table 3.20
i 0 1 2
Xu Zhang (Oklahoma State University) MATH 45133 Numerical
4
Analysis Fall 2020 86 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

Solution (2/3)
We write a MATLAB Driver file3:06
9/15/20 for this
PM example
/Users/xuzhang/Dropbox/Teachi.../ex3_6_1.m

% ex3_6_1
dataT = [0,0.25,0.5,0.75,1];
dataX = [-1,0,1,0,1];
dataY = [0,1,0.5,0,-1];

qt = 0:0.001:1;
qx = LagrangeInterpolation(dataT,dataX,qt);
qy = LagrangeInterpolation(dataT,dataY,qt);

figure(1); clf
plot(dataX,dataY,'r*','linewidth',2)
hold
plot(qx,qy,'b-.','linewidth',2)
grid on
lgd = legend('Data Point','Lagrange');
lgd.FontSize = 16;
lgd.Location = 'NorthEast';

The Interpolation polynomials are


352 3 14
x(t) = 64t4 − t + 60t2 − t − 1,
3 3
64 4 3 116 2
y(t) = − t + 48t − t + 11t.
3 3
Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 87 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

3.6 Parametric Curves 165


Solution (3/3)
omputer graphics will show how this technique can be extended to represent general
Plotting the parametric system produced the graph
es and surfaces in space. (See, for example, [FVFH].)
below:
1.5

y Data Point
Lagrange
1
1

0.5

1 1 x 0

-0.5

1
-1
-1.5 -1 -0.5 0 0.5 1 1.5

A straightforward parametric technique for determining a polynomial or piecewise


nomial to connect the points (x0 , y0 ), (x1 , y1 ), . . ., (xn , yn ) in the order given is to use
ameter t on an interval [t0 , tn ], with t0 < t1 < · · · < tn , and construct approximation
ionsXu
with
Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 88 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

Remark
For this example, we can also use the natural cubic Spline interpolation for
the parametric
9/15/20 3:18 PM system.
/Users/xuzhang/Dropbox/Teac.../ex3_6_1_2.m 1 of 1

% ex3_6_1_2 1.5
dataT = [0,0.25,0.5,0.75,1]; Data Point
dataX = [-1,0,1,0,1];
Lagrange
dataY = [0,1,0.5,0,-1];
1
Natural Spline
qt = 0:0.001:1;

qx = LagrangeInterpolation(dataT,dataX,qt);
qy = LagrangeInterpolation(dataT,dataY,qt); 0.5

qxS = natural_spline(dataT,dataX,qt);
qyS = natural_spline(dataT,dataY,qt);
0
figure(1); clf
plot(dataX,dataY,'r*','linewidth',2)
hold
plot(qx,qy,'b-.','linewidth',2) -0.5
plot(qxS,qyS,'k-.','linewidth',2)
grid on
lgd = legend('Data Point','Lagrange','Natural Spline');
lgd.FontSize = 16; -1
lgd.Location = 'NorthEast'; -1.5 -1 -0.5 0 0.5 1 1.5

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 89 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

Example 21.
In this example, we demonstrate using natural cubic spline to interpolate
arbitrary hand-drawn curve. We need to use the graphic input MATLAB
command
[X,Y]=ginput(N)
to get N points from the click of the mouse.
(for more details, type help ginput in MATLAB command window)

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 90 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

9/15/20
A MATLAB Driver File 3:45 PM /Users/xuzhang/Dropbox/Teachi.../ex3_6_2.m
for Parametric Curve 1

% ex3_6_2
clc
clear
close all

%% Input Points on a region [0,1] X [0,1]


figure(1)
grid on
axis([0,1,0,1])
N = 20;
dataX = zeros(N,1); dataY = zeros(N,1);
dataT = (0:1/(N-1):1)';

for n = 1:N
[X,Y] = ginput(1);
plot(X,Y,'r*');
text(X,Y,int2str(n));
grid on
axis([0,1,0,1])
hold on
dataX(n) = X; dataY(n) = Y;
end
disp(' ')
disp(' I dataT dataX dataY')
disp('---------------------------------------')
disp([(1:N)',dataT,dataX,dataY])

%% Query Points
qt = 0:0.001:1; % use 1000 query points
qx = natural_spline(dataT,dataX,qt);
qy = natural_spline(dataT,dataY,qt);

figure(2);clf
plot(dataX,dataY,'r*',qx,qy,'k-','linewidth',2)
grid on
axis([0,1,0,1])

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 91 / 92
Chapter 3. Interpolation and Polynomial Approximation 3.5 Parametric Curves

Remarks
Applications in computer graphics require the rapid generation of
smooth curves that can be easily and quickly modified. For both
aesthetic and computational reasons, changing one portion of
these curves should have little or no effect on other portions of the
curves.
This eliminates the use of interpolating polynomials and splines
since changing one portion of these curves affects the whole
curve.
The choice of curve for use in computer graphics is generally a
form of the piecewise cubic Hermite polynomial. Popular graphics
programs using Hermite cubics are described as Bézier
polynomials, which uses the “guidepoint” to compute the
derivatives at the endpoints in each interval.

Xu Zhang (Oklahoma State University) MATH 4513 Numerical Analysis Fall 2020 92 / 92

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy