0% found this document useful (0 votes)
22 views29 pages

Lecture Numerical Interpolation

Uploaded by

Hasibur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views29 pages

Lecture Numerical Interpolation

Uploaded by

Hasibur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

ME 261

Session: January 2023

Dr. Sumon Saha


Professor
Department of Mechanical Engineering
Bangladesh University of Engineering and Technology
ME 261 .. Numerical Analysis

Lecture # 07

Numerical Interpolation
ME 261 .. Introduction to Interpolation

• Interpolation Function: A function that passes exactly


through a set of data points.
• Interpolating functions to interpolate values in Tables

• In Table, the function is only specified at a limited number


or discrete set of independent variable values (as opposed to
a continuum function)
• We can use interpolation to find functional values at other
values of the independent variable, e.g., sin(0.63253)
ME 261 .. Introduction to Interpolation

• In numerical methods, like Tables, the values of the


function are only specified at a discrete number of points!
Using interpolation, we can describe or at least approximate
the function at every point in space.
• For numerical methods, we use interpolation techniques for
the following cases:
– Interpolate values from computations
– Develop numerical integration schemes
– Develop numerical differentiation schemes
– Develop finite element methods
• Interpolation is typically not used to obtain a functional
description of measured data since errors in the data may
lead to a poor representation.
– Curve fittings to data is handled with a separate set of techniques
ME 261 .. Regression versus Interpolation
ME 261 .. Polynomial interpolation

• Estimation of intermediate values between precise data


points. The most common method is:
n −1
f ( x) = a1 + a2 x + a3 x + 2
+ an x
• Although there is one and only one (n-1)th-order polynomial
that fits n points, there are a variety of mathematical formats
in which this polynomial can be expressed:
– The Newton polynomial
– The Lagrange polynomial
• Although both Newton and Lagrange polynomials are well
suited for determining intermediate values between points,
they do not provide a polynomial in the above conventional
form.
ME 261 .. Coefficients of an Interpolating Polynomial

Since n data points are required to determine n coefficients,


simultaneous systems of linear equations can be used to
calculate “a”s.

f ( x1 ) = a1 + a2 x1 + a3 x12 + an x1n −1
n −1
f ( x2 ) = a1 + a2 x2 + a x 2
3 2 +a x n 2

n −1
f ( xn ) = a1 + a2 xn + a x 2
3 n +a x n n

Where “x”s are the knowns,


and “a”s are the unknowns.
ME 261 .. Coefficients of an Interpolating Polynomial
ME 261 .. Polynomial interpolation

Examples of interpolating polynomials: (a) first-order (linear)


connecting two points, (b) second-order (quadratic or parabolic)
connecting three points, and (c) third-order (cubic) connecting
four points.
ME 261 .. Newton’s Divided-Difference Interpolating
Polynomials
Linear Interpolation/
• Is the simplest form of interpolation, connecting two data
points with a straight line.
Slope and a
f1 ( x) − f ( x1 ) f ( x2 ) − f ( x1 ) finite divided
= difference
x − x1 x2 − x1 approximation to
f ( x2 ) − f ( x1 ) 1st derivative
f1 ( x) = f ( x1 ) + ( x − x1 )
x2 − x1 Linear-interpolation
formula

• f1(x) designates that this is a first-order interpolating


polynomial.
ME 261 .. Linear Interpolation

Taking slopes for both


triangles
f1 ( x) − f ( x1 ) f ( x2 ) − f ( x1 )
=
x − x1 x2 − x1

f ( x2 ) − f ( x1 )
f1 ( x) = f ( x1 ) + ( x − x1 )
x2 − x1
ME 261 .. Quadratic Interpolation

• If three data points are available, the estimate is improved


by introducing some curvature into the line connecting the
points.
f 2 ( x) = b1 + b2 ( x − x1 ) + b3 ( x − x1 )( x − x2 )
• A simple procedure can be used to determine the values of
the coefficients.
x = x1 b1 = f ( x1 )
f ( x2 ) − f ( x1 )
x = x2 b2 =
x − x1
f ( x3 ) − f ( x2 ) f ( x2 ) − f ( x1 )

x3 − x2 x2 − x1
x = x3 b3 =
x3 − x1
ME 261 .. General Form of Newton’s Interpolating
Polynomials
f n −1 ( x) = b1 + b2 ( x − x1 ) + b3 ( x − x1 )( x − x2 ) + + bn ( x − x1 )( x − x2 ) ( x − xn −1 )
f n −1 ( x) = f ( x1 ) + ( x − x1 ) f [ x2 , x1 ] + ( x − x1 )( x − x2 ) f [ x3 , x2 , x1 ] +
+( x − x1 )( x − x2 ) ( x − xn −1 ) f [ xn , xn −1 , , x1 ]
b1 = f ( x1 )
b2 = f [ x2 , x1 ]
b3 = f [ x3 , x2 , x1 ]

bn = f [ xn , xn −1 , , x 2 , x1 ]
f ( xi ) − f ( x j )
f [ xi , x j ] =
xi − x j
f [ xi , x j ] − f [ x j , xk ] Bracketed function evaluations are
f [ xi , x j , xk ] = finite divided differences
xi − xk

f [ xn , xn −1 , , x2 ] − f [ xn −1 , xn − 2 , , x1 ]
f [ xn , xn −1 , , x2 , x1 ] =
xn − x1
ME 261 .. General Form of Newton’s Interpolating
Polynomials

f ( xi ) − f ( x j ) f [ xi , x j ] − f [ x j , xk ]
f [ xi , x j ] = f [ xi , x j , xk ] =
xi − x j xi − xk
Question: The general form of Newton’s interpolating polynomial is-
f n ( x) = b0 + b1 ( x − x0 ) + b2 ( x − x0 )( x − x1 ) + + bn ( x − x0 )( x − x1 ) ( x − xn −1 )
Show that the coefficients b0, b1, b2,…, bn actually indicate derivates by
Newton’s Divided Difference Method.
ME 261 .. Linear Interpolation

Linear interpolation is obtained by passing a straight line between


2 data points
x1, x2 = the data points (also
f(x) referred to as interpolation points
or nodes)
f1(x) f(x) = exact function for which
values are known only at a
discrete set of data points

f1(x) = the interpolated


approximation to f(x)
ME 261 .. Linear Interpolation

If f1(x) is a linear function with two unknown coefficients A and B


f1 ( x) = Ax + B

To pass through points (x1, f(x1)) and (x2, f(x2)) we must have:
f1 ( x1 ) = f ( x1 )  Ax1 + B = f ( x1 )
f1 ( x2 ) = f ( x2 )  Ax2 + B = f ( x2 )
2 unknowns and 2 equations  Solve for A and B
B = f ( x1 ) − Ax1
Ax2 + f ( x1 ) − Ax2 = f ( x2 )
B

f ( x2 ) − f ( x1 )
A=
x2 − x1
f ( x1 ) x2 − f ( x2 ) x1
B=
x2 − x1
ME 261 .. Linear Interpolation

Now substituting the value for A and B in the approximating


polynomial
( x2 − x) ( x − x1 ) ( x − x2 ) ( x − x1 )
f1 ( x) = f ( x1 ) + f ( x2 ) = f ( x1 ) + f ( x2 )
( x2 − x1 ) ( x2 − x1 ) ( x1 − x2 ) ( x2 − x1 )

This is the formula for linear interpolation.

f ( x2 ) − f ( x1 )
f1 ( x) = f ( x1 ) + ( x − x1 )
x2 − x1
This is Newton’s Divided-Difference first-order interpolating
polynomial.

Question: Derive Newton’s first order interpolating polynomial. Also


derive the Lagrange form from that interpolating polynomial.
ME 261 .. Lagrange Interpolating Polynomial

Linear interpolating polynomial  weighted average of the two


values that are connected by a straight line
f ( x) = L1 f ( x1 ) + L2 f ( x2 )

Where, L’s are the weighing coefficients defined such that it returns
1 at one point and 0 at the other point
x − x2
L1 = 1 at x1 and 0 at x2
x1 − x2
x − x1
L2 = 0 at x1 and 1 at x2
x2 − x1
Substituting these into the interpolating
polynomial x − x2 x − x1
f ( x) = f ( x1 ) + f ( x2 )
x1 − x2 x2 − x1
Linear Lagrange interpolating polynomial
ME 261 .. Lagrange Interpolating Polynomial

Linear Lagrange interpolating polynomial (for first order)


x − x2 x − x1
f1 ( x) = f ( x1 ) + f ( x2 )
x1 − x2 x2 − x1

Second order Lagrange interpolating polynomial => fit a parabola


through three points (x , x , x ) 1 2 3

Weighing coefficients are parabolas giving one passing through one


point and zero for other two.
Now, the weighted average of the three values that are connected by a
unique parabola through the three points:
( x − x2 )( x − x3 ) ( x − x1 )( x − x3 ) ( x − x1 )( x − x2 )
f 2 ( x) = f ( x1 ) + f ( x2 ) + f ( x3 )
( x1 − x2 )( x1 − x3 ) ( x2 − x1 )( x2 − x3 ) ( x3 − x1 )( x3 − x2 )

Second order Lagrange interpolating polynomial


ME 261 .. Lagrange Interpolating Polynomial

For higher order Lagrange polynomial


n
f n−1 ( x) =  Li ( x) f ( xi )
i =1

Where n x − xj
Li ( x) = 
j =1 xi − x j
j i

where n is the number of data points and  designates “the product of”

• The Lagrange interpolating polynomial is simply a


reformulation of the Newton’s polynomial that avoids
the computation of divided differences.
ME 261 .. Numerical Interpolation

Example 01:
Estimate the natural logarithm of 2 using linear interpolation.
First perform the computation by interpolating between ln 1 =
0 and ln 6 = 1.791759. Then, repeat the procedure, but use a
smaller interval from ln 1 to ln 4 (1.386294). Note that the true
value of ln 2 is 0.6931472.
Solution: For linear interpolation,
f ( x2 ) − f ( x1 )
f1 ( x) = f ( x1 ) + ( x − x1 )
x2 − x1
ME 261 .. Numerical Interpolation

Solution: From x1 = 1 to x2 = 6,
f (6) − f (1) 1.791759 − 0
f1 (2) = f (1) + (2 − 1) = 0 + ( 2 − 1) = 0.3583519
6 −1 6 −1
fexact ( 2 ) − f num ( 2 ) 0.6931472 − 0.3583519
Error, t = 100% = 100% = 48.3%
fexact ( 2 ) 0.6931472

From x1 = 1 to x2 = 4,
f (4) − f (1) 1.386294 − 0
f1 (2) = f (1) + (2 − 1) = 0 + ( 2 − 1) = 0.4620981
4 −1 4 −1
Error, εt = 33.3%
ME 261 .. Numerical Interpolation

Two linear interpolations to estimate ln 2. Note how the smaller interval


provides a better estimate.
ME 261 .. Numerical Interpolation

Example 02:
Employ a second-order Newton polynomial to estimate ln 2
with the following three points. Note that the true value of ln 2
is 0.6931472.
x 1 4 6
f(x) 0 1.386294 1.791759
ME 261 .. Numerical Interpolation

Solution: Divided Difference Table


x f(x) First Second
1 0 0.4620981 −0.0518731
4 1.386294 0.2027325
6 1.791759

f2 ( 2) = 0 + 0.4620981( 2 − 1) − 0.0518731( 2 − 1)( 2 − 4 )


= 0.5658444

Error, εt = 18.4%
ME 261 .. Numerical Interpolation

Two linear interpolations to estimate ln 2. The linear interpolation from x


= 1 to 4 is also included for comparison.
ME 261 .. Numerical Interpolation

Example 03:
Employ a third-order Newton’s interpolating polynomial to
estimate ln 2 with the following four points. Note that the true
value of ln 2 is 0.6931472.
x 1 4 5 6
f(x) 0 1.386294 1.609438 1.791759
ME 261 .. Numerical Interpolation

Solution: Divided Difference Table


x f(x) First Second Third
1 0 0.4620981 −0.0597385 0.0078654
4 1.386294 0.223144 −0.0204115
5 1.609438 0.182321
6 1.791759

f3 ( 2 ) = 0 + 0.4620981( 2 − 1) − 0.0597385 ( 2 − 1)( 2 − 4 ) + 0.0078654 ( 2 − 1)( 2 − 4 )( 2 − 5 )


= 0.6287675

Error, εt = 9.3%
ME 261 .. Numerical Interpolation

Two linear interpolations to estimate ln 2.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy