Presentation is loading. Please wait.

Presentation is loading. Please wait.

Splines There are cases where polynomial interpolation is bad

Similar presentations


Presentation on theme: "Splines There are cases where polynomial interpolation is bad"— Presentation transcript:

1 Splines There are cases where polynomial interpolation is bad overshoot oscillations

2 Example Interpolation at -4,-3,-2,-1,0,1,2,3,4

3 Idea behind splines use lower order polynomials to connect subsets of data points make connections between adjacent splines smooth because lower order polynomials, avoid oscillations and overshoots

4 We will cover linear splines quadratic splines cubic splines - most common Autocad uses splines extensively

5 Linear splines - connect each two points with straight line functions connecting each pair of points are m is slope between points

6 Linear splines are exactly the same as linear interpolation!
Example:

7 Problem with linear splines - not smooth at data points (or knots)
first derivative is not continuous use higher order splines to get continuous derivatives - equate derivatives at neighboring splines

8 Quadratic splines - continuous first derivatives
can have discontinuous second and higher derivatives Derive second order polynomial between each pair of points For n+1 points (i=0,1,…,n) - n intervals - 3n unknown parameters (a’s, b’s, and c’s) Need 3n equations

9 Equations for interior knots (data points), equations on either side must equal knot at knot n-1 interior knots 2n-2 interior equations

10 the first and last functions must pass through the end points
2 more equations: total is 2n so far

11 first derivatives at interior nodes must be equal
Another n-1 equations for a total of 3n-1 equations We need 3n equations. What is the last equation?

12 Last equation is arbitrary
We use assume second derivative is 0 at first point Connect first two points by a straight line

13 Example: n=3 9 unknowns Set up interior equations (4 of them)

14 Set up end-point equations (2 of them)

15 Set up first derivative equations at interior knots (2 of them)
Final arbitrary equation

16 The 9 equations are

17 Rearrange, and use a1=0 to eliminate

18 Put in matrix form

19 Solve by any matrix method
Get

20 Result

21 Cubic splines avoid the straight line and the over-swing
Can develop method like we did for quadratic - 4n unknowns - 4n equations interior knot equality end point fixed interior knot first derivative equality assume derivative value if needed

22 Can do a set of algrebraic manipulations (which book shows) to reduce 4n equations to n-1 equations
Unknowns - second derivatives

23 Second derivatives are evaluated using
with end conditions Becomes a tridiagonal system

24

25 Method outline Set up equations for second derivatives get second dertivatives and plug into spline equation for each section

26 Example: Note that n is 3 - we will not have a true tridiagonal setup Get second derivatives with end conditions

27 Write the equations as

28 Now plug second derivative values into cubic spline equation
This gets messy, so look at Matlab code

29


Download ppt "Splines There are cases where polynomial interpolation is bad"

Similar presentations


Ads by Google