Curve Fitting to Polynomials & Interpolation/Extrapolation

Curve Fitting to Polynomials & Interpolation/Extrapolation

6/9/2020 Computational Science: Computational Methods in Engineering Curve Fitting to Polynomials & Interpolation/Extrapolation https://empossible.net/academics/emp4301_5301/ Outline • Exact Fit Methods – Fitting Polynomials • Interpolation & Extrapolation • MATLAB Implementation https://empossible.net/academics/emp4301_5301/ 2 1 6/9/2020 Fitting Polynomials https://empossible.net/academics/emp4301_5301/ 3 Statement of the Problem Suppose it is desired to fit the following Nth‐order polynomial to a set of points. 2 N f xaaxax01 2 axN There exists N+1 unknown coefficients so N+1 points are needed to calculate the coefficients exactly. 4 2 6/9/2020 Calculating the Unknown Polynomial Coefficients First, write the polynomial at the N+1 points. 2 N fx101121 a axax axN 1 2 N fx201222 a axax axN 2 2 N f xaaxaxaxNNNNN101121 1 Since this is an exact fit, there are no residual terms. 5 Calculating the Unknown Polynomial Coefficients Second, put the equations into matrix form. 2 N f xa10 1 xx11 x 1 2 N 2 N fx101121 a axax axN 1 f xa211 xx22 x 2 2 N fx a axax ax 201222N 2 2 N f xa32 1 xx x 33 3 f xaaxaxax 2 N NNNNN101121 1 2 N f xaNN1 1 xxNN11 x N 1 This can be written more compactly as Aside: f Xa This is a Vandermonde matrix and is usually ill‐conditioned for large matrices. See Lagrange interpolation. 6 3 6/9/2020 Calculating the Unknown Polynomial Coefficients Last, the matrix equation is solved for [a] to find the polynomial coefficients. a0 a1 1 aXf aa 2 aN 7 Example 1 (1 of 2) Fit the following points to a polynomial.. f 00 f(x) f 1.5 1.5 f 4.0 1.0 x Step 1 –Determine order of polynomial Since there are three points, a quadratic polynomial can be fit. 2 f xaaxax 01 2 8 4 6/9/2020 Example 1 (2 of 2) Step 2 –The matrix equation is 22 f101121aaxax f 110100 xx 11 a 0 a 0 f aaxax 22 f 1 xx a 1.5 1 1.5 2.25 a 201222 2 221 1 22 f301323aaxax f 311.01416 xx 33 a 2 a 2 Step 3 –Calculate polynomial coefficients. 1 a0 10 0 0 0 a 1 1.5 2.25 1.5 1.45 1 a2 1 4 16 1.0 0.3 Step 4 –Write the final polynomial. f(x) f xxx 1.45 0.3 2 x 9 Interpolation & Extrapolation https://empossible.net/academics/emp4301_5301/ 10 5 6/9/2020 What is Interpolation & Extrapolation? Interpolation –Sometimes an intermediate value located between measured values is needed. Extrapolation –Sometimes a value located outside of the measured values is needed. Why? Measuring the new value may be difficult, expensive, time‐consuming or impossible. Interpolation and extrapolation can be thought of as two steps: Step 1 – Fit data to a curve. Step 2 –Use the curve fit to calculate the new value(s). 11 Linear Interpolation Given two data points, a line can be fit from which it is possible to interpolate or extrapolate anything else. Given two data points , and , , the equation for the line is yy21 yy11 xx xx21 slope y 2 error This equation can be used to interpolate from any yi desired position . y1 yy yy21xx ii11 x1 xi x2 xx21 12 6 6/9/2020 Polynomial Interpolation (1 of 3) Interpolation using a quadratic polynomial is likely the most common method of interpolation. This requires three points. f x 2 f xaaxax 01 2 x 13 Polynomial Interpolation (2 of 3) Write the matrix equation . 2 f11101 xx a f 1 xx2 a 2221 2 f33321 xxa Solve for the polynomial coefficients . xx xx xx 23 13 12 1 xxxx xxxx xxxx axxf1 2 1213 1223 1323f 0111 1 2 xx23 xx 13 xx12 axxf 1 f 1222 xxxx xxxx xxxx 2 2 1213 1223 1323 axxf23331 f3 111 xxxx1213 xxxx 1223 xxxx 1323 14 7 6/9/2020 Polynomial Interpolation (3 of 3) The final equations are xx23 xx 13 xx12 afff0123 xxxx1213 xxxx 12 23 xxxx 1323 xx23 xx 13 xx12 afff1123 xxxx1213 xxxx 1223 xxxx 1323 11 1 afff2123 xxxx1213 xxxx 12 23 xxxx 1323 Typically, these are not calculated using these equations. Instead, the matrix inversion is performed numerically. 15 Example 1 – Quadratic Interpolation Given the following points, interpolate the value at 3. f 00 f 1.5 1.5 f 4.0 1.0 Solution Step 1 –These points were previously fit to a quadratic polynomial. The answer was f xxx 1.45 0.3 2 Interpolated point f(x) Step 2 –This is evaluated at 3. f 3 1.45 3 0.3 32 1.65 x 16 8 6/9/2020 Example 2 – Quadratic Extrapolation Given the following points, extrapolate the value at 0.5. f 00 f 1.5 1.5 f 4.0 1.0 Solution Step 1 –These points were previously fit to a quadratic polynomial. The answer was 2 f xxx 1.45 0.3 f(x) Step 2 –Evaluate this at 0.5. x f 0.5 1.45 0.5 0.3 0.52 0.8 Extrapolated point 17 9.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us