+ All Categories
Home > Documents > Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than...

Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than...

Date post: 09-Apr-2018
Category:
Upload: nguyenhanh
View: 264 times
Download: 3 times
Share this document with a friend
44
Interpolation CS5240 Theoretical Foundations in Multimedia Leow Wee Kheng Department of Computer Science School of Computing National University of Singapore Leow Wee Kheng (NUS) Interpolation 1 / 44
Transcript
Page 1: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Interpolation

CS5240 Theoretical Foundations in Multimedia

Leow Wee Kheng

Department of Computer Science

School of Computing

National University of Singapore

Leow Wee Kheng (NUS) Interpolation 1 / 44

Page 2: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Last Time...

Last Time...

Fit the regional economic data.

0 10000 20000 30000 40000 50000 60000

GDP per capita

0

10000

20000

30000

40000

50000

60000

GN

I per

capit

a

GNI per capita

line t

quad t

cubic t

Leow Wee Kheng (NUS) Interpolation 2 / 44

Page 3: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Last Time...

Fit 2-D quadratic surface to 3-D data points.

3D points fitted surfaces

Leow Wee Kheng (NUS) Interpolation 3 / 44

Page 4: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Last Time...

What if you want to model the curve/surface of this aircraft exactly?

Nonlinear least squares approximate data points.Need interpolating curve/surface that fits exactly!

p4

p3

p0

p2p1

x

y

p4

p3

p2

p0

p1

x

y

approximating curve interpolating curve

Leow Wee Kheng (NUS) Interpolation 4 / 44

Page 5: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Last Time...

Approximation Problem

Given data points pi, i = 1, . . . , n, and their corresponding

data points qi, find a function f that minimizes the error

E =n∑

i=1

‖f(pi)− qi‖2. (1)

Interpolation Problem

Given data points pi, i = 1, . . . , n, and their corresponding

data points qi, find a function f such that f(pi) = qi for all i.

That means, error E = 0 over the data points pi.

Leow Wee Kheng (NUS) Interpolation 5 / 44

Page 6: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Linear Interpolation

Linear Interpolation

Given control points (x1, y1) and (x2, y2), find a line that passes them.

x2x1

y2

y1

y

xx

y

y − y1x− x1

=y2 − y1x2 − x1

. (2)

So,

y = y1 +y2 − y1x2 − x1

(x− x1). (3)

Leow Wee Kheng (NUS) Interpolation 6 / 44

Page 7: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Linear Interpolation

Alternatively,

x2x1

y2

y1

d1 d2

y

xx

y

y − y1x− x1

=y2 − y

x2 − x. (4)

That is,y − y1d1

=y2 − y

d2. (5)

So,

y =d1y2 + d2y1d1 + d2

. (6)

Leow Wee Kheng (NUS) Interpolation 7 / 44

Page 8: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Linear Interpolation

Linear interpolation can be extended to 2D data:Interpolate the height h(x, y) given heights at 4 neighbouring points.

y1

y2

x2x1

x y( , )

x

y

?

Interpolate along two directions: x and y.This is called bilinear interpolation (Assignment).

Similarly, 3D version is trilinear interpolation:interpolate along three directions x, y, z.

Leow Wee Kheng (NUS) Interpolation 8 / 44

Page 9: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Polynomial Interpolation

Polynomial Interpolation

Consider n+ 1 points pi = (xi, yi), i = 0, 1, . . . , n that lie on a curve.

p4

p3

p2

p0

p1

x

y

How to produce an interpolating curve that passes through the points?

Leow Wee Kheng (NUS) Interpolation 9 / 44

Page 10: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Polynomial Interpolation

Consider a polynomial of degree (order) d:

yi = a0 + a1xi + a2x2i + · · ·+ adx

di , for i = 0, 1, . . . , n. (7)

In matrix form,

1 x0 x20 · · · xd01 x1 x21 · · · xd1...

......

. . ....

1 xn x2n · · · xdn

a0a1...ad

=

y0y1...yn

(8)

◮ If d > n, no unique solution.

◮ If d = n, matrix has inverse: interpolating solution.

◮ If d < n, matrix has pseudo-inverse: approximating solution.

Leow Wee Kheng (NUS) Interpolation 10 / 44

Page 11: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Polynomial Interpolation

Interpolation vs. Approximation

0 0.5 1 1.5 2 2.5 3 3.5

x0.3

0.4

0.5

0.6

0.7

0.8

0.9

1y

control points (n = 6)degree n interpolationdegree n-1 approximationdegree n-3 approximation

Leow Wee Kheng (NUS) Interpolation 11 / 44

Page 12: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Polynomial Interpolation

Polynomial Interpolation

◮ Strength: Easy to implement.

◮ Weakness: Data matrix is often ill-conditioned when n is large.(Refer to optimization-2.pdf for condition number of matrix.)

Leow Wee Kheng (NUS) Interpolation 12 / 44

Page 13: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Lagrange Interpolation

Lagrange Interpolation

Suppose we have n+ 1 control points pi = (xi, yi), i = 0, 1, . . . , n.

An intuitive way to interpolate is to define a function

f(x) = y0L0(x) + y1L1(x) + · · ·+ ynLn(x) =

n∑

i=0

yiLi(x), (9)

such that

Li(xj) = δij =

{

1 if j = i,0 if j 6= i.

(10)

Then, obviouslyf(xi) = yiLi(xi) = yi. (11)

Leow Wee Kheng (NUS) Interpolation 13 / 44

Page 14: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Lagrange Interpolation

An easy way to define Li(x) is

Li(x) =(x− x0)(x− x1) · · · (x− xi−1)(x− xi+1) · · · (x− xn)

(xi − x0)(xi − x1) · · · (xi − xi−1)(xi − xi+1) · · · (xi − xn),

=n∏

j=0, j 6=i

x− xjxi − xj

. (12)

This Li(x) is called Lagrange interpolation polynomial.

Eq. 9 is already the interpolation formula for any x.No need to solve any other equation!

Leow Wee Kheng (NUS) Interpolation 14 / 44

Page 15: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Lagrange Interpolation

Example Lagrange interpolation polynomials

1 1.2 1.4 1.6 1.8 2x−0.5

0

0.5

1

Li

L0

L1

1 1.2 1.4 1.6 1.8 2x−0.5

0

0.5

1

Li

L0

L1

L2

degree-1: linear degree-2: quadratic

Leow Wee Kheng (NUS) Interpolation 15 / 44

Page 16: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Lagrange Interpolation

Lagrange Interpolation

0 0.5 1 1.5 2 2.5 3 3.5

x0.3

0.4

0.5

0.6

0.7

0.8

0.9

1y

control points (n = 6)degree-n polynomial interpolation

Leow Wee Kheng (NUS) Interpolation 16 / 44

Page 17: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Lagrange Interpolation

Lagrange Interpolation

◮ Strength: Easy to implement, no need optimization.

◮ Weakness: Does not take into account gradient at control points.

Leow Wee Kheng (NUS) Interpolation 17 / 44

Page 18: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Hermite Interpolation

Hermite Interpolation

Hermite interpolation is extension of Lagrange interpolation.

Given n+ 1 control points pi = (xi, yi), i = 0, 1, . . . , n, andthe gradients y′i = dy/dx at x = xi.

Define the interpolation function as

f(x) =n∑

i=0

(

yiHi(x) + y′iHi(x))

(13)

with appropriate Hi(x) and Hi(x):

Hi(xj) = δij , H ′i(xj) = 0,

Hi(xj) = 0, H ′i(xj) = δij.

(14)

Then,

f(xi) = yiHi(xi) = yi,df

dx

x=xi

= y′iHi(xi) = y′i. (15)

Leow Wee Kheng (NUS) Interpolation 18 / 44

Page 19: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Hermite Interpolation

These Hi and Hi are called Hermite interpolation polynomials, andthey have these forms:

Hi(x) = (1− 2(x− xi)L′i(xi))L

2i (x)

Hi(x) = (x− xi)L2i (x).

(16)

Hermite Interpolation

◮ Strength: Takes into account gradient. Still no need optimization.

◮ Weakness: More complex than Lagrange interpolation.

Leow Wee Kheng (NUS) Interpolation 19 / 44

Page 20: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Global Interpolation Hermite Interpolation

Global Interpolation◮ Strength: Simple, single interpolating curve.◮ Weakness: Can have undesirable oscillations.

0 5 10 15 20 25 30

x−4

−2

0

2

4

6y

◮ Lagrange-1: control points at x = 0, 1, 8, 27.◮ Lagrange-2: control points at x = 0, 8, 16, 27.◮ Lagrange-3: control points at x = 0, 1, 8, 16, 27.

Leow Wee Kheng (NUS) Interpolation 20 / 44

Page 21: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation

Piecewise Interpolation

Interpolate using a combination of low-degree polynomials.

Piecewise Polynomial Interpolation

0 0.5 1 1.5 2 2.5 3 3.5

x0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

y

control points (n = 6)

p�������� ����� �� �����

p�������� �� �� �� �� ���

Leow Wee Kheng (NUS) Interpolation 21 / 44

Page 22: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Lagrange Interpolation

Piecewise Lagrange Interpolation

Write Lagrange interpolation polynomials as functions of parameteru = [0, 1].

Example: Interpolate between 2 control points pi and pi+1:

x = x(u), x(0) = xi, x(1) = xi+1

y = y(u), y(0) = yi, y(1) = yi+1

(17)

xi i +1x

pi +1

pi

= 1u

yi

i +1y

= 0u

y

x

Leow Wee Kheng (NUS) Interpolation 22 / 44

Page 23: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Lagrange Interpolation

Lagrange Linear Polynomials

For interpolation with 2 control points, u = 0 at pi, u = 1 at pi+1.

0 0.2 0.4 0.6 0.8 1u0

0.2

0.4

0.6

0.8

1

Li

L0

L1

L0(u) =u− u1u0 − u1

=u− 1

0− 1= 1− u,

L1(u) =u− u0u1 − u0

=u− 0

1− 0= u.

(18)

Leow Wee Kheng (NUS) Interpolation 23 / 44

Page 24: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Lagrange Interpolation

p4

p3

p2

p0

p1

pi

pi +1

xi i +1x

= 0u

= 1u

x

y

Then, the linear interpolation between pi and pi+1 is

x = xiL0(u) + xi+1L1(u) = (1− u)xi + uxi+1,

y = yiL0(u) + yi+1L1(u) = (1− u)yi + uyi+1,(19)

which is standard linear interpolation.

Eq. 19 is applied to each segment between pi and pi+1 fori = 0, 1, . . . , n− 1.

Leow Wee Kheng (NUS) Interpolation 24 / 44

Page 25: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Lagrange Interpolation

Lagrange Quadratic Polynomials

For interpolation with 3 control points that are equally spaced in termsof xi, u = 0, 0.5, 1 at pi−1, pi, pi+1. Then, (Exercise)

L0(u) =(u− 0.5)(u− 1)

(0− 0.5)(0− 1)= 2u2 − 3u+ 1,

L1(u) =(u− 0)(u− 1)

(0.5− 0)(0.5− 1)= −4u2 + 4u,

L2(u) =(u− 0)(u− 0.5)

(1− 0)(1− 0.5)= 2u2 − u.

(20)

Leow Wee Kheng (NUS) Interpolation 25 / 44

Page 26: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Lagrange Interpolation

0 0.2 0.4 0.6 0.8 1u−0.2

0

0.2

0.4

0.6

0.8

1

Li

L0

L1

L2

Lagrange quadratic interpolation between pi, pi+1, and pi+2 is

x = xiL0(u) + xi+1L1(u) + xi+2L2(u),

y = yiL0(u) + yi+1L1(u) + yi+2L2(u),(21)

Eq. 21 is applied to each segment between pi, pi+1, pi+2, fori = 0, 2, 4, ..., n.

Leow Wee Kheng (NUS) Interpolation 26 / 44

Page 27: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Lagrange Interpolation

Global vs. Piecewise Interpolation

0 5 10 15 20 25 30x−4

−3

−2

−1

0

1

2

3

4y

◮ Lagrange-1: Global, control points at x = 0, 1, 8, 27.

◮ Lagrange-2: Global, control points at x = 0, 8, 16, 27.

◮ piecewise Lagrange: quadratic, 2 segments,control points at x = 0, 4, 8 and x = 8, 17.5, 27.

Leow Wee Kheng (NUS) Interpolation 27 / 44

Page 28: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Hermite Interpolation

Piecewise Hermite Interpolation

Hermite Cubic Polynomials

For interpolation with 2 control points, u = 0 at pi, u = 1 at pi+1.

From Eq. 18,L0(u) = 1− u, L1(u) = u.

So,L′0(u) = −1, L′

1(u) = 1.

Therefore, (Exercise)

H0(u) = (1− 2L′0(0)(u− 0))L2

o(u) = 2u3 − 3u2 + 1

H1(u) = (1− 2L′1(1)(u− 1))L2

1(u) = −2u3 + 3u2

H0(u) = (u− 0)L20(u) = u3 − 2u2 + u

H1(u) = (u− 1)L21(u) = u3 − u2.

(22)

Leow Wee Kheng (NUS) Interpolation 28 / 44

Page 29: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Piecewise Hermite Interpolation

0 0.2 0.4 0.6 0.8 1u−0.2

0

0.2

0.4

0.6

0.8

1

Hermite cubic interpolation between pi and pi+1 is

y = yiH0(u) + yi+1H1(u) +dy

dx

dx

du

u=0

H0(u) +dy

dx

dx

du

u=1

H1(u)

= yiH0(u) + yi+1H1(u) + (xi+1 − xi)y′iH0(u)

+(xi+2 − xi+1)y′i+1H1(u). (23)

Leow Wee Kheng (NUS) Interpolation 29 / 44

Page 30: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Splines

Splines

draftsman’s spline curve ruler

Leow Wee Kheng (NUS) Interpolation 30 / 44

Page 31: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

Cubic Spline

The point p(u) on a cubic spline between control points pi and pi+1 is:

p(u) = a0 + a1u+ a2u2 + a3u

3, for 0 ≤ u ≤ 1 (24)

where a0, . . . ,a3 are to be determined such that p(0) = pi,p(1) = pi+1.

Derivation of cubic spline for x and y are the same.

Suppose thatx = φ(u) = a0 + a1u+ a2u

2 + a3u3 (25)

and its 2nd derivative at pi is given by Di.

Since φ(u) is cubic, φ′′(u) is linear:

φ′′(u) = (1− u)Di + uDi+1 = Di + (Di+1 −Di)u. (26)

Leow Wee Kheng (NUS) Interpolation 31 / 44

Page 32: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

Integrating φ′′(u) twice gives

φ(u) = A+Bu+1

2Diu

2 +1

6(Di+1 −Di)u

3 (27)

for some constants A and B.

For u = 0, xi = φ(0) = A.For u = 1, xi+1 = φ(1) = A+B + 1

3Di +

16Di+1.

That is, B = xi+1 − xi −13Di −

16Di+1.

So, Eq. 27 becomes

φ(u) = xi +

(

xi+1 − xi −1

3Di −

1

6Di+1

)

u+1

2Diu

2 +1

6(Di+1 −Di)u

3.

(28)This is the interpolation function for x between pi and pi+1: x = φ(u).

Leow Wee Kheng (NUS) Interpolation 32 / 44

Page 33: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

Now, consider the two splines that meet at pi.

pi

pi −1

pi +1

= 0u

= 1u= 1u = 0u

The blue spline and its gradient are:

φ(u) = xi−1+

(

xi − xi−1 −1

3Di−1 −

1

6Di

)

u+1

2Di−1u

2+1

6(Di−Di−1)u

3

φ′(u) = xi − xi−1 −1

3Di−1 −

1

6Di +Di−1u+

1

2(Di −Di−1)u

2. (29)

The red spline is given by Eq. 28 and its gradient is:

φ′(u) = xi+1 − xi −1

3Di −

1

6Di+1 +Diu+

1

2(Di+1 −Di)u

2. (30)

Leow Wee Kheng (NUS) Interpolation 33 / 44

Page 34: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

At control point pi, u = 1 for Eq. 29 and u = 0 for Eq. 30:

φ′(1) = xi − xi−1 +1

6Di−1 +

1

3Di, (31)

φ′(0) = xi+1 − xi −1

3Di −

1

6Di+1. (32)

For continuity of gradient, equate Eq. 31 and 32, giving:

Di−1 + 4Di +Di+1 = 6(xi−1 − 2xi + xi+1), for i = 1, . . . , n− 1. (33)

So, have n− 1 equations, but have n+ 1 unknowns D0, D1, . . . , Dn.Need two more conditions, for example:

(a) natural spline: D0 = 0 or Dn = 0;

(b) specified gradient: φ′(u) = g0 at p0 or φ′(u) = gn at pn;

(c) quadratic end spans: D0 = D1 or Dn−1 = Dn.

Leow Wee Kheng (NUS) Interpolation 34 / 44

Page 35: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

Overall equation, in matrix form, is

a00 a01 0 0 · · · 0 0 01 4 1 0 · · · 0 0 00 1 4 1 · · · 0 0 0...

......

.... . .

0 0 0 0 · · · 1 4 10 0 0 0 · · · 0 an,n−1 ann

D0

D1

D2

...Dn−1

Dn

= 6

b0x0 − 2x1 + x2x1 − 2x2 + x3

...xn−2 − 2xn−1 + xn

bn

(34)

Leow Wee Kheng (NUS) Interpolation 35 / 44

Page 36: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

where (Exercise)

(a) a00 = 1 and a01 = b0 = 0 or ann = 1 and an,n−1 = bn = 0;

(b) a00 = 2, a01 = 1, and b0 = x1 − x0 − g0 oran,n−1 = 1, ann = 2, and bn = gn − xn + xn−1;

(c) a00 = 1, a01 = −1, and b0 = 0 oran,n−1 = −1, ann = 1, and bn = 0.

After solving D0, . . . , Dn, interpolation of x is computed using Eq. 28.Interpolation of y is computed in the same way as x using y0, . . . , yn.

Leow Wee Kheng (NUS) Interpolation 36 / 44

Page 37: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

Example:

0 5 10 15 20 25 30x0

1

2

3

y

piecewise Lagrangecubic spline 1cubic spline 3

◮ cubic spline 1: case 1, natural splines

◮ cubic spline 3: case 3, quadratic end spans

Leow Wee Kheng (NUS) Interpolation 37 / 44

Page 38: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

Cubic Spline Interpolation:

◮ Strength: 1st derivative is continuous.

◮ Weakness: oscillation can occur at points where 2nd derivative isnot continuous.

◮ Local modification of curve requires re-computing whole curve.

Other Splines

cubic B-spline, Bezier curve, NURBS (non-uniform rational B-splines).

Leow Wee Kheng (NUS) Interpolation 38 / 44

Page 39: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Piecewise Interpolation Cubic Spline

Comparisons

◮ Piecewise Lagrange interpolation:1st and 2nd derivatives are discontinuous at control points.

◮ Piecewise Hermite interpolation:1st derivative is continuous but must be known at control points.2nd derivative is discontinuous at control points.

◮ Cubic spline interpolation:1st and 2nd derivatives are continuous at control points.

Leow Wee Kheng (NUS) Interpolation 39 / 44

Page 40: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Surface Interpolation

Surface Interpolation

v

u

Surface can be represented using two spline curves on a grid.A point on the surface is parameterized by two parameters

x(u, v), y(u, v), z(u, v).

Analogous to bilinear interpolation.

But, this method cannot be applied to general non-rectangular meshes.Leow Wee Kheng (NUS) Interpolation 40 / 44

Page 41: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Summary

Summary

method property

polynomial unstable for large nLagrange stable for large nHermite stable for large nglobal have oscillations

piecewise reduce oscillationspiecewise linear discontinuous

piecewise polynomial discontinuouspiecewise Lagrange discontinuous 1st derivativespiecewise Hermite discontinuous 2nd derivatives

cubic spline continuous 1st & 2nd derivatives

Leow Wee Kheng (NUS) Interpolation 41 / 44

Page 42: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Probing Questions

Probing Questions

◮ We have studied interpolation of planar curves, i.e., curves in 2D.Which of the methods studied can be easily applied to spacecurves, i.e., curves in 3D?

◮ Is it possible to adapt curve interpolation methods to curveapproximation? If yes, how? If no, why?

◮ We have studied the interpolation of values. Is it possible tointerpolate functions such as transformation functions? If yes,how? If no, why?

Leow Wee Kheng (NUS) Interpolation 42 / 44

Page 43: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

Homework

Homework

1. Describe the essence of global interpolation and piecewise (local)interpolation, each in one sentence.

2. Describe the essence of polynomial interpolation, Lagrangeinterpolation, Hermite interpolation and cubic B-splineinterpolation, each in one sentence.

3. Derive the Lagrange quadratic polynomials given in Eq. 20.

4. Derive the Hermite cubic polynomials given in Eq. 22.

5. For cubic spline interpolation, derive the values of the matrixelements a00, a01, an,n−1, ann, b0, and bn for the three cases asillustrated in page 36.

Leow Wee Kheng (NUS) Interpolation 43 / 44

Page 44: Interpolation - NUS Computingcs5240/lecture/interpolation.pdf · Weakness: More complex than Lagrange interpolation. Leow Wee Kheng (NUS) Interpolation 19 / 44. Global Interpolation

References

References

1. A. Davis and P. Samuels, An Introduction to Computational Geometry

for Curves and Surfaces, Clarendon Press, 1996.

2. B. I. Kvasov Methods of Shape-Preserving Spline Approximation, WorldScientific, 2000.

Leow Wee Kheng (NUS) Interpolation 44 / 44


Recommended