today’s class spline interpolation quadratic spline cubic spline fourier approximation numerical...

33
Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Upload: darlene-moody

Post on 02-Jan-2016

245 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Today’s class

• Spline Interpolation• Quadratic Spline• Cubic Spline

• Fourier Approximation

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

1

Page 2: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Lagrange & Newton Interpolation

• Noticing that the function (black line) has a sharp or sudden change at x = 0.

• Polynomial interpolations work poorly.

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

2

Page 3: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Spline Interpolation

• Spline interpolation applies low-order polynomial to connect two neighboring points and uses it to interpolate between them.

• Typical Spline functions

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

3

Page 4: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Linear Splines

• Use straight lines to connect two neighboring points

Shortcomings: Sharp angle at

connections, or not smooth.

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

4

Page 5: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Linear Splines• Use either Lagrange or Newton interpolations to

determine the equations for the straight lines

• To find y5 at x5, first find which interval x5 is in and then use the linear Spline in that region to calculate y5.

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

5

Page 6: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Quadratic Spline Function• Each two neighboring points are connected

by a 2nd-order (quadratic) polynomial.

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

6

Page 7: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Quadratic Splines

• If number of points is n+1, there are two end points and n-1 interior points. The number of intervals is n.• Since each interval has one quadratic polynomial, there are 3n unknown coefficients (ai, bi & ci ) to be determined.

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

7

Page 8: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Conditions Used to Determine Coefficients• At each interior point, the two neighboring

quadratic polynomials have to pass this point, resulting in 2(n-1) equations

• The first and last quadratics must pass through the end points resulting in 2 more equations.

• At each interior point, the first-order derivatives of the two neighboring polynomials are equal, resulting in (n-1) equations.

• The last equation is obtained by letting the second-order derivative of the first polynomial equal zero (totally arbitrary and may be changed).

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

8

Page 9: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Equations Used to Determine Coefficients

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

9

Page 10: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Quadratic Splines

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

10

Page 11: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Function• Each two neighboring points are connected or

interpolated by a 3rd-order (Cubic) polynomial.

• If # of points is n+1, then there are two end points and n-1 interior points. # of intervals is n.

• Each interval has a cubic polynomial. There are totally 4n unknown coefficients (ai, bi, ci & di) .

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

11

Page 12: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Conditions Used to Determine Coefficients• At each interior point, the two neighboring cubic

polynomials have to pass this point, resulting in 2(n-1) equations

• Only one cubic polynomial to pass an end point, resulting in 2 equations

• At each interior point, the first-order & second-order derivatives of the two neighboring polynomials are equal, resulting in 2(n-1) equations.

• There are totally 4n-2 equations, two more additional equations are needed by letting the second-order derivatives of the first and last polynomials equal zero.

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

12

Page 13: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Equations Used to Determine Coefficients

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

13

• Second

Page 14: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Functions• Second derivative is a line • Lagrange interpolating polynomial for

second derivative

• Integrate twice to get fi(x)

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

14

Page 15: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Functions

• Two constants can be evaluated by applying interval end conditions

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

15

Page 16: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Functions

• First derivatives at knots must be equal

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

16

at xi

Page 17: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Functions• Rearranging terms we get the following

relationship

• For all n-1 interior knots, this gives us n-1 equation with n-1 unknowns – the second derivatives

• Once we solve for the second derivatives, we can plug it into the previous equations to solve for the splines

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

17

Page 18: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Functions

• Example: (3,2.5), (4.5,1), (7,2.5), (9,0.5)• At x=x1=4.5

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

18

Page 19: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Functions

• Example: (3,2.5), (4.5,1), (7,2.5), (9,0.5)• At x=x2=7

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

19

Page 20: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Equations

• Solve the system of equations to find the second derivatives

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

20

Page 21: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Equations

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

21

Page 22: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Spline Equations

• Substituting for other intervals

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

22

Page 23: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Cubic Splines

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

23

Page 24: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Approximation

• What if the curve is periodic• Use a sinusoidal function as the least-

squares model

• Select coefficients to minimize least-squares sum

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

24

Page 25: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Least-Squares Approximation of Sinusoidal Functions

• Special case when the data points are spaced at equal intervals of Δt over one period

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

25

Page 26: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Series• Any periodic function can be represented

by a series of sinusoids of multiples of a common harmonic frequency

[ ]

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

26

Page 27: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

27

Page 28: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

28

Page 29: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

29

Page 30: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

30

Page 31: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

31

Page 32: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Fourier Series

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

32

Page 33: Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1

Next class

• Review

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

33