Docsity

Lecture Notes on Interpolation - Numerical Analysis | MATH 475A, Study notes of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Chapter 3. Interpolation
•question: to construct a polynomial through given data points
3.1 Lagrange Interpolation
•given n+ 1 data points
(x1, y1),(x2, y2), . . ., (xn+1, yn+1),
where xi6=xjfor any i6=j, to find a polynomial p(x) of degree at
most nsuch that p(xi) = yifor all i
•formula: Lagrange polynomial
p(x) =
n+1
X
k=1
ykLk(x),
where
Lk(x) =
n+1
Y
i=1, i6=k
x−xi
xk−xi
;
for example, case when n= 1
•example: find Lagrange polynomial p(x), given that
xi2 2.5 4
yi0.5 0.4 0.25
•polyfit and polyval; for example, yi=f(xi), where x1=−2, x2=
−1, x3= 0, x4= 1, x5= 2 and where f(x) = 1
x+ (1 −x)2
•Lagrange polynomial p(x) interpolating f(x) at x1, x2,...,xn+1, with
xi6=xjfor any i6=j, then for any fixed x,
f(x)−p(x) = f(n+1) (ξ(x))
(n+ 1)!
n+1
Y
k=1
(x−xk)
1
pf3
pf4
pf5

Partial preview of the text

Download Lecture Notes on Interpolation - Numerical Analysis | MATH 475A and more Study notes Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Chapter 3. Interpolation

  • question: to construct a polynomial through given data points

3.1 Lagrange Interpolation

  • given n + 1 data points

(x 1 , y 1 ), (x 2 , y 2 ),... , (xn+1, yn+1),

where xi 6 = xj for any i 6 = j, to find a polynomial p(x) of degree at most n such that p(xi) = yi for all i

  • formula: Lagrange polynomial

p(x) =

n∑+

k=

ykLk(x),

where Lk(x) =

n∏+

i=1, i 6 =k

x − xi xk − xi

for example, case when n = 1

  • example: find Lagrange polynomial p(x), given that

xi 2 2.5 4 yi 0.5 0.4 0.

  • polyfit and polyval; for example, yi = f (xi), where x 1 = − 2 , x 2 = − 1 , x 3 = 0, x 4 = 1, x 5 = 2 and where f (x) =

x + (1 − x)^2

  • Lagrange polynomial p(x) interpolating f (x) at x 1 , x 2 ,... , xn+1, with xi 6 = xj for any i 6 = j, then for any fixed x,

f (x) − p(x) =

f (n+1)(ξ(x)) (n + 1)!

n∏+

k=

(x − xk)

0

1

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

3.2 Divided Differences

  • definition: y[xi] = yi, i = 1, 2 ,... , n + 1;

y[xi, xi+1] =

y[xi+1] − y[xi] xi+1 − xi

, i = 1, 2 ,... , n;

y[xi, xi+1, xi+2] =

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

, i = 1, 2 ,... , n − 1;

and so on

  • formula: Lagrange polynomial

p(x) = y[x 1 ] + y[x 1 , x 2 ](x − x 1 ) + y[x 1 , x 2 , x 3 ](x − x 1 )(x − x 2 ) +...

+y[x 1 , x 2 ,... , xn+1](x − x 1 )(x − x 2 ) · · · (x − xn)

  • computation:

x 1 y[x 1 ] x 2 y[x 2 ] y[x 1 , x 2 ] x 3 y[x 3 ] y[x 2 , x 3 ] y[x 1 , x 2 , x 3 ] x 4 y[x 4 ] y[x 3 , x 4 ] y[x 2 , x 3 , x 4 ]... ;

for example, x 1 = − 2 , x 2 = − 1 , x 3 = 0, x 4 = 1, x 5 = 2, with

y 1 = 0. 142857 , y 2 = 0. 333333 , y 3 = 1, y 4 = 1, y 5 = 0. 333333

  • cubic spline: assuming a = x 1 < x 2 <... < xn+1 = b, to construct piecewise cubic polynomial

si(x) = ai + bi(x − xi) + ci(x − xi)^2 + di(x − xi)^3 , xi ≤ x ≤ xi+

such that si(xi) = yi and si(xi+1) = yi+1, where i = 1, 2 ,... , n; addi- tionally,

(1) s′ i(xi+1) = s′ i+1(xi+1), i = 1, 2 ,... , n − 1 (2) s′′ i (xi+1) = s′′ i+1(xi+1), i = 1, 2 ,... , n − 1 (3) two more conditions, such as

s′′′ 1 (x 2 ) = s′′′ 2 (x 2 ) and s′′′ n− 1 (xn) = s′′′ n (xn)

  • interp1; for example,

xi − 55 − 45 − 35 − 25 − 15 − 5 yi − 3. 25 − 3. 37 − 3. 35 − 3. 2 − 3. 12 − 3. 02 xi 5 15 25 35 45 55 65 yi − 3. 02 − 3. 07 − 3. 17 − 3. 32 − 3. 3 − 3. 22 − 3. 1

3.5 Application

  • grayscale image; imread and imshow
  • interp
  • examples:

50 100 150 200 250 300 -

0

50

100

40 60 80 100 120 140 160 180 200 220

50 100 150 200 250 300 -

0

50

100

40 60 80 100 120 140 160 180 200 220