Académique Documents
Professionnel Documents
Culture Documents
(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.
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
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
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
(b − a )
x1 = a − f (a)
f (b) − f ( a )
Repeat the process using appropriate interval.
3. Secant 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.
Solution
-2 2 4 6
-2
-4
The two curves intersect at three points and hence the number of real roots is 3.
4
1 −1.03981
x2 = 1 − (0.16771 ) = 1.03672 ≈ 1.0367
0.16771 − (−0.01411 )
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
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.
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.
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
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.
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
Divided Differences
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.
13
Example 4.1
x: −1 1 2 3 4
f(x) : −7 −1 8 29 68
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)
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.
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.
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.
17