Presentation on theme: "Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation."— Presentation transcript:
Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation
Interpolation: Overview l Objective: estimate intermediate values between precise data points using simple functions l Solutions –Newton Polynomials –Lagrange Polynomials –Spline Interpolation InterpolationCurve Fitting multiple values Curve need not go through data points single value Curve goes through data points
Newton’s Divided-Difference Interpolating Polynomials l General comments l Linear Interpolation l Quadratic Interpolation l General Form
Linear Interpolation Formula By similar triangles: Rearrange: The notation: means the first order interpolating polynomial
Estimate ln(2) (the true value is 0.69) We know that: at x = 1 ln(x) =0 at x = e ln(x) =1 (e= ) Thus, Example Problem: Solution:
General form: Equivalent form: To solve for,three points are needed: Quadratic Interpolation (f 2 (x) means second-order interpolating polynomial)
Set in (1) to find Substitute in (1) and evaluate at to find: Quadratic Interpolation Note: this looks like a second derivative…
Example Estimate ln(2) (the true value is 0.69) We know that: at x = x 0 = 1 ln(x) =0 at x = x 1 = e ln(x) =1 (e= ) at x = x 2 = e 2 ln(x) = 2 Problem Solution
How to Generalize This? It would get pretty tedious to do this for third, fourth, fifth, sixth, etc order polynominal We need a plan: Newton’s Interpolating Polynomials
To solve for, n+1 points are needed: Solution General form of Newton’s Interpolating Polynomials What does this [ ] notation mean?
First finite divided difference: nth finite divided difference: Finite Divided Differences Second finite divided difference:
Finite divided difference table, case n = 3: Finite Divided Differences
Divided Differences Pseudo Code do i=0,n-1 fdd(i,1)=f(i) enddo do j=2,n do i=1,n-j+1 fdd(i,j)=(fdd(i+1,j-1)-fdd(i,j-1))/ & (x(i+j-1)-x(i)) enddo
Example – ln(2) again
Newton Interpolation Pseudo Code See the textbook!
Features of Newton Divided-Differences to get Interpolating Polynomial l Data need not be equally spaced l Arrangement of data does not have to be ascending or descending, but it does influence error of interpolation l Best case is when the base points are close to the unknown value l Estimate of relative error: Error estimate for n th-order polynomial is the difference between the ( n +1)th and n th-order prediction.
Relative Error As a Function of Order Example 18.5 in text Determine ln(2 ) using the following table MATLAB function interp1 is very useful for this