22
Interpolation and Curve Fitting Wednesday 10 August 2011

Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Embed Size (px)

Citation preview

Page 1: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Interpolation and Curve Fitting

Wednesday 10 August 2011

Page 2: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Discrete Data

Fitting predominantly done with polynomials

Intractable functions replaced by interpolating polynomials

Polynomial of order n

Laplace’s method: Unique polynomial of degree n-1 that can pass through n points

for n = 2, linear polynomial

Obviously the polynomialpasses through all the points

error in polynomial interpolation

Wednesday 10 August 2011

Page 3: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Lagrange’s method is

straightforward, but does not lend itself to algorithm.Newton’s method

is better

Newton’s Method

Wednesday 10 August 2011

Page 4: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Evaluation of Coefficients in NewtonIntroducing divided differences

for n = 5

Wednesday 10 August 2011

Page 5: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Limitations of Interpolation with polynomials

dangers of using too many points (oscillatory behavior)Runge Phenomenon

1. Works well when the total number of points used is few.2. If many close points: linear interpolation is good.3. Interpolation between 3 to 6 points is ok.4. Too many points are neither useful (possibly dangerous)5. Polynomial extrapolation outside the data points is

dangerous. Better to use low order nearest neighborinterpolation (linear or quadratic). Can work with plot of log(x) vs log(y), which is generally a straight line.

absurd extrapolation beyond 12.0 linear extrapolation on log-log plot

Wednesday 10 August 2011

Page 6: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 7: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Spline Interpolation

Since q = 0, the solution is cubic (at most)Slope and bending moment and thus curvature is

continuous. At the ends curvature is zero.

This is called natural cubic splineData points are called knots.

Wednesday 10 August 2011

Page 8: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Mathematical Description

put together from n-1 cubics

continuity of second derivative

The second derivatives are linear

therefore

Integrating

Using

Thus

Wednesday 10 August 2011

Page 9: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

to obtain k’s

results in simultaneous equations, which can be solved very easily becauseof the tri-diagonal nature of the matrix of k’s

Given data points:Matlab function

to obtain k’s

Wednesday 10 August 2011

Page 10: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Finally: Obtain the values of the function at any x

function to obtain in which i,i+1 does x fall

Wednesday 10 August 2011

Page 11: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Least Square Fit

Smooth curve that fits data points on average

n: no of data pointsm: number of fitting parameters (n > m)

The form of the smooth curve is generallyknown or at least assumed.

Best fit is the one which minimizes the residual

The spread of the curve is denoted by

Wednesday 10 August 2011

Page 12: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 13: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 14: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

polynFit:Function to

obtain coefficients

of polynomial

Wednesday 10 August 2011

Page 15: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

stdDev:To obtain

the standard deviation

Wednesday 10 August 2011

Page 16: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 17: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 18: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 19: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 20: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 21: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011

Page 22: Interpolation and Curve Fitting - Civil Departmentminamdar/ce603/Notes/Interpolation.pdf · Limitations of Interpolation with polynomials dangers of using too many points (oscillatory

Wednesday 10 August 2011