Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
123 views

Lecture Notes 7

The document discusses different methods of interpolation: 1) Linear interpolation uses a straight line between two data points. 2) Quadratic interpolation fits a parabola through three data points using a second-order polynomial. 3) Newton's divided difference method generalizes polynomial interpolation to fit an nth-order polynomial through n+1 data points, where the coefficients are calculated recursively using divided differences.

Uploaded by

Hussain Aldurazy
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views

Lecture Notes 7

The document discusses different methods of interpolation: 1) Linear interpolation uses a straight line between two data points. 2) Quadratic interpolation fits a parabola through three data points using a second-order polynomial. 3) Newton's divided difference method generalizes polynomial interpolation to fit an nth-order polynomial through n+1 data points, where the coefficients are calculated recursively using divided differences.

Uploaded by

Hussain Aldurazy
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

CHAPTER 4

Interpolation and
Approximation

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• Interpolation
• The general formula for an nth-order polynomial is:

f ( x)  a0  a1 x  a2 x 2  ...  an x n

• For n+1 data points, there is one and only one polynomial of nth order
that passes through all the points. For example, there is only one
straight line (that is, a first-order polynomial that connects two points.
Similarly, only one parabola connects a set of three points.

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• Polynomial Interpolation consists of determining the unique nth –order
polynomial that fits n+1 data points. This polynomial then provides a
formula to compute intermediate values.
• Although there is one and only one nth –order polynomial that fits n+1
data points, there are a variety of mathematical formats in which this
polynomial can be expressed. (Newton and Lagrange polynomials)

• Newton’s Divided-Difference Interpolating Polynomials

1.Linear Interpolation: The simplest form of interpolation is to


connect two data points with a straight line. This technique
called linear interpolation, is depicted graphically in following Figure.

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
f(x)

f(x1)
f(x)
f1(x)

f(x0)
x
x0 x x1

• Using similar triangles


f1 ( x)  f ( x0 ) f ( x1 )  f ( x0 )

x  x0 x1  x0

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• which can be rearranged to yield

f ( x1 )  f ( x0 )
f1 ( x)  f ( x0 )  ( x  x0 )
x1  x0

• which is a linear interpolation formula the term [ f ( x1 )  f ( x0 )] / ( x1  x0 )


is the slope of the line connecting the points and known as “ finite-
divided-difference approximation of the first derivative.

• In general, the smaller the interval between the data points, the better
the approximation.

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation

• Example: Estimate the natural logarithm of 2 (ln(2)) using linear


interpolation.
• First perform the computation by interpolating between ln(1)=0 and
ln(6)=1.79176
• Then repeat the procedure but use a smaller interval from ln(1) =0 to
ln(4)=1.3863 2

1.5
• (True value of ln(2)=0.693147)
1

0.5

• Solution: 0

i) x0  1 x1  6
1 2 3 4 5 6
• 1.79176  0
f1 ( x)  0  ( x  1)
f ( x0 )  0 f ( x1 )  1.79176 6 1

1.79176 0.35825  0.693147


f1 (2)  (2  1)  0.35835 t   100%  48.3%
5 0.693147
CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN
Interpolation

• ii) x0  1 x1  4
f1 ( x)  0 
1.3863  0
( x  1)
f ( x0 )  0 f ( x1 )  1.3863 4 1

1.3863 0.4621  0.693147


f1 (2)  (2  1)  0.4621 t   100%  33%
3 0.693147

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• 2. Quadratic Interpolation:
• If three data points are available, this can be accomplished with a
second-order polynomial. A particularly convenient form for this
purpose is:
f 2 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 ) (1)

• If the terms in above equation are multiplied, the equation yields

f 2 ( x)  b0  b1 x  b1 x0  b2 x 2  b2 x0 x1  b2 x0 x  b2 x1 x
• or collecting the terms

f 2 ( x)  a0  a1 x  a2 x 2

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• where
a0  b0  b1 x0  b2 x0 x1
a1  b1  b2 x0  b2 x1
a2  b2
• A simple procedure can be used to determine the values of the
coefficients.
• For b0, Eqn. (1) is used with x=x0

f 2 ( x0 )  b0  b1 ( x0  x0 )  b1 ( x0  x0 )( x0  x1 )
=0 =0
f 2 ( x0 )  b0
and f ( x0 )  f 2 ( x0 ) Therefore b0  f ( x0 ) (2)

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• If we substitute x=x1 into Eqn (1)
f 2 ( x1 )  b0  b1 ( x1  x0 )  b1 ( x1  x0 )( x1  x1 )
=f(x0) =0
f 2 ( x1 )  f ( x0 )  b1 ( x1  x0 )
f ( x1 )  f ( x0 )
and f ( x1 )  f 2 ( x1 ) Therefore b1  (3)
x1  x0

• Finally, Eqs. (2) and (3) can be substituted into Eq.(1), which can be
evaluated at x=x2 and solved ( after some algebraic manipulations) for

f ( x2 )  f ( x1 ) f ( x1 )  f ( x0 )

x2  x1 x1  x0
b2 
x2  x0

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• Example: Fit a second-order polynomial to the three points given
below
x0  1 f ( x0 )  0
x1  4 f ( x1 )  1.38629
x2  6 f ( x2 )  1.79176
• Solution:
b0  0
f ( x1 )  f ( x0 ) 1.38629  0
b1    0.4621
x1  x0 4 1
1.79176  1.38629
 f ( x2 )  f ( x1 ) f ( x1 )  f ( x0 )   0.4621
b2    6  4
 / ( x2  x0 )   0.05187
 x2  x1 x 1  x0  6  1

f 2 ( x )  0  0.462098( x  1)  0.05187( x  1)( x  4)

f 2 ( x )  0.565844
CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN
Interpolation
• 3. General Form of Newton’s Interpolating Polynomials
• The preceding analysis can be generalized to fit an nth order
polynomial to n+1 data points. The nth order polynomial is:
f n ( x)  b0  b1 ( x  x0 )  ...  bn ( x  x0 )( x  x1 )...( x  xn1 )
• b0 , b1, b2, … , bn are first, second, third,…, nth finite divided difference,
respectively. We denote the first divided difference by:
f  x0   f ( x0 )
• The second divided difference by;
f ( x1 )  f ( x0 )
f  x1 , x0  
x1  x0

• And the third divided difference by; f  x2 , x1  


f ( x2 )  f ( x1 )
f  x2 , x1   f  x1 , x0  x2  x1
f  x2 , x1 , x0   where
x2  x0 f ( x1 )  f ( x0 )
f  x1 , x0  
x1  x0

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• Where f[x0], f[x1,x0] and f[x2,x1,x0] are called bracketed functions of
their variables enclosed in square brackets.
• Rewriting;

f n ( x)  f [ x0 ]  f [ x1 , x0 ]( x  x0 )  ...  f [ xn , xn 1 ,..., x0 ]( x  x0 )( x  x1 )...( x  xn 1 )

• The divided differences are calculated recursively;


• For an example of a third order polynomial given (x0,y0), (x1,y1),
(x2,y2), (x3,y3).
f 3 ( x)  f [ x0 ]  f [ x1 , x0 ]( x  x0 )  f [ x2 , x1 , x0 ]( x  x0 )( x  x1 )  f [ x3 , x2 , x1 , x0 ]( x  x0 )( x  x1 )( x  x 2 )
xi 1st divided 2nd divided 3rd divided 4th divided
difference difference difference difference
x0 f(x0) f[x1, x0]
f[x2, x1, x0]
x1 f(x1) f[x2, x1] f[x3, x2, x1, x0]
x2 f(x2)
f[x3, x2] f[x3, x2, x1]
x3 f(x3)
CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN
Interpolation
• Example: Using ln(1), ln(4), ln(6) and ln(5), estimate ln(2) with a
third-order Newton’s Interpolating Polynomial.
xi 1st divided 2nd divided 3rd divided 4th divided f ( x1 )  f ( x0 )
difference difference difference difference f  x1 , x0    0.4621
x1  x0
x0=1 f(x0)=0 0.4621 f ( x2 )  f ( x1 )
-0.0519 f  x2 , x1    0.2027
x1=4 f(x1)=1.386 0.2027 x2  x1
0.0079
x2=6 f(x2)=1.792 f ( x3 )  f ( x2 )
f [ x3 , x2 ]   0.1823
0.1812 -0.0204 x3  x2
x3=5 f(x3)=1.609
f [ x2 , x1 ]  f [ x1 , x0 ] 0.2027  0.4621
f  x2 , x1 , x0     0.0519
x2  x0 6 1
f [ x3 , x2 ]  f [ x2 , x1 ] 0.1812  0.2027
f  x3 , x2 , x1     0.0204
x3  x1 54
f [ x3 , x2 , x1 ]  f [ x2 , x1 , x0 ] 0.0204  (0.0519)
f  x3 , x2 , x1 , x0     0.0079
x3  x0 5 1

f3 ( x)  0  0.4621( x  1)  0.0519( x  1)( x  4)  0.0079( x  1)( x  4)( x  6)


CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN
Interpolation
for x=2  f 3 (2)=0+0.4621(2-1)-0.0519(2-1)(2-4)+0.0079(2-1)(2-4)(2-6)=0.6288

True value=ln(2)=0.69315

0.69315  0.6288
t   0.0929  9.3%
0.69315

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• Lagrange Interpolating Polynomials
• The Lagrange interpolating polynomial is simply a reformulation of the
Newton polynomial that avoids the computation of divided differences.
It can be represented concisely as;
n
f n ( x)   Li ( x) f ( xi )
i 0

 L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  ...  Ln ( x) f ( xn )

• where n x  xj
Li ( x)  
j 0 xi  x j
j i

• where π designates the “product of”. For example, the linear version
(n=1) is:
x  x1 x  x0
f1 ( x)  f ( x0 )  f ( x1 )
x0  x1 x1  x0

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• The second-order version is
( x  x1 )( x  x2 ) ( x  x0 )( x  x2 ) ( x  x0 )( x  x1 )
f 2 ( x)  f ( x0 )  f ( x1 )  f ( x2 )
( x0  x1 )( x0  x2 ) ( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 )

• Example: Use a Lagrange interpolating polynomial of the first and


second order to evaluate ln(2) on the basis of the data given:
xi f(xi)
x0=1 f(x0)=ln(1)=0
x1=4 f(x1)=ln(4)=1.3863
x2=6 f(x2)=ln(6)=1.7918

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN


Interpolation
• The first order polynomial:
f1 ( x)  L0 ( x) f ( x0 )  L1 ( x ) f ( x1 )

x  x1 x  x0
f1 ( x)  f ( x0 )  f ( x1 )
x0  x1 x1  x0
24 2 1
f1 (2)  0  1.3863  0.4621
1 4 4 1
• The second order polynomial
f 2 ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  L2 ( x) f ( x2 )

( x  x1 )( x  x2 ) ( x  x0 )( x  x2 ) ( x  x0 )( x  x1 )
f 2 ( x)  f ( x0 )  f ( x1 )  f ( x2 )
( x0  x1 )( x0  x2 ) ( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 )

(2  4)(2  6) (2  1)(2  6) (2  1)(2  4)


f 2 (2)  0 1.3863  1.7918  0.5658
(1  4)(1  6) (4  6)(4  6) (6  1)(6  4)

CENG 202: NUMERICAL ANALYSIS, DR. SEMIH ERHAN

You might also like