You are on page 1of 32

Chapter 4

INTERPOLATION (1)

Open 1
Learning Objectives

At the end of the chapter, the student will be able to perfom


an interpolation using:

i) Newton’s Interpolating techniques

ii) Lagrange Interpolation techniques

iii) Spline interpolation technique

Open 2
Introduction

In interpolation, we try to fit some type of curve


or function to a subset of the tabular data

That is try to find f(x) for x that is not included in the


data
 In general we solve this type of problem:

Given a set of points (x0, f(x0)), (x1, f(x1)), (x2, f(x2)),... ,


(xn , f(xn )), determine the value f(x) for a given x.

Open 3
Interpolation: to estimate the value of f(x) at a point x
using the given data points

When we fit a polynomial to the data for the purpose of


interpolation, the polynomial is called interpolating
polynomial.

Possible interpolating polynomial.


1. Newton Divided Difference methods/ Newton Interpolating
Polynomials

2. Lagrange Polynomials
Open 4
General form of Newton’s interpolating formula

f n ( x )  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )
 b3 ( x  x0 )( x  x1 )( x  x2 )  ...
 bn ( x  x0 )( x  x1 )...( x  xn 1 )

For an nth order polynomial, (n+1) data points are required

[ x0 , f ( x0 )], [ x1 , f ( x1 )], [ x2 , f ( x2 )],....., [ xn , f ( xn )]

Open 5
General form of Newton’s interpolating formula

Evaluation of the coefficients

b0  f ( x0 )
b1  f [ x1 , x0 ]
Finite divided differences
b2  f [ x2 , x1 , x0 ]....
bn  f [ xn , xn 1, ...., x0 ]

f ( xi )  f ( x j )
f [ xi , x j ]  First Finite divided difference
xi  x j

nth Finite divided differences


f [ xn , xn 1, ....x1 ]  f [ xn 1, ....x1 , x0 ]
Open
f [ xn , xn 1, ....x1 , x0 ]  6

xn  x0
First order/Linear interpolation – for any given two points
f n ( x )  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )
 b3 ( x  x0 )( x  x1 )( x  x2 )  ...
 bn ( x  x0 )( x  x1 )...( x  xn 1 )

When n = 1
f1 ( x)  b0  b1 ( x  x0 )

f ( x1 )  f ( x0 )
b0  f ( x0 ) b1  f [ x1 , x0 ] 
x1  x0

Linear interpolation ( First order interpolation)


f ( x1 )  f ( x0 )
f1 ( x)  f ( x0 )  ( x  x0 )
Open
x1  x0 7
Quadratic interpolation ( second order interpolation)
f n ( x )  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )
 b3 ( x  x0 )( x  x1 )( x  x2 )  ...
 bn ( x  x0 )( x  x1 )...( x  xn 1 )

b0  f ( x0 )
When n = 2
b1  f [ x1 , x0 ]
f [ x2 , x1 ]  f x1, x0 
b2  f [ x2 , x1 , x0 ] 
x2  x0

f 2 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )

Open 8
Estimation of Error for Newton’s polynomial
 error for the nth order polynomial is given by

Rn = f[xn, xn-1, ….,x0] (x – x0) (x – x1)….(x –xn)


or
Rn= fn+1(x) - fn (x)

 in order to reduce the error in the estimated value


of the function at the unknown, data points should
centered around and as close as possible to the
Open
unknown 9
Example 1:

The specific volume of a superheated steam is measured


at various temperatures. At a pressure of 2950 lb/in2, the
data are as follows:

x ( temp in oC ) 700 720 740 760


f(x) (volume) 0.1058 0.1280 0.1462 0.1603

a) Use linear interpolation to estimate the value of f(710)

b) Use quadratic interpolation to estimate the value of f(710)


Open 10
a) Use linear interpolation to estimate the value of f(710) using
the given data points

Since 710 lies between 700 and 720, we used these


two points to interpolate

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

0.1280  0.1058
f1 (710)  0.1058  (710  700)
720  700
 0.1169

x ( temp in oC ) 700 720 740 760


f(x) (volume) 0.1058 0.1280 0.1462 0.1603
Open 11
Data:
x0 = 700, f(x0) = 0.1058 x1 = 720, f(x1) = 0.1280 x2 =740, f(x2) = 0.1462

f 2 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )
f ( x2 )  f ( x1 )
0.1280  0.1058 f [ x2 , x1 ] 
f [ x1 , x0 ]  x2  x1
720  700 0.1462  0.1280

0.0222 740  720
  0.00111
20  9.1 x 10-4

f [ x2 , x1 ]  f [ x1 , x0 ]
divided difference of second f [ x2 , x1 , x0 ] 
order x2  x0

0.00091  0.00111
f [ x2 , x1 , x0 ]   -0.000005
740  700

Open
12
Quadratic interpolation ( second order interpolation)

f 2 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )

where
b0  0.1058
b1  f [ x1 , x0 ]  0.00111
b2  f [ x2 , x1 , x0 ]  0.000005

f 2 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )

f 2 (710)  0.1058  (0.00111)(10)  (0.000005)(10)( 10)


 0.1174

Open 13
In interpolation, the objective is to
determine the value f(x) for a given x, if a set of points
((x0, f(x0 ),(x1, f(x1 ), (x2, f(x2 ),... ,(xn, f(xn )) is given.

Points x0, x1, x2, …., xn must be chosen with reference


to their distance from x .

 in order to reduce the error in the estimated value


of the function at the unknown, data points should
centered around and as close as possible to the
unknown
Open 14
Example 2
Given these points, find f(2.8) using Newton’s interpolating formula of
order 1 through 3. Estimate the error for each prediction

x 1 2 3 4

f(x) 0.234 0.352 0.563 0.684

First need to determine values for x0, x1, x2, …., xn

Find the distance of each point from x


| 4 - x| = |4 - 2.8| = 1.2 | 3 - x| = |3 - 2.8| = 0.2

| 2 - x| = |2 - 2.8| = 0.8 | 1 - x| = |1- 2.8| = 1.8


15

Open
since | 3 - x| is the smallest distance, |2 - x|
is the second smallest and so on, then we
must choose x0 = 3, x1 =2, x2 = 4 and x3 = 1

 therefore x0 = 3, f(x0) = 0.563


x1 = 2, f(x1) = 0.352
x2 = 4, f(x2) = 0.684
and x3 = 1, f(x3) = 0.234

 find f(2.8) using the formula.


Open 16
First order interpolation

f1 ( x)  b0  b1 ( x  x0 )

second order interpolation

f 2 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )

third order interpolation

f 3 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )
 b3 ( x  x0 )( x  x1 )( x  x2 )

Open 17
First order interpolation
b0  f ( x0 )
f1 ( x)  b0  b1 ( x  x0 )
b1  f [ x1 , x0 ]
f1 ( 2.8)  ? b2  f [ x2 , x1 , x0 ]

Second order interpolation b3  f [ x3 , x2, x1 , x0 ]

f 2 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )
f 2 (2.8)  ?
x0 = 3, f(x0) = 0.563
x1 = 2, f(x1) = 0.352
x2 = 4, f(x2) = 0.684
Third order interpolation x3 = 1, f(x3) = 0.234

f 3 ( x)  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )
 b3 ( x  x0 )( x  x1 )( x  x2 )
f 3 ( 2.8)  ?
Open 19
Example 3

The stress data for nine specimens against load are given below:

load 1.9 3.1 4.2 5.1 5.8 6.9 8.1 9.3 100
(kg)
Stress 0.3 0.6 0.4 0.9 0.7 1.1 1.5 1.3 1.6
(ksf)

Estimate the shear stress at a load of 4.5kg using Newton’s


Interpolating polynomials of order 2 and 3.

f 2 (4.5)  0.66131
Open
f 3 (4.5)  0.583788 20
Lagrange Interpolating Polynomials

The Lagrange interpolating equation


for estimating the value of f(x) is
n
f n ( x)   Li ( x) f ( xi )
i 0

 does not make use of the divided differences as


the Newton polynomials.
Open 21
The weights L’s are given by

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

means ‘the product of’

Open 22
n n x  xj
f n ( x)   Li ( x) f ( xi ) Li ( x)  
i 0 j 0 xi  x j
j i

For linear equation, 1


f1 ( x)   Li ( x) f ( xi )
i 0

f1 ( x)  L0 ( x) f ( x0 )  L1 f ( x1 )

( x  x1 ) ( x  x0 )
f1 ( x)  f ( x0 )  f ( x1 )
Open
( x0  x1 ) ( x1  x0 ) 23
Example

 Given (x0, f(x0)), (x1, f(x1)) and (x2, f(x2)),


find f2(x), [ that is n = 2]

 from the Lagrange formula, we have


f2(x) = L0(x)f(x0) + L1(x)f(x1) + L2(x)f(x2),

 where ( x  x1 )( x  x2 )
L0 ( x) 
( x0  x1 )( x0  x2 )
Open 24
( x  x0 )( x  x2 ) ( x  x0 )( x  x1 )
L1 ( x)  L2 ( x) 
( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 )

 substitute these values in the formula earlier.

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

Open 25
Example
Estimate f2(5), given the following table
x 1 3 6
f(x) 5 13 145

Solution
x0 = 1 f(x0) = 5
x1 = 3 f(x1) = 13 f2(5) = ????
x2 = 6 f(x2) = 145
Open 26
Solution - continued

Second order Lagrange interpolating equation


is

f2(x) = L0(x)f(x0) + L1(x)f(x1) + L2(x)f(x2)

= L0(x)(5) + L1(x)(13) +L2(x)(145)

Open 27
Calculate each of the weights

( x  3)( x  6) x 2  9 x  18
L0 ( x)  
(1  3)(1  6) 10

( x  1)( x  6) x2  7x  6
L1 ( x)  
(3  1)(3  6) 6

( x  1)( x  3) x2  4x  3
L2 ( x)  
(6  1)(6  3) 15
Open 28
n
f n ( x)   Li ( x) f ( xi )
Substitute in the formula,
we have i 0

x 2  9 x  18 x2  7x  6 x2  4x  3
 f 2 ( x)  5  13  145
10 6 15

 8 x 2  28 x  25

Hence f 2 (5)  85
Open 29
Given the following data
x -40 -20 10 70 100 120
f(x) 1250 1280 1350 1480 1580 1700

On the basis of the points that you have chosen,


determine f(80) using Lagrange interpolating
polynomials of order 1 through 3.

Open 30
Solution:

x  100 x  70
f1 (80)  ( )(1480)  ( )(1580)
 30 30
 1513. 33

f 2 (80)  1502.7

f 3 (80)  1505.6
Open 31
Exercise:
The percentage of Light (L) passing through the sea surface
that penetrates to specific depths(D) in clean water is as
follows:

D (m) 0 1 2 10 50 100
L(%) 100 45 39 22 5 0.5

Find the value of L at a depth of 1.6m using a Lagrange


interpolation polynomial of order 2.

Open 32
Reading assignment:

1. Coefficient of an interpolating polynomial


2. Inverse Interpolation

Open 33

You might also like