330 likes | 501 Views
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.
E N D
Halfway Down Halfway down the stairsIs a stair Where I sit.There isn't any Other stairQuite likeIt.I'm not at the bottom,I'm not at the top;So this is the stairWhere I alwaysStop. 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 thoughtsRun round my head:"It isn't really Anywhere!It's somewhere else instead!"
Halfway Down Halfway down the stairsIs a stair Where I sit.There isn't any Other stairQuite likeIt.I'm not at the bottom,I'm not at the top;So this is the stairWhere I alwaysStop. 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 thoughtsRun round my head:"It isn't really Anywhere!It's somewhere else instead!" A.A. Milne
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
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 y x y x
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: • “expensive” to solve for the coefficients • System of equations (Vandermonde matrix) becomes ill-conditioned • High order polynomials oscillate between points
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. don’t know know
Polynomial (and other) Fitting • Problem looks like: • Two options: • Solve the normal equations: ATAa = ATb. Solved by standard LU decomposition, but tend to be badly conditioned and prone to roundoff error. • Do a singular value decomposition on A. Naturally finds the solution which is the best least squares approximation. A= a= b= Aa=b
Up or Down? Halfway up the stairs Isn't up,And isn't down.It isn't in the nursery,It isn't in the town. Up How much up and how much down? Down
Lagrangian Interpolation entire range y sub-interval x • 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
Linear Lagrange Interpolation sub-interval y (xj+1,yj+1) (xj,yj) x yj(x) • Put a straight line between each pair of points What form do Lj and Lj+1 take?
Linear Lagrange Interpolation sub-interval y (xj+1,yj+1) (xj,yj) x yj(x) • Put a straight line between each pair of points Lj+1 1 Important!! L act as weighting functions: some of yj and some of yj+1 xj+1 x xj
Quadratic Lagrange Interpolation sub-interval y (xj+1,yj+1) (xj-1,yj-1) (xj,yj) x yj(x) • Put a quadratic between each triplet of points
Quadratic Lagrange Interpolation Lj-1 Lj Lj+1 1 1 1 xj-1 xj xj+1 xj-1 xj xj+1 xj-1 xj xj+1
Quadratic Lagrange Interpolation Still true? Check! L continue to act as weighting functions: some of yj-1, some of yj, and some of yj+1
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
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. sub-interval y (xj+1,yj+1) (xj-1,yj-1) (xj,yj) x slope discontinuous Not always important
Function Continuity • C0 continuity – value continuous • C1 continuity – gradient or slope continuous • C2 continuity – curvature (2nd derivative) continuous
Interpolation with Slope Continuity sub-interval: j y • Definitions: kj kj+1 x yj(x) xj xj+1 • Four “degrees of freedom” over interval: pj(xj), pj(xj+1), p’j(xj)=kj and p’j(xj+1 )=kj+1 • Four dof can be fitted by a cubic polynomial. • Gradients may be known at x0 and xN. • May be reasonable to set p’’=0 at x0 and xN. p’’=0 p’’ 0
Cubic Spline Polynomial • General form: • Spline – from thin rods used by engineers to fit smooth curves through a number of points. • pj(x) must satisfy: pj(xj)=yj, pj(xj+1)=yj+1, p’j(xj)=kj and p’j(xj+1 )=kj+1 • Two steps to make pj(x) useful. (1) Determine a0 to a3. (2) Determine k values. Two sets of equations necessary.
Step 1: Spline Coefficients • To satisfy: pj(xj)=yj, p’j(xj)=kj , pj(xj+1)=yj+1 and p’j(xj+1 )=kj+1
Step 1: Spline Coefficients • Solving for a2 and a3: • Once the kj values are known, the spline function is determined.
Step 2: Unknown Gradients sub-interval: j sub-interval: j-1 • For cubic in each interval: • Evaluating the second derivatives: • Equating the second derivatives: y’’ p’’j-1(x) p’’j(x) xj x
Step 2: Unknown Gradients k0 y’’N-1(xN)=0 y • Known or • assumed • information: • If k0 and kN are known, there are N-1 points, N-1 unknown k values and N-1 equations. • Equal number of equations and unknowns. y’’0(x0)=0 N-1 internalpoints kN x x0 xN
Step 2: Unknown Gradients • If k0 and kN 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.
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
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.