Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical...

Post on 02-Jan-2016

240 views 1 download

Tags:

Transcript of Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical...

Today’s class

• Spline Interpolation• Quadratic Spline• Cubic Spline

• Fourier Approximation

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, 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

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

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

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

Quadratic Spline Function• Each two neighboring points are connected

by a 2nd-order (quadratic) polynomial.

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

6

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

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

Equations Used to Determine Coefficients

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

9

Quadratic Splines

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

10

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

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

Equations Used to Determine Coefficients

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

13

• Second

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

Cubic Spline Functions

• Two constants can be evaluated by applying interval end conditions

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

15

Cubic Spline Functions

• First derivatives at knots must be equal

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

16

at xi

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

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

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

Cubic Spline Equations

• Solve the system of equations to find the second derivatives

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

20

Cubic Spline Equations

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

21

Cubic Spline Equations

• Substituting for other intervals

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

22

Cubic Splines

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

23

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

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

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

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

27

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

28

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

29

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

30

Fourier Series

• Example

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

31

Fourier Series

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

32

Next class

• Review

Numerical MethodsLecture 21

Prof. Jinbo BiCSE, UConn

33