Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mark Trew CT1 2002. Halfway Down Halfway down the stairs Is a stair Where I sit. There isn't any Other stair Quite like It. I'm not at the bottom, I'm.

Similar presentations


Presentation on theme: "Mark Trew CT1 2002. Halfway Down Halfway down the stairs Is a stair Where I sit. There isn't any Other stair Quite like It. I'm not at the bottom, I'm."— Presentation transcript:

1 Mark Trew CT1 2002

2 Halfway Down Halfway down the stairs Is a stair Where I sit. There isn't any Other stair Quite like It. I'm not at the bottom, I'm not at the top; So this is the stair Where I always Stop. Halfway up the stairs Isn't up, And isn't down. It isn't in the nursery, It isn't in the town. And all sorts of funny thoughts Run round my head: "It isn't really Anywhere! It's somewhere else instead!"

3 Mark Trew CT1 2002 Halfway Down Halfway down the stairs Is a stair Where I sit. There isn't any Other stair Quite like It. I'm not at the bottom, I'm not at the top; So this is the stair Where I always Stop. Halfway up the stairs Isn't up, And isn't down. It isn't in the nursery, It isn't in the town. And all sorts of funny thoughts Run round my head: "It isn't really Anywhere! It's somewhere else instead!" A.A. Milne

4 Mark Trew CT1 2002 Interpolation – the ups and downs

5 Mark Trew CT1 2002 Interpolation and Fitting Discrete datum points obtained by some process Provide basis for a description of behaviour at any point Description usually in some function form: Function can have some physical form based on theoretical behaviour or can be a more general form Use interpolation every day, e.g. measurements, weights, solving ODEs etc. or

6 Mark Trew CT1 2002 Interpolation and Fitting Interpolation vs Fitting – in general: -Interpolation reproduces datum values at the datum locations -Fitting seeks to provide the best overall description Interpolation vs Extrapolation -Interpolation: unknown value bracketed by known values -Extrapolation: unknown value has known value on one side only x y x y

7 Mark Trew CT1 2002 Polynomial Interpolation Determine the coefficients of a polynomial one order less than the number of datum points: Coefficients found by solving linear system of equations: Significant problems with this kind of interpolation, especially as the number of datum points becomes large: 1.“expensive” to solve for the coefficients 2.System of equations (Vandermonde matrix) becomes ill- conditioned 3.High order polynomials oscillate between points

8 Mark Trew CT1 2002 Polynomial (and other) Fitting Polynomials useful for small number of points – at least 3 for a quadratic Can be useful for fitting rather than datum interpolation Given polynomial to “reasonable” order, find coefficients such that function is a good representation of data, e.g. minimise the sum of the squared difference between function and datum values (called Least Squares Fit): If we have N data points and our polynomial is of order m, how can we solve? The problem is overdetermined. know don’t know

9 Mark Trew CT1 2002 Polynomial (and other) Fitting Problem looks like: Two options: 1.Solve the normal equations: A T Aa = A T b. Solved by standard LU decomposition, but tend to be badly conditioned and prone to roundoff error. 2.Do a singular value decomposition on A. Naturally finds the solution which is the best least squares approximation. A=a=a=b=b= Aa=bAa=b

10 Mark Trew CT1 2002 Up or Down? Up Down Halfway up the stairs Isn't up, And isn't down. It isn't in the nursery, It isn't in the town. How much up and how much down?

11 Mark Trew CT1 2002 Lagrangian Interpolation Used for large number of datum points Break whole interpolation range into smaller intervals Use low order polynomial to interpolate over sub-interval only Overcomes problems with high-order polynomial interpolation x y entire range sub-interval

12 Mark Trew CT1 2002 Linear Lagrange Interpolation x y sub-interval Put a straight line between each pair of points (x j,y j ) (x j+1,y j+1 ) yj(x)yj(x) What form do L j and L j+1 take?

13 Mark Trew CT1 2002 Linear Lagrange Interpolation x x y sub-interval Put a straight line between each pair of points (x j,y j ) (x j+1,y j+1 ) yj(x)yj(x) L j+1 1 xjxj x j+1 Important!! L act as weighting functions: some of y j and some of y j+1

14 Mark Trew CT1 2002 Quadratic Lagrange Interpolation x y sub-interval Put a quadratic between each triplet of points (x j-1,y j-1 )(x j,y j ) yj(x)yj(x) (x j+1,y j+1 )

15 Mark Trew CT1 2002 Quadratic Lagrange Interpolation L j-1 1 x j-1 x j+1 xjxj LjLj 1 x j-1 x j+1 xjxj L j+1 1 x j-1 x j+1 xjxj

16 Mark Trew CT1 2002 Quadratic Lagrange Interpolation Still true? Check! L continue to act as weighting functions: some of y j-1, some of y j, and some of y j+1

17 Mark Trew CT1 2002 Lagrange Interpolation of any Order An mth order Lagrange interpolation using m+1 datum points is represented by: The weighting functions, or Lagrange polynomials, are described by: multiply

18 Mark Trew CT1 2002 Lagrange Interpolation of any Order Always true that: A problem with Lagrange interpolation is the lack of slope continuity between the sub-interval (element) boundaries. x y sub-interval (x j-1,y j-1 )(x j,y j ) (x j+1,y j+1 ) slope discontinuous Not always important

19 Mark Trew CT1 2002 Next time… Function continuity and Cubic Splines

20 Mark Trew CT1 2002 The story continues… Function continuity and Cubic Splines

21 Mark Trew CT1 2002 Function Continuity

22 Mark Trew CT1 2002 Function Continuity C 0 continuity – value continuous C 1 continuity – gradient or slope continuous C 2 continuity – curvature (2 nd derivative) continuous

23 Mark Trew CT1 2002 Interpolation with Slope Continuity Four “degrees of freedom” over interval: p j (x j ), p j (x j+1 ), p’ j (x j )=k j and p’ j (x j+1 )=k j+1 Four dof can be fitted by a cubic polynomial. Gradients may be known at x 0 and x N. May be reasonable to set p’’=0 at x 0 and x N. x y sub-interval: j xjxj x j+1 yj(x)yj(x) Definitions: kjkj k j+1 p’’  0 p’’=0

24 Mark Trew CT1 2002 Cubic Spline Polynomial General form: Spline – from thin rods used by engineers to fit smooth curves through a number of points. p j (x) must satisfy: p j (x j )=y j, p j (x j+1 )=y j+1, p’ j (x j )=k j and p’ j (x j+1 )=k j+1 Two steps to make p j (x) useful. (1) Determine a 0 to a 3. (2) Determine k values. Two sets of equations necessary.

25 Mark Trew CT1 2002 Step 1: Spline Coefficients To satisfy: p j (x j )=y j, p’ j (x j )=k j, p j (x j+1 )=y j+1 and p’ j (x j+1 )=k j+1

26 Mark Trew CT1 2002 …some algebra later…

27 Mark Trew CT1 2002 Step 1: Spline Coefficients Solving for a 2 and a 3 : Once the k j values are known, the spline function is determined.

28 Mark Trew CT1 2002 Step 2: Unknown Gradients x y’’ sub-interval: j xjxj p’’ j-1 (x) sub-interval: j-1 p’’ j (x) For cubic in each interval: Evaluating the second derivatives: Equating the second derivatives:

29 Mark Trew CT1 2002 Step 2: Unknown Gradients Known or assumed information: If k 0 and k N are known, there are N-1 points, N-1 unknown k values and N-1 equations. Equal number of equations and unknowns. x y x0x0 xNxN k0k0 kNkN y’’ N-1 (x N )=0 y’’ 0 (x 0 )=0 N-1 internal points

30 Mark Trew CT1 2002 Step 2: Unknown Gradients If k 0 and k N are not known, there are N+1 points, N+1 unknown k values and N-1 equations of the type: and two equations: from the condition of zero curvature (p’’=0) at the end-points. Still equal number of equations and unknowns.

31 Mark Trew CT1 2002 Step 2: Unknown Gradients In both cases, equations are put together into a matrix of linear equations in the unknown k values. The system of equations is solved. Each row has only 3 non-zero terms – one on either side of the diagonal. Very efficient to solve. = k

32 Mark Trew CT1 2002 Summary Gradient continuous interpolations can be produced using cubic splines. Gradients must be known at the extremum points – or assumption of zero curvature can be used. System of linear equations solved to give gradients at each discrete point. (Step 2) Gradients used to determine coefficents of cubic spline interpolation for each sub-interval. (Step 1) Cubic splines can be used to interpolate to x points lying between known discrete points.

33 Mark Trew CT1 2002 The end…


Download ppt "Mark Trew CT1 2002. Halfway Down Halfway down the stairs Is a stair Where I sit. There isn't any Other stair Quite like It. I'm not at the bottom, I'm."

Similar presentations


Ads by Google