P T 4 Part 4 Chapter 15

P T 4 Part 4 Chapter 15

Pt4Part 4 Chapter 15 PlPolynomi ilItal Interpol ltiation PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Revised by Prof. Jang, CAU All images copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Objectives • Recogn iz ing that eval uati ng pol ynomi al coeffi c ien ts with simultaneous equations is an ill-conditioned problem. • Knowinggpy how to evaluate polynomial coefficients and interpolate with MATLAB’s polyfit and polyval functions. • Knowing how to perform an interpolation with Newton’s polynomial. • Knowing how to perform an interpolation with a Lagrange polynomial. • Knowing how to solve an inverse interpolation problem by recasting it as a roots problem. • Appreciating the dangers of extrapolation . • Recognizing that higher-order polynomials can manifest large oscillations. Introduction • Suppose that you desired the density at a temperature not included in the table below. In such a case, you would have to ilThiinterpolate. That is, you would ldhihl have to estimate the values at the desired temperature based on the densities that include it. • The simpppplest approach is to determine the eq uation for the straight line connecting the two adjacent values and use this equation to estimate the density at the desired intermediate temperature. • Although such linear interpolation is perfectly adequate in many cases, error can be introduced when the data exhibit siifiignificant curvature. -> hihigh her ord er i nterpol ati on i s requi red . T (C) (kg/m3) (Ns/m2) v (m2/s) 200 0.746 2.57 10-5 3.45 10-5 250 0.675 2.75 10-5 4.08 10-5 300 0.616 2.93 10-5 4.75 10-5 400 0.525 3.25 10-5 6.20 10-5 500 0.457 3.55 10-5 7.77 10-5 Polynomial Interpolation • You will frequently have occasions to estimate intermediate values between precise data points. • The function you use to interpolate must pass through the actual data points - this makes interppgolation more restrictive than fitting. • The most common method for this purpose is ppyolynomial interp olation,,( where an (n-1)th order polynomial is solved that passes through n data points: 2 n1 f (x) a1 a2 x a3x an x MATLAB version : f (x) p xn1 p xn2 p x p 1 2 n1 n Determining Coefficients • A straightforward way for computing the coefficients is based on the fact that n data points are required to determine the n coefficients. Hence, the polynomial coefficients can be found exactly using linear algebra. • MATLAB’s built in polyfit and polyval commands can also be used - all that is required is making sure the order of the fit for n data points is n-1. Example 15.1 ( 1/2) Q. Determine the coefficients of the parabola that passes through the last three density values from Table 15.1 2 f (x) p1 x p2 x p3 Solution) 2 x1 300 f (x1) 0.616 0.616 p1(300) p2 (300) p3 2 x2 400 f (x2 ) 0.525 0.525 p1(400) p2 (400) p3 x 500 f (x ) 0.457 2 3 3 0.457 p1(500) p2 (500) p3 90,000 300 1 p1 0.616 160,000 400 1 p 0.55525 2 250,000 500 1 p3 0.457 Example 15.1 (2/2) >> format long >> A = [90000 300 1; 160000 400 1; 250000 500 1]; >> b = [0.616 0.525 0.457]'; >> p = A\b p = 0.00000115000000 -0. 00171500000000 1.02700000000000 f (x) 0.00000115x 2 0.001715x 1.027 This polynomial can provide a means to determine intermediate points. For examppyle, the value of density at 350C can be found as f (350) 0.00000115(350)2 0.001715(350) 1.027 0.567625 Polynomial Interpolation Problems n1 n2 f (x) p1x p2 x pn1x pn • One problem that can occur with solving for the coefficients of a polynomial is that the system to be inverted is in the form: n1 n2 x x x 1 p fx 1 1 1 1 1 xn1 xn2 x 1 p f x 2 2 2 2 2 n1 n2 p xn1 xn1 xn1 1 n1 fxn1 n1 n2 pn xn xn xn 1 f xn • Matrices such as that on the left are known as Vandermonde matrices,,y and they are very ill-conditioned - meaning their solutions are very sensitive to round-off errors. • The issue can be minimized by scaling and shifting the data . Newton Interpolating Polynomials • Another way to express a polynomial interpolation is to use Newton’s itinterpol ltiating pol ynomi ilal. • The differences between a simple polynomial and Newton’s interpolating polynomial for first and second order interpolations are: Order Simple Newton 1st (linear) f1(x) a1 a2 x f1(x) b1 b2 (x x1) 2 2nd (dti(quadratic) f2 (x) a1 a2 x a3x f2 (x) b1 b2 (x x1) b3 (x x1)(x x2 ) Newton Interpolating Polynomials (Liiinear interpo lilation) • The first -order Newton interpolating polynomial may be obtained from linear interpolation and similar triangles, as shown. • The resulting formula based on kitknown points x1 and x2 andthd the values of the dependent function at those points is : fx 2 fx 1 f1x fx1 x x1 x2 x1 • In general, the smaller the interval Graphical representation of between the data points, the linear interpolation better the approximation. Newton Interpolating Polynomials (QdiiQuadratic interpo lilation) • The second -order Newton interpolating polynomial introduces some curvature to the line connecting the points, but still goes through the first two points. • The resulting formula based on known points x1, x2, and x3 and the values of the dependent function at those poitints i s: f2 (x) b1 b2 (x x1) b3 (x x1)(x x2 ) fx fx fx fx 3 2 2 1 f x2 f x1 x3 x2 x2 x1 f2 x fx1 x x1 x x1 x x2 x2 x1 x3 x1 Example 15.2 Q. Estimate the natural logarithm of 2 using linear interpolation. First compute it by interpolating between ln 1 0 and ln 6 1 .791759 . Then repeat the procedure using smaller interval from ln1 and ln4 (1.386294). Note: ln 2 0.6931472 Solution) Using x1 = 1 and x2 = 6 1.791759 0 f (2) 0 (2 1) 0.3583519 1 6 1 Using x1 = 1 and x2 = 4, 1.386294 0 f (2) 0 (2 1) 0.4620981 1 4 1 The value εt are 48.3% and 33.3% respectively. Example 15.3 Q. Use a second-order Newton polynomial to estimate ln2 with the same three points used in Ex . 15.2 . Solution) x1 1 f (x1) 0 x2 4 f (x2 ) 1.386294 x3 6 f (x3 ) 1.791759 1.386294 0 b1 0 b 0.4620981 2 4 1 1.791759 1.386294 0.4620981 b 6 4 0.0518731 3 6 1 f2 (x) 0 0.4620981(x 1) 0.0518731(x 1)(x 4) f 2 (2) 0.5658444 The value εt are 18.4% . -> The quadratic formula improves the error. Newton Interpolating Polillynomials (Generalfl form) • In general, an ( n-1)th Newton interpolating polynomial can be fitted to n data points. • The general formula is: f x b b x x b x x x x x x n1 1 2 1 n 1 2 n1 where b1 fx 1 b2 fx2, x1 b3 fx 3, x2, x1 b f x , x , , x , x n n n1 2 1 and the f[…] represent divided differences. Divided Differences • Divided difference are calculated as follows: fx i fx j f xi , x j xi x j fxi , x j fxj , xk fxi , x j , xk xi xk fx, x , , x fx, x , , x fx, x , , x , x n n1 2 n1 n2 1 n n1 2 1 x x n 1 • High er-orddiiddder divided differences are ca lcu la te d us ing divided difference of lower-order terms: Graphical representation of the recursive nature of finite divided differences Example 15.4 (1/2) Q. Estimate ln2 using a third-order Newton’s interpolating polilUthfllifitlynomial. Use the following four points x1 = 1, x2 = 4, x3 = 6, and x4 = 5, [f(x4) = 1.609438]. Solution) f3 (x) b1 b2 (x x1) b3 (x x1)(x x2 ) b4 (x x1)(x x2 )(x x3 ) 1.38629 4 0 1.791759 1.386294 f [x2 , x1 ] 0.4620981 f [x , x ] 0.2027326 4 1 3 2 6 4 1.609438 1.791759 f [x , x ] 0.1823216 4 3 5 6 0.1823216 0.2027326 f [x , x , x ] 0.02041100 4 3 2 5 4 0.2027326 0.4620981 f [x , x , x ] 0.05187311 3 2 1 6 1 0.02041100 (0.05187311) f [x , x , x , x ] 0.007865529 4 3 2 1 5 1 Example 15.4 (2/2) f3 (x) b1 b2 (x x1) b3 (x x1)(x x2 ) b4 (x x1)(x x2 )(x x3 ) xi f(xi) First Second Third 1 0 0.4620981 -0.05187311 0.007865529 4 1. 386294 0. 2027326 -0. 02041100 6 1.791759 0.1823216 5 1.609438 f3 (x) 0 0.4620981(x 1) 0.05187311(x 1)(x 4) f3 (2) 0.6287686 0.007865529(x 1)(x 4)(x 6) MATLAB Implementation Lagrange Interpolating Polillynomials • Another method that uses shifted value to express an interpolating polynomial is the Lagrange interpolating polynomial . • The differences between a simply polynomial and Lagrange interpolating polynomials for first and second order polynomials are: Order Simple Lagrange 1st f1(x) a1 a2 xf1(x) L1 fx1 L2 fx2 2 2nd f2 (x) a1 a2 x a3x f2 (x) L1 f x1 L2 f x2 L3 f x3 where the Li are weighting coefficients that are functions of x.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 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