Vous êtes sur la page 1sur 17

Numerical Methods with EXCEL

(Part 1)
Microsoft Excel is a very powerful and widely used spreadsheet. For our Numerical calculations
we shall use Scientific Calculators as well as MS Excel.

Chapter 1: Numbers and Errors


Approximation to Numbers
Decimal places (d.p.): The number of digits counted after the decimal marker.
Significant figures (s.f.): All digits including zero are counted from the first non-zero digit.
Rounding: The last retained digit is corrected up if the succeeding digit is greater than or
equal to 5, otherwise chopped off.
Errors:
Absolute error = True value − Approximate value
True value −Approx. value
Relative error = True value
Percentage of error = Relative error × 100
From the definition, if x = 3.52 (to 2 d.p.), then
3 ⋅ 515 ≤ x < 3 ⋅ 525 or 3.5 2− 12 × 1 0− 2 ≤ x < 3.5 2+ 12 × 1 0− 2
−2
and the absolute error is 1 × 10 .
2

If a number is rounded to n decimal places, the maximum absolute error is 1 × 10− n .


2
Consider two numbers 235.3 and 0.003267 which are rounded to 4 s.f.. The errors can be
estimated as follows
1 × 10− 1 1 × 10− 3
For 235.3, the relative error is 2
2
= 2
< 12 × 10− 3
2.353× 10 2.353
1 × 10− 6 1 × 10− 3
For 0.003267. the relative error is 2
−3
= 2
< 12 × 10− 3
3.267× 10 3.267
If a number is rounded to n significant figures the maximum relative error is
1 × 10− n +1 .
2

Taylor’s Theorem with Remainder


( x − a) 2 ( x − a ) n−1 ( n −1)
f ( x) = f (a ) + ( x − a ) f ′(a ) + f ′′(a ) + ⋅ ⋅ ⋅ + f ( a ) + Rn ( x )
2! ( n −1) !
( x − a) n (n)
where Rn ( x ) = f (c ) , c lies between a and x.
n!
Numerical Calculations using Excel
To calculate mathematical expressions we need to enter formula in the Excel.

Data Entry: There are three types of data that can be entered in a cell.
data types examples descriptions
LABEL Solution text for caption
CONSTANT 3.245 fixed numerical data
FORMULA =2*sin(a2)+2 for calculation
* All formulas MUST begin with an equal sign (=).
* Most of the common functions are available in MS Excel with usual name. The
function name can be typed in either upper or lower case, but Excel displays it in
upper case.
List of functions can be searched by clicking f x  select a category  Select a
function.
Curve Sketching

Select data range.


In the Insert menu, select Chart
In the Chart Wizard, select Char type: XY (Scatter) and Chart sub-type.
Select Finish to complete the diagram.

Example: Calculate f ( x ) = sin −1 x + e −2 / x rounded to 4 d.p. for x = 0.5, 0.75 and 1.0.
C D
4 x f(x)
5 0.5 =round(asin(c5)+exp(-2/c5),4)
6 0.75 ↓
7 1.0

Chapter 2: Solution of Equations in One Variable

Number of Real Roots by Graphical Method


Rewrite the equation f ( x ) = 0 as f1 ( x ) = f 2 ( x) . Then sketch the graph of
y = f1 ( x) and y = f 2 ( x )
Points of intersection indicate the number of real roots of f ( x ) = 0 .

Location of Roots
If f ( x ) is continuous in [ a, b] and f (a ) and f (b) are opposite in signs i.e.
f (a ) f (b) < 0 , then there exists odd number of real roots (at least one root) of f ( x ) = 0 in
(a, b) .

Method of Solution

1. Bisection Method
Let f ( x ) be continuous in [a 0 , b0 ] and f (a 0 ) f (b0 ) < 0 , then an approximation to the
root α of f ( x ) = 0 is
1
x0 = ( a0 + b0 )
2
Repeat the process using appropriate interval.

2. False Position Method/Regula Falsi Method/Linear Approximation

A root α of f ( x ) = 0 in (a, b) may be approximated by the value of the x-intercept of the


line joining the points ( a, f ( a )) and (b, f (b)) .

2
(b − a )
x1 = a − f (a)
f (b) − f ( a )
Repeat the process using appropriate interval.

3. Secant Method

A root near x0 and x1 of f ( x ) = 0 may be approximated by the x-intercept of the secant


line (chord) joining the points ( x0 , f ( x0 )) and ( x1 , f ( x1 )) . The iteration formula of the
root is given by
( xn − xn−1 )
xn+1 = xn − f ( x n ) , n ≥1
f ( xn ) − f ( xn−1 )
4. Newton-Raphson Method

The root of the equation f ( x ) = 0 may be approximated by x-intercept of the tangent line
through a guess value x 0 . The iterative formula for successive iteration is
f ( xn )
x n+ 1 = x n − , n = 0, 1, 2, 3, ⋅ ⋅ ⋅

f ( xn )
For a simple root the convergence of the method is of order two and for a multiple root it is
linear.
For a multiple root the rate of convergence can be increased by the modified Newton-
Raphson formula of the form
f ( xn )
xn+ 1 = x n − m , n = 0, 1, 2, 3, ⋅ ⋅ ⋅

f ( xn )
where m is the multiplicity of the root.

5. Fixed Point Iteration Formula


In order to find a root of the equation f ( x ) = 0 by iteration, rearrange the equation into a
form x = g ( x). The iteration formula is then
xn+ 1 = g ( xn ) , n = 0, 1, 2, 3, ⋅ ⋅ ⋅
If x0 is an approximation close to a root of f ( x ) = 0 and x n +1 = g ( x n ) is an iterative
formula used to find a root of the equation near x0, then
(i) if g ′( x0 ) <1 the sequence x1 , x2 , x3 , ⋅ ⋅ ⋅ will converge to the root.
In particular,
(a) if − 1 < g ′( x0 ) < 0 , then the sequence will oscillate and converge to the root.
(b) if 0 < g ′( x0 ) < 1 , then the sequence will converge to the root without oscillation.
(ii) if g ′( x0 ) ≥1 the sequence x1 , x2 , x3 , ⋅ ⋅ ⋅ will diverge.
Example 2.1

Given that f ( x) = 2 cos 2 x + 2 − x .


(a) Find the number of real roots of the equation f ( x ) = 0 .
(b) Show that the equation f ( x ) = 0 has a root in (0.8, 1.6) .
3
Use Bisection method twice to find the new smaller interval where the root lies.
Apply false position (Regula Falsi) method in the interval obtained by the Bisection method to
estimate this root correct to 4 decimal places.
(c) Use Secant method twice to estimate the root of f ( x) = 0 to 5 decimal places with
starting values x0 = 3.3 and x1 = 3.5 . Show also that the root is correct to 5 d.p.
(d) The equation f ( x) = 0 has a root in the interval (2.4, 2.6) . Use Newton-Raphson
formula to estimate this root correct to 5 decimal places with a suitable starting value.
(e) An iterative formula x n +1 = (1 − k ) x n + 2k (1 + cos 2 xn ) can be used to estimate the root of
f ( x) = 0 . Find the range of values of k for which the iterative formula will converge to
the root near 3.6 .
Use this iterative formula with a suitable value of k to estimate the root correct to 3 decimal
places.

Solution

(a) The equation f ( x ) = 0 i.e. 2 cos 2 x + 2 − x = 0 can be written as


2 cos 2 x = x − 2
consider the graphs of y = 2 cos 2 x and y = x − 2 .
4
2

-2 2 4 6
-2
-4

The two curves intersect at three points and hence the number of real roots is 3.

(b) It can be seen that


f (0.8) =1.142
f (1.6) = −1.596
Here f (0.8) f (1.6) < 0 . Thus a root lies in (0.8, 1.6) .
Applying Bisection method on (0.8, 1.6) , we have
0.8 +1.6
x1 = = 1.2
2
Now f (1.2) = −0.675 and f (0.8) =1.142 .
The root lies in (0.8, 1.2) .
Applying Bisection method on (0.8, 1.2) , we have
0.8 +1.2
x2 = = 1.0
2
Now f (1.0) = 0.16771 and. f (1.2) = −0.67479
The root lies in (1.0, 1.2) .

Now applying false position method on (1,1.2) , we have


1 −1.2
x1 = 1 − (0.16771 ) = 1.03981 ≈ 1.0398
0.16771 − ( −0.67479 )
Now f (1.03981 ) = −0.01411
and f (1) = 0.16771 as the root lies in (1, 1.0367)
Using false position method again

4
1 −1.03981
x2 = 1 − (0.16771 ) = 1.03672 ≈ 1.0367
0.16771 − (−0.01411 )

Again f (1.03672 ) = −0.00021


f (1) = 0.16771
1 −1.03672
and hence x3 = 1 − (0.16771 ) = 1.03667 ≈ 1.0367
0.16771 − ( −0.00021 )
Thus x2 and x3 are same to 4 d.p. Hence the root correct to 4 d.p. is 1.0367.

(c) Given starting values for Secant method is


x 0 = 3.3 and x1 = 3.5
and f (3.3) = 0.600465 and f (3.5) = 0.007805
Using Secant formula
3.5 − 3.3
x2 = 3.5 − × (0.007805 ) = 3.502634
0.007805 − 0.600465
Now f (3.502634 ) = −0.001772 .
Repeating the calculation with
x1 = 3.5 and x2 = 3.502634
we have
3.502634 − 3.5
x3 = 3.502634 − × (−0.001772 ) = 3.502147
− 0.001772 − 0.007805
After 2nd iteration, root to 5 d.p. is 3.50215 .
Similarly next iter5ation gives
x4 = 3.502147 ≈ 3.50215
Comparing x3 and x4 we can conclude that the root is correct to 5 decimal places.
Alternative if x2 ≈ 3.50215 is correct to 5 d.p. then
x2 = x3.50215± 1 × 10− 5
2
3.502145 ≤ x x ≤ 3.502155
But f (3.502145 ) =8.71 ×10 −6 and f (3.502155 ) =8.71 ×10 −5 .
Hence the root is correct to 5 decimal places.

(d) When Newton-Raphson method applied to the equation, we have


f ( x ) = 2 cos 2 x + 2 − x
f ′( x) = −4 sin 2 x − 1
Here f ( 2.4) = −0.225 and f ( 2.6) = 0.337 and we may take a starting value x0 = 2.5 .
Using Newton-Raphson formula we may proceed as follows:
x0 = 2.5
f ( x0 ) = f ( 2.5) = 0.067324
f ′( x0 ) = f ′(2.5) = 2.835697
f ( x0 ) 0.067324
x1 = x0 − = 2.5 − = 2.476258 ≈ 2.47626
f ′( x0 ) 2.835697
f ( x1 ) − 0.000607
x 2 = x1 − = 2.476258 − = 2.476468 ≈ 2.47647
f ′( x1 ) 2.885231
f ( x2 ) − 1.36 ×10 −7
x3 = x 2 − = 2.476468 − = 2.476468 ≈ 2.47647
f ′( x 2 ) 2.884831
The root correct to 5 d.p. is 2.47647.
5
(e) In this case the iterative function g ( x) is given by
g ( x ) = (1 − k ) x + 2k (1 + cos 2 x )
g ′( x ) = 1 − k − 4k sin 2 x
and g ′(3.6) = 1 − 4.175 k
The iterative formula will converge to the root near 3.6 if
g ′(3.6) <1 or 1 −4.175 k <1
−1 < 1 − 4.175 k < 1
− 2 < −4.175 k < 0 (adding −1 to each expression)
2 > 4.175 k > 0 (multiplying by −1 )
0.4896 > k > 0 (dividing by 4.175)
which gives the range of values of k.
A suitable choice of k is
1
1 − 4.175 k ≈ 0 which gives k = = 0.2395 ≈ 0.24 .
4.175
With k = 0.24 , the iteration formula becomes
x n +1 = 1 − 0.24 ) x n + 2(0.24 )(1 + cos 2 x n ) = 0.76 x n + 0.48 (1 + cos 2 x n )
With x0 = 3.6 , the successive iterates are given below:
n xn xn (to 4 d.p.)
0 3.6 3.6000
1 3.50801 3.5080
2 3.50286 3.5029
3 3.50224 3.5022
4 3.50216 3.5022

The root correct to 4 d.p. is 3.5022.

6
Chapter 3: Solution of System of Linear Equations
We shall consider the following techniques which are suitable for numerical solution of linear
system.
1 Gaussian Elimination with Partial Pivoting

(a) Select pivotal equation for a variable for elimination (the equation with maximum
numerical coefficient of that variable in the system).
(b) Eliminate the chosen variable from the remaining equations with respect to the pivotal
equation.
(c) Repeat the process for the subsystem.
(d) Using back-substitution find solutions by using pivotal equations.

Example 3.1
Solve the following linear system by the Gaussian elimination with partial pivoting, giving your
answers to 3 decimal places.
5 x +12 y + 9 z = 5, 8 x +11 y + 20 z = 35 , 16 x + 5 y + 7 z = 29
Taking first equation as the pivotal equation we can write the system as
Opration Coefficient of R. H. Eq. # Check
x y z S. Sum
16 5 7 29 Eq1* 57
5 12 9 5 Eq2 31
8 11 20 35 Eq3 74
Eq1/16 1 0.312 0.4375 1.8125 Eq4* 3.5625
Eq2/5 1 5 1.8000 1.0000 Eq5 6.2000
Eq3/8 1 2.400 2.5000 4.3750 Eq6 9.2500
0
1.375
0
Eq5−Eq4 2.087 1.3625 −0.8125 Eq7** 2.6375
Eq6−Eq4 5 2.0625 2.5625 Eq8 5.6875
1.062
5
Eq7/2.0875 1 0.6527 −0.3892 Eq9** 1.2635
Eq8/1.0625 1 1.9412 2.4118 Eq10 5.3530
Eq10−Eq9 1.2885 2.8010 Eq11 4.0895
Eq11/1.2685 1 2.1738 Eq12 3.1778

Solution of the system is obtained by the back substitution as follows:


From (Eq12) z == 2.1738
From (Eq9) y = −0.3892 − 0.6527 ×2.1738 = −1.8080
From (Eq4) x =1.8124 − 0.3125 ×( −1.8080 ) − 0.4375 × 2.1738 =1.4264
Note: To check the calculations an extra column headed by check sum is included which is the
sum of the numbers in the row. It is also worked out in exactly the same way as the other
numbers in the line.

2. Matrix Factorization Method

7
In this method the coefficient matrix A is decomposed into the product of a lower triangular
matrix L and an upper triangular matrix U.
A=LU
The system of equations becomes
LUX=B
We rewrite this system as
UX=Z
LZ=B
We first solve for Z using forward substitution and then find X using the back substitution.

In practice we use one of the following alternatives to get unique factorization:


(a) Crout’s formalism: All the diagonal elements of U is choesen 1.
(b) Dolittle’s formalism: All the diagonal elements of L is choesen 1.

 1 2 3  5  x
     
Example 3.2: Given that A =
3 4 1 1 , B=
 2 1 , X=
 y
 5 1 41  2  1 5  z
     
(i) Determine a lower triangular matrix L and an upper triangular matrix U such that L U = A.
(ii) Use the above factorization to solve the equation A X = B.

 a 00  1 ml 
 1 2 3
    
Solution: (i) Let A=
3 4 1 1 =LU=

 5 1 41  2
 db 0  10 n
   fec   100 
  
8
 a al am 
 
=
 b bl + d b m + d n 
 c cl + e cm + en + f 
 
Equating the corresponding elements of the two matrices, we have
a =1
b =3
c =5
2
a l =2 or l= =2
1
a m =3 or m =3
b l +d = 4 or d = 4 − 3( 2) = −2
c l +e =14 or e =14 −5( 2) = 4
1
b m + d n =11 or n= (11 − 3(3) ) = −1
−2
c m + e n + f =12 or f =12 −5(3) −4( −1) =1
Thus

1 0 0  1 2 3
   
L=
3 − 2 0 U=
 0 1 − 1
5 4 1   0 0 1
  
(ii) The equation can be written as
AX = LUX = LY = B
where

 y1 
 
UX = Y and Y=
 y2 
y 
 3
9
Consider the solution of
LY = B

1 0 0   y1   5
    
or
3 − 2 0  y2  =
 2 1
5 4 1   y3   1 5
  
Using forward elimination, we have
y1 = 5, y 2 = −3, y3 = 2
Now consider the solution of
UX = Y

 1 2 3  x   5 
    
or
 0 1 − 1   y   − 3 =

 0 0 1  z   2 
    
Using backward elimination, we have
x =1, y = −1, z =2
and hence

 1
 
X=
 − 1
 2
 
3. Iterative Method

Iterative method for linear system is similar as the method of fixed-point iteration for an equation
in one variable. To solve a linear system by iteration, we solve each equation for one of the
variables, in turn, in terms of the other variables.

10
An iterative method converges, for any choice of the first approximation, if every equation
satisfies the condition that the magnitude of the coefficient of solving variable is greater than the
sum of the absolute values of the coefficients of the other variables. A system satisfying this
condition is called diagonally dominant. A linear system can always be reduced to diagonally
dominant form by elementary operations.

(a) Jacobi’s Method


Starting with an initial set of values, if not given, derive a new set of solution.
Repeat the calculations till the required accuracy is obtained.

(b) Gauss-Seidel Method


Start with initial values and update the value of variables in each calculation.

Example 3.3
Use three-digit rounding arithmetic to solve the following system byGauss-Seidel iteration
method.
12 x − 2 y + 5 z = 20 , 4 x + 5 y +11 z = 8, 7 x +12 y +10 z = 27

Without changing the order of the equations, we have


12 x − 2 y + 5 z = 20 (E1) 12 > −2 +5 for x
4 x + 5 y +11 z = 8 (E2) 5 <4 +11 for y
7 x +12 y +10 z = 27 (E3) 10 < 7 +12 for z
and is not diagonally dominant.

Arranging the system as (E1), (E3) − (E2), (E2), we have

12 x − 2 y + 5 z = 20 12 > −2 +5
3 x + 7 y − z = 19 7 > 3 +−1
4 x + 5 y +11 z = 8 11 > 4 +5
The system reduces to diagonally dominant form.

The Gauss-Seidel iterative formulas of the above system are


xn + 1 = 1 ( 2 0 + 2 y n − 5 z n )
12
y n + 1 = 1 ( 19 − 3xn + 1 + z n )
7
z n + 1 = 1 ( 8 − 4 xn + 1 − 5 yn + 1 )
11

Starting with initial values


x0 = 0, y 0 = 0, z 0 = 0
we get the solutions as follows:
First approximation:
x1 = 1 [20 + 0 + 0] = 1.67
12
y1 = 1 [19 − 3(1.67) + 0] = 2.00
7
z1 = 1 [8 − 4(1.67) − 5(2)] = − 0.79
11

11
Second approximation:
x 2 = 1 [20 + 2(2.00) − 5(− 0.79)] = 2.33
12
y 2 = 1 [19 − 3(2.33) − 0.79] = 1.60
7
z 2 = 1 [8 − 4(2.33) − 5(1.60] = − 0.89
11
Third approximation:
x3 = 1 [20 + 2(1.60) − 5(− 0.85)] = 2.29
12
y3 = 1 [19 − 3(2.29) − 0.85] = 1.61
7
z3 = 1 [8 − 4(2.29) − 5(1.61] = − 0.84
11
Fourth approximation:
x 4 = 1 [20 + 2(1.61) − 5(− 0.84)] = 2.29
12
y 4 = 1 [19 − 3(2.29) − 0.84] = 1.61
7
z 4 = 1 [8 − 4(2.29) − 5(1.61] = − 0.84
11
which gives the results correct to 2 d.p.

It can be observed that the Gauss-Seidel method converges twice as fast as the Jacobi method.
Chapter 4: Interpolation and Finite Differences

Polynomial Interpolation

Given the values of a function f(x) at (n+1) distinct points x0 , x1 , x 2 , ⋅⋅⋅, x n we can
construct a unique polynomial of degree less than equal to n which satisfies the conditions
p ( xi ) = f ( xi ), i = 0, 1, 2, 3, ⋅ ⋅ ⋅, n
General Form
An nth degree polynomial can be taken as
p ( x) = a 0 + a1 x + a 2 x 2 + a3 x 3 +⋅⋅⋅ + a n x n
To fit this polynomial to (n+1) set of points we have to solve (n+1) simultaneous equations
and is very tedious.

Newton Form

A form which is convenient to use is suggested by Newton is


p ( x ) = a 0 + a1 ( x − x0 ) + a 2 ( x − x0 )( x − x1 ) +⋅⋅⋅ + a n ( x − x0 )( x − x1 ) ⋅ ⋅ ⋅ ( x − x n −1 )

Divided Differences

Divided differences are defined as follows:


f [ x0 ] = f ( x0 )

12
f [ x1 ] − f [ x0 ]
f [ x0 , x1 ] =
x1 − x0
f [ x1 , x 2 ] − f [ x0 , x1 ]
f [ x0 , x1 , x3 ] =
x 2 − x0
………………………………………………………..
f [ x1 , x 2 ,  , x n ] − f [ x0 , x1 ,  , x n −1 ]
f [ x0 , x1 , x3 ,  , x n ] =
x n − x0
Note that divided differences are symmetric about their arguments.

Newton Interpolation Formula

In terms of the divided differences interpolating polynomial can be written as


p( x ) = f [ x 0 ] + f [ x 0 , x1 ]( x − x 0 ) + f [ x 0 , x1 , x 2 ]( x − x 0 )( x − x1 ) +
+ f [ x0 , x1 , x 2 ,  , x n ]( x − x0 )( x − x1 )  ( x − x n −1 )

13
Example 4.1

The table below gives the values of x and f(x):

x: −1 1 2 3 4
f(x) : −7 −1 8 29 68

(i) Construct a divided-difference table for the above data.


(ii) Find the polynomial of least degree that incorporates the values in the table and find
f (5) .
(iii) Find by linear interpolation a real root of f ( x ) = 0 .
(iv) Find the polynomial g ( x) that takes the values of the above table and g (5) = 203 .

Solution:
(i) The divided difference table for the given data is as follows:
x f(x) f1[ ] f2[ ] f3[ ] f4[ ]
-1 -7
1 -1 3
2 8 9 2
3 29 21 6 1
4 68 39 9 1 0

(ii) The needed differences are enclosed by the double lined box.
By Newton’s divided difference formula, we get
f ( x ) = −7 +3( x +1) +2( x +1)( x −1) +1( x +1)( x −1)( x −2)
and f (5) = −7 +3(6) +2(6)( 4) +1(6)( 4)( 3)
= −7 +18 + 48 + 72 = 131
(iii) Here f (1) f ( 2) = ( −1)( 8) = −8 < 0
Thus a root is in (1, 2).
From the table, we have
x f(x) 1DD
1 −1
2 8 9
Thus the root is the solution of
f ( x ) = −1 +9( x −1) = 0

or x = 1 + 19 ≈ 1.111
(iv) The polynomial g ( x) can be written as
g ( x ) = f ( x ) +b( x +1)( x −1)( x −2)( x −3)( x −4)
where b is a constant.
Taking x = 5 , we have
g (5) = f (5) +b(6)( 4)( 3)( 2)(1)
or 203 = 131 +144 b
203 −131 72 1
Hence b= = =
144 144 2
The required polynomial is
g ( x) = f ( x) + 12 ( x + 1)(x − 1)(x − 2)(x − 3)(x − 4)

Finite Difference Operators


14
Assume that the tabular points x0 , x1 , x 2 , ⋅⋅⋅, x n are equispaced, that is
x r = x0 + rh, r = 0,1,2,  , n
with step size h. We define
Shift Operator: Εf ( x r ) = f ( x r + h)
Forward Difference Operator: ∆f ( x r ) = f ( x r + h) − f ( x r )
Backward Difference Operator: ∇f ( x r ) = f ( x r ) − f ( x r − h)
Central Difference Operator: δ f ( xr ) = f ( xr + h2 ) − f ( xr − h2 )
Averaging Operator: µ f ( xr ) = f ( xr + h2 ) + f ( xr − h2 )

Repeated applications of the difference operators give the following higher order differences:
Εn f ( x r ) = f ( x r + nh )
∆n f ( x r ) = ∆n −1 f r +1 − ∆n −1 f r
∇n f ( x r ) = ∇n −1 f r +1 − ∇n −1 f r
where f r = f ( x r ) .
We also have
1 1
f [ x 0 , x1 , x 2 ,  , x k ] = k
∆k f 0 = ∇k f k
k !h k !h k
Newton-Gregory Forward Difference Interpolation
Replacing the divided differences in the Newton interpolation formula by the forward
differences, we have
( x − x0 ) ( x − x0 )( x − x1 ) 2 ( x − x0 )( x − x1 )  ( x − x n−1 ) n
p ( x) = f 0 + ∆f 0 + 2
∆ f 0 + + ∆ f0
h 2!h n !h n
x − x0 x − x1
Substituting s= , we have = s − 1 and so on
h h
The above interpolation formula becomes
s ( s −1) 2 s ( s −1)( s − 2)  ( s − n +1) n
p ( x) = f 0 + s∆f 0 + ∆ f 0 + + ∆ f0
2! n!
x − x0
where s = .
h
Newton-Gregory Backward Difference Interpolation
Replacing the divided differences in the Newton interpolation formula by the backward
differences, we have
( x − xn ) ( x − xn )( x − xn−1 ) 2 ( x − xn )( x − xn−11 )  ( x − x1 ) n
p( x) = f n + ∇f n + 2
∇ fn + + ∇ fn
h 2!h n !h n
x − xn x − xn−1
Substituting u = , we have = u + 1 and so on
h h
The above interpolation formula becomes
u (u +1) 2 u (u +1)( u + 2)  (u + n −1) n
p ( x ) = f n + u∇f n + ∇ f n + + ∇ fn
2! n!
where u = ( x − xn ) / h .

15
Example 4.2
The following are the number of deaths in five successive ten years age groups. Find the number
of deaths for the age group 31 – 45 and exactly at the age of 60.

Age group 21 - 30 31 – 40 41 – 50 51 - 60
Deaths 17.4 21.5 26.7 32.3
(in thousand

Solution
Data is given in groups and hence it cannot be fitted with a polynomial directly. Consider the
cumulative frequency and then construct the difference table.

Age less than No. of deaths


x f(x) ∆f ∆2
f ∆3
f
(years) (in thousands)
31 17.4
41 38.9 21.5
51 65.6 26.7 5.2
61 97.9 32.3 5.6 0.4

The interpolated polynomial is


f ( x ) ≈17 .4 +21 .5 s +
5.2
s ( s −1) +
0.4
s ( s −1)( s −2)
x − 31
2! 3!
where s =
10
The number of deaths for the age group 31 – 45 = f ( 46 ) − f (31 )
46 − 31
For x = 46 , s = = 1.5 and
10
5.2 0.4
f ( 46 ) =17 .4 + 21 .5(1.5) + (1.5)( 0.5) + (1.5)( 0.5)( −0.5) =51.569
2 6
The number of deaths for the age group 31 – 45 = 51.569 − 17.4 = 34.169 thousands.

The number of deaths at the age of 60 can be estimated from f (61 ) − f (60 ).
60 − 31
For x = 60 , s = = 2.9 and
10
5. 2 0.4
f (60 ) =17 .4 + 21 .5( 2.9) + (2.9)(1.9) + ( 2.9)(1.9)( 0.9) =
2 6
The number of deaths at the age 60 = 97.9 – 94.407 = 3.493 thousands.

Lagrange Interpolating Polynomial

Lagrange polynomial of degree one passing through two points ( x0 , y 0 ) and ( x1 , y1 ) is


written as
x − x1 x − x0
L1 ( x ) = y0 + y1
x0 − x1 x1 − x0
Lagrange polynomial of degree two passing through three points ( x0 , y 0 ) , ( x1 , y1 ) and
( x 2 , y 2 ) is written as
( x − x1 )( x − x2 ) ( x − x0 )( x − x2 ) ( x − x0 )( x − x1 )
L2 ( x) = y0 + y1 + y2
( x0 − x1 )( x0 − x2 ) ( x1 − x0 )( x1 − x2 ) ( x2 − x0 )( x2 − x1 )

16
Lagrange polynomial of degree three passing through four points ( x0 , y 0 ) , ( x1 , y1 ) ,
( x 2 , y 2 ) and ( x3 , y 3 ) is written as
( x − x1 )( x − x2 )( x − x3 ) ( x − x0 )( x − x2 )( x − x3 )
L3 ( x ) = y0 + y1
( x0 − x1 )( x0 − x2 )( x0 − x3 ) ( x1 − x0 )( x1 − x2 )( x1 − x3 )
( x − x0 )( x − x1 )( x − x3 ) ( x − x0 )( x − x1 )( x − x2 )
+ y2 + y3
( x2 − x0 )( x2 − x1 )( x2 − x3 ) ( x3 − x0 )( x3 − x1 )( x3 − x2 )
Similar for higher degree polynomials.

Example 4.3
The following table gives the values of an empirical function f(x) for certain values of x.
x 0 1 2 3
f(x) −4 −1 8 29
Use the Lagrange interpolation formula to estimate
(i) the value of f ( 2.5)
(ii) the root of the equation f(x) = 0 to 3 decimal places.

(i) Applying Lagrange’s formula, we have


( x −1)( x −2)( x −3) ( x −0)( x − 2)( x −3)
f ( x) = −4 −1
(0 −1)( 0 −2)( 0 −3) (1 −0)(1 − 2)(1 −3)
( x −0)( x −1)( x −3) ( x −0)( x −1)( x − 2)
+8 + 29
( 2 −0)( 2 −1)( 2 −3) (3 −0)( 3 −1)( 3 − 2)
(1.5)( 0.5)( −0.5) ( 2.5)( 0.5)( −0.5)
and f ( 2.5) =−4 −1
( −1)( −2)( −3) (1)( −1)( −2)
( 2.5)(1.5)( −0.5) ( 2.5)(1.5)( 0.5)
+8 +29
( 2)(1)( −1) (3)( 2)(1)
= −0.25 + 0.3125 + 7.5 + 9.0625
=16 .625
(ii) Let y = f (x) . Then the root of f ( x ) = 0 corresponds to y =0 . To find the root let us use
the Lagrange formula in reverse order i.e. consider the polynomial in terms of y.
y −4 −1 8 29
x 0 1 2 3
Then
( y + 4)( y −8)( y − 29 ) ( y + 4)( y +1)( y − 29 ) ( y + 4)( y +1)( y −8)
x = 0 +1 +2 +3
( −1 + 4)( −1 −8)( −1 − 29 ) (8 + 4)( 8 +1)( 8 − 29 ) ( 29 + 4)( 29 +1)( 29 −8)
When y =0 , then
( 4)( −8)( −29 ) ( 4)(1)( −29 ) ( 4)(1)( −8)
x = 0 +1 +2 +3
(3)( −9)( −30 ) (12 )( 9)( −21 ) (33 )( 30 )( 21 )
= 1.1457 + 0.1023 − 0.0046
=1.2434
Thus a root of the equation f ( x ) = 0 to 3 d.p. is 1.243 .

17

Vous aimerez peut-être aussi