Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1."— Presentation transcript:

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

2 Lagrange & Newton Interpolation Noticing that the function (black line) has a sharp or sudden change at x = 0. Polynomial interpolations work poorly. Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 2

3 Spline Interpolation Spline interpolation applies low-order polynomial to connect two neighboring points and uses it to interpolate between them. Typical Spline functions Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 3

4 Linear Splines Use straight lines to connect two neighboring points Shortcomings: Sharp angle at connections, or not smooth. Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 4

5 Linear Splines Use either Lagrange or Newton interpolations to determine the equations for the straight lines To find y 5 at x 5, first find which interval x 5 is in and then use the linear Spline in that region to calculate y 5. Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 5

6 Quadratic Spline Function Each two neighboring points are connected by a 2 nd -order (quadratic) polynomial. Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 6

7 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 (a i, b i & c i ) to be determined. Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 7

8 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 Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 8

9 Equations Used to Determine Coefficients Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 9

10 Quadratic Splines Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 10

11 Cubic Spline Function Each two neighboring points are connected or interpolated by a 3 rd -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 (a i, b i, c i & d i ). Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 11

12 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 Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 12

13 Equations Used to Determine Coefficients Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 13 Second

14 Cubic Spline Functions Second derivative is a line Lagrange interpolating polynomial for second derivative Integrate twice to get f i (x) Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 14

15 Cubic Spline Functions Two constants can be evaluated by applying interval end conditions Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 15

16 Cubic Spline Functions First derivatives at knots must be equal Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 16 at x i

17 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 Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 17

18 Cubic Spline Functions Example: (3,2.5), (4.5,1), (7,2.5), (9,0.5) At x=x 1 =4.5 Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 18

19 Cubic Spline Functions Example: (3,2.5), (4.5,1), (7,2.5), (9,0.5) At x=x 2 =7 Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 19

20 Cubic Spline Equations Solve the system of equations to find the second derivatives Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 20

21 Cubic Spline Equations Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 21

22 Cubic Spline Equations Substituting for other intervals Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 22

23 Cubic Splines Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 23

24 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 Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 24

25 Least-Squares Approximation of Sinusoidal Functions Special case when the data points are spaced at equal intervals of Δt over one period Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 25

26 Fourier Series Any periodic function can be represented by a series of sinusoids of multiples of a common harmonic frequency [ ] Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 26

27 Fourier Series Example Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 27

28 Fourier Series Example Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 28

29 Fourier Series Example Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 29

30 Fourier Series Example Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 30

31 Fourier Series Example Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 31

32 Fourier Series Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 32

33 Next class Review Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 33


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

Similar presentations


Ads by Google