Numerical Analysis
Numerical Analysis
Error in addition:
Let A and B are two inequalities to be added with ∆ A∧∆ B as errors in A and B respectively.
R+ ∆ R=( A+ ∆ A ) +( B+ ∆ B)
¿( A +B)+(∆ A+ ∆ B)
Error in multiplication:
Let R = A . B
R+ ∆ R=( A+ ∆ A ) (B+∆ B)
¿ AB+ A ∆ B +B ∆ AB+ ∆ A . ∆ B
∆ R= A ∆ B+ B ∆ AB+ ∆ A . ∆ B
Assumption:
If ∆ A and ∆ B is small relative to A and B respectively then ∆ A . ∆ B is extremely very small relative to
A.B and can therefore be ignored.
So, ∆ R= A ∆ B+ B ∆ A
Relative error:
∆ R ∆ A ∆B
= +
R A B
Error in quotient:
A
Let R=
B
A +∆ A B−∆ B
R+ ∆ R= .
B+∆ B B−∆ B
AB−A ∆ B+ B ∆ A−∆ A . ∆ B
¿ 2
B
AB A ∆ B B ∆ A
¿ 2
− 2 + 2
B B B
−A ∆ B B ∆ A
∆ R= 2
+ 2
B B
∆ R −A ∆ B B B ∆ A B
= . + 2 .
R B
2
A B A
∆ R −∆ B ∆ A
= +
R B A
Examples:
Given X= 2.2255, Y= 0.449, correct to the given number of decimal places. State the maximum
possible errors in the values of X and Y. Hence determine;
(i) The absolute error
X
(ii) The limit within which the value of the quotient lies giving your answer to 2 dps.
Y
Solution:
(i)
X ∆ X X ∆Y
Error in = − .
Y Y Y Y
= -0.005408
min ( YX )≤ YX ≤ max ( YX )
X
4.95 ≤ ≤ 4.96
Y
Example:
(a) Given that x=2.5 , y=14.2∧z=8.1 all values given correct to 2 dps. Find the maximum values of;
x+ y x− y 1 1 1
(i) 2 (ii) (iii) + −
z z x y z
(b) Two decimal numbers x∧ y are rounded off to give X ∧Y with errors E1∧E 2 respectively. Show
Solution:
(a)
x+ y max ( x )+ max ( y )
(i) Max =
min ( z 2 )
2
z
2.55+14.25
=
( 8.05 )2
= 0.259
x− y max ( x )−min ( y )
(ii) Max =
z min ( z )
2.55−14.15
=
8.05
= -1.441
Example:
FORMULATE QUESTION:
Solution:
Alternatively;
1
Error bound = (Max . Value−Min .Value)
2
1
= ( 9.647134783−9.644382923 )=0.00137593
2
Exercise:
1. Given that x=3.57 , y=−4.291∧z =6.7955 are rounded off to the given decimal places
indicated.
x
(ii) Find the limits within which the exact value of the expression, lies.
y−z
15.36+27.1−1.672
2. (a) Determine the approximate values between which lies,
2.36 ×1.043
assuming the maximum possible error in each of the figures.
3. If the error in each of the values of 2 x and 2−x is ± 0.005. find the exact value of the
x
2
quotient −x , when x=0.40 , giving your answer correct to 3 decimal places.
2
ESTIMATION OF ROOTS:
Newton-Raphson method: y
X n can be considered to be
root x . Q ( xr , yr )
NQ=f ( x r ) α
NQ NQ
=tan α → RN = O P ( x ,0 ) Q( x r +1 , 0 )N x
RN tan α
f ( xr )
¿=ON – RN →∨¿ x r − '
f ( xr )
f ( xr )
x r +1=x r−
f ' ( xr )
Example:
Using the Newton- Raphson formula, find the root of the equation
3
X −2 X−5=0
Solution:
f ( X n)
Newton-Raphson formula is given by X n+1=X n− '
f ( Xn)
' 2
Now,
3
f (X n )=X n −2 X n−5 and f ( X n )=3 X n −2
( X n3−2 X n−5 )
So, X n+1=X n−
3 X n2−2
3 3
3 X n −2 X n− X n +2 X n +5
= 2
3 X n −2
3
2 X n +5
= 2
3 X n −2
Let x 0=2
n Xn X n+1 | X n+1− X n|
0 2 2.1 0.1
1 2.1 2.094 0.0054
2 2.094 2.094 0.0000
Root of equation is 2.09 (2dps)
Example:
(a) Show that the Newton-Raphson iterative formula for finding the cube root of any
number N is given by
X n+1=
1
3 (N
)
2 X n + 2 ; n=0 , 1 , 2, … … … … … …
Xn
1
Use the iterative formula to find 96 3 correct to 3 decimal places.
(b) Show that the equation 3 X 3 + X −5=0 has a real root between X=1 and X=2.
Using the Newton-Raphson formula thrice, find the value of his root correct to 2 d.p.
Solution:
1
(a) Let X =N 3
3
X −N=0
3 ' 2
Now, f ( X n )= X n −N and f ( X n )=3 X n
f ( X n)
Using X n+1=X n− '
f ( Xn)
( X n3−N )
= X n−
3 X n2
3 3
3 X n −X n + N
= 2
3 Xn
3
2 Xn + N 2 1 N
= 2 = 3 . Xn+ 3 . 2
3 Xn Xn
X n+1=
1
3 ( N
2 Xn+ 2
Xn )
Let x 0=5 , N=96
n Xn X n+1 | X n+1− X n|
0 5 4.613 0.3867
1 4.613 4.5791 0.0339
2 4.5791 4.5789 0.0002
3 4.5789 4.5789 0.0000
1
Therefore, 96 3 =4.579(3 d . p)
The function changes sign, from negative (-) to positive (+) between x=1∧x =2.
This implies that the real root of the function f ( x )=3 x 3 + x−5 lies between the two
x-values.
Example:
FORMULATE QUESTION
Solution:
−3
(i) a=23.037 ; error ∈a ( e1 )=±0.5 × 10 =± 0.0005
−4
b=8.4658 ; error ∈b ( e 2 )=± 0.5 ×10 =± 0.00005
a
(ii) Absolute error in
b
Absolute error ¿
|e 1| |e 2|
+
a b
0.0005 0.00005
¿ +
23.037 8.4658
¿ 0.0000276
min ( ba )= max
min a 23.0365
=
b 8.46585
=2.7211
a
Range is given by: 2.7211< <2.7213
b
Example:
FORMULATE QUESTION:
Solution:
' x
Let (x n )=e −2 x n−1 , f ( x n )=e −2
x n n
f ( X n)
From; X n+1=X n− '
f ( Xn)
( e x −2 x n−1 )
n
¿ X n−
e x −2
n
xn
e ( X n−1 ) +1
¿ xn
e −2
n Xn X n+1 | X n+1 −X n|
0 1.000 1.389 0.389
1 1.389 1.271 0.108
2 1.271 1.259 0.012
3 1.259 1.256 0.003
4 1.256 1.256 0.000
xn
Root of equation e −2 x n−1=0 is x=1.256
Example:
FORMULATE QUESTION:
Solution
¿ X ∆ Y +Y ∆ X +∆ X ∆ Y ; Neglect error in ∆ X ∆ Y
¿ X ∆ Y +Y ∆ X
X ∆ Y +Y ∆ X ∆ X ∆ Y
Relative error: = +
XY X Y
[| | | |]
∆ X ∆Y
X
+
Y
×100 %
Exercise:
1. By plotting graphs of y=e x and y=− x+ 4 on the same co-ordinate axes, estimate the
only real root of the equation e x + x−4=0 correct to one decimal place.
2. (a) Show that the equation x=ln ( 8−x ) has a root between x=1 and x=2.
(b) Use the Newton- Raphson method to find the root of the equation correct to 2
dp.
3. (a) Given two iterative formulae I and II for calculating the positive root of the
quadratic equation f(x) = 0 as:
I II
[ ]
2
1 1 X n +1
X n+1= ( X 2−1 )
2 n
X n+1=
2 X n−1
For n = 1, 2, 3, ….
Taking X 0=2.5, use each formula thrice to 2 dps to decide which is the more suitable
formula. Give a reason for your answer.
(b) If α is an approximate root of the equation X 3 =n, show that the iterative
formula for finding the root reduces to
n
+α
α
2
4. (i) Show that the iterative formula for approximating the root of F(x) = 0 by the
Newton-Raphson process for the equation x e x +5 x−10=0 is
2 Xn
X n e +10
X n+1= Xn
e ( X n +1 ) +5
(ii) Show that the root of the equation in (i) above lies between 1 and 2. Hence, find
the root of the equation correct your answer to 2 dps.
5. Using the same graph show that the curve X 3 and 2X+5 have a common real root. Using
the Newton-Raphson formula twice, find the positive root of X 3 −2 X−5=0, giving your
answer correct to 2 dps.
6. (a) Show that the Newton-Raphson formula for finding the root of the equation
x −3 x+ 4=0 is
3
[ ]
3
2 x n −2
, n = 0, 1, 2, ……………………
3 x n2−1
(b) Taking the first approximatrion to the root of the above equation as -2.0, draw a
flow diagram which reads and prints the number of iterations and the root. Carry
out a dry run of the flow chart and obtain the root with an error of less than
0.005.
FLOW CHARTS/DIAGRAMS:
2. They show the logical or sequential flow of processes/programs using arrows and
symbols.
Symbols:
START/END
OVAL
INPUT (READ)/
PARALLELOGRAM
OUTPUT (PRINT)
RECTANGLE
PROCESS/ALGORITM TO
BE EXECUTED
DECISION
TO BE YES RHOMBUS/DIAMOND BOX
TAKEN
NO
Study the flow chart and perform a dry run of the flow chart. Hence, state the purpose of the
flow chart.
START
Solution:
0 1 …………
N=1
1 3 1 , 1
4 5 4 , 3
9 7 9 , 5
16 9 16 , 7
25 11 25 , 9
36 13 36 , 11
49 15 49 , 13
numbers.
Example:
Draw a flow chart for computing and printing the mean of the square roots of the first one
hundred natural numbers.
N=N+1
START END
N=0 S=S+N
S=0
IS
N=100 NO
PRINT A
S ?
A=
100
START
YES
Start
Inputs: (N=0 ; S=0)/PRINT S=S+N
Counters: (N=N+1)
S
Algorithm for Average: (A= ) IS
100
N=100 N=N+1
Algorithm for Sum: (S=S+N)
?
Decision box
End
S
A=
100
PRINT A
Dry Run:
N=N+1
A N T N , T
0 0 0 …………..
1 1 1 1 , 1
3 2 8 2 , 8
T=T+6A+1
6 3 27 3 , 27
10 4 64 4 , 64
15 5 125 5 , 125
21 6 216 6 , 216 A=A+N
28 7 343 7 , 343
36 8 512 8 , 512
45 9 729 9 , 729 PRINT; N,T
55 10 1000 10 , 1000
The flow chart prints the first natural numbers and their NO
IS
corresponding cube roots. T =N 3 N=10
?
YES
STOP
Example: [2008(2)]
Study the flow chart below. Using the flow chart, perform a dry run and complete the table
below for X=22 and Y=7.
Solution:
P Q
START
0 22
1 15 Read: X,Y
2 8
P=0
3 1
The flow chart is used for finding the first four terms of
Q=X
whose common difference is -7 and first term is 22.
IS
Q<Y
?
YES
WRITE: P,Q
NO
P=P+1
STOP
Q=Q-Y
READ: A C=B÷ 2
START
IS
B ≤0 YES
?
NO
PRINT: C
IS NO
B DIVISIBLE STOP
BY 2 ?
A ← A +1
YES B= A−5
(a) Rearrange them and draw a complete logical flow chart.
(b) State the purpose of the flow chart.
(c) Perform a dry run of your arranged flow chart by coping and completing the table
below.
A B C
46 ……….. ………..
77 ……..... ………..
120 ………… ………..
177 ………… …………
Solution:
(c) A B C
READ: A
46 41 ……
77 72 36
B= A−5
120 115 ……
177 172 86
YES
IS
B ≤0 A ← A +1
?
NO
NO
YES
In the flow diagram C=Counter; SSN = Social Security Number; W=Monthly Wage of a factory
employee in shillings.
START
Copy and complete the following
table:
SSN W T C=1
01-86-003 8400 ………
03-86-095 8200 ………
04-86-064 7500 ………. SSN, W
02-86-035 8000 ………
04-86-066 6400 ………
01-87-098 4800 ………
02-87-105 6300 ……….
IS
03-87-135 5500 ………. W ≤ 4000 YES T =0
01-88-215 3800 ………. ?
01-88-217 3500 ………..
For how many employees is this program
Designed? Among these employees there NO
are some senior staff whose monthly
EXCESS=W −4000
salary is more than Sh.10,000 each.
These pay tax as follows: 12.5% for salary
Above Sh.4,000 but not more than Sh. 10,000;
T =EXCESS ¿0.125
Then 25% for salary above Sh. 10,000. Modify
The given flow diagram in order to incorporate
the senior staff.
WRITE: SSN,W,T
IS
C=C+ 1 NO C=270
?
YES
STOP
Solution:
START
C=1
SSN, W
IS
W ≤ 4000 T =0
? YES
IS
W ≤ 4000 EXCESS=W −4000 T =EXCESS ¿0.125
?
NO
YES
NO
NO
YES
STOP
Example:
SSN W T P
Example:
Solution:
1
Let X =N 5
5
X =N
5
X −N=0
5
f ( X n )= X n−N
' 4
f ( X n )=5 X n
5
(X n −N)
¿ X n− 4
5 Xn
X n+1=
1
5( N
4 X n− 4
Xn )
(b)
READ: X 0
END
START
n =0 n = n+1
IS
| X n+1− X n|≤0.5 × 10−3
?
X n+1=
1
5( N
4 X n− 4
Xn )
Flow chart:
START
READ: X 0
n =0
X n+1=
1
5 ( N
4 X n− 4
Xn )
IS
| X n+1− X n|≤0.5 × 10−3 n = n+1
?
NO
YES
(c)
Dry run:
Example:
FORMULATE QUESTION:
Solution:
Y = f(X) Y = f (A + a)
f(A) = f (A + a) – b
b = f (A + a) - f(A)
f ( A+ a)−f (A )
but f ' ( A)=
a
'
af ( A )=f ( A +a )−f ( A )
b=af ' ( A )
|b|=|a||f ' ( A )|
p
(b) f ( A )= A
' p−1
f ( A ) =p A
|b|=|a| p A p−1
|b|
Relative error =
B
|a| p A p−1
=
f ( A)
|a| p A p−1
=
Ap
= |a| p A−1
An iterative method for approximating a root of the equation f ( x )=0 is described in the flow
chart below.
Given that A = 1.6875, B = 1.8750 and Tol = 0.5 ×10−3, perform a dry run to find the values of B
and X.
START
READ: A, B, TOL
A+ B
X=
2
LINEAR INTERPOLATION:
R[ x , f ( x ) ] is a point between
P and Q in which either the ordinates
f ( x 1 )−f ( x 0 ) f ( x ) −f ( x 0 )
=
( x 1 )−( x 0 ) ( x ) −( x 0 )
From which;
f ( x ) −f ( x 0 )
x=x 0 + ( x 1−x 0 )
f ( x 1 )−f ( x 0)
( x−x 0 )
Or f ( x )=f ( x 0 ) +
( x1 −x 0)
[ f ( x 1 ) −f ( x 0 ) ]
Example:
T: (x) 0 12 20 30
Q: 6.6 2.9 -0.1 -2.9
Use linear interpolation to find
(i) Q when T = 16
(ii) T when Q -1
Solution:
f ( x 1 )−f ( x 0 ) f ( x ) −f ( x 0 )
=
( x 1 )−( x 0 ) ( x ) −( x 0 )
16−12
f ( x )=2.9+ (−0.1−2.9)
20−12
¿ 1.4
¿ 23.2
Example:
FORMULATE QUESTION:
Solution:
( x−x 0 )
f= ( f 1−f 0 ) +f 0
( x 1−x 0 )
( 80.759−80.50 )
f= ( 1.9074−1.9058 ) +1.9058
( 80.80−80.50 )
f =1.9072(4 dp)
( f −f 0 )
(b) x= ( x 1−x 0 ) + x 0
( f 1−f 0 )
( 1.90388−1.9031 )
x= ( 80.20−80.00 )+ 80.00
( 1.9042−1.9031 )
x=80.14 (2 dp)
Exercise:
1. The table below shows the values of a function f(x) at a set of points.
X 0 5 10 15
t 0 13 24.1 38.7
Use linear interpolation or extrapolation to find:
(i) t when x = 8
(ii) x when t = 44
TRAPEZIUM RULE:
3
Use the trapezium rule with 7 ordinates to estimate ∫ x+1 1 dx correct to 3 dps.
0
Solution:
3
∫ x+1 1 dx 1
2
h [ y 0+ 2 ( y 1+ y 2 +…+ y n−1 )+ y n ]
0
h=0.5
3
¿ 1.406 3 dp
Example:
FORMULATE QUESTION:
Solution:
xn
1
∫ f (x )dx 2 [ 0
h y +2 ( y 1+ y 2+ …+ y n−1 ) + y n ]
x0
n 0 1 2 3 4 5
x 0 0.2 0.4 0.6 0.8 1.0
yn 1 0.9606 0.8518 0.6978 0.5274 0.3678
¿ 0.7443
Exercise:
π
4
1. Use the trapezium rule with 5 ordinates to evaluate ∫ sec x dx correct to 4 dps.
0