Solved Examples in Numerical Analysis: Solution of Equations in One Variable Example
Solved Examples in Numerical Analysis: Solution of Equations in One Variable Example
Using Bisection Method to find the approximate value of the root of the equation
5x3 + x2 − 2= 0 .
Solution:
a b pn = 1 (bn − an ) f ( pn )
2
0 1 0.5 -1.125
Table (1)
The approximate root is 0.6796875
1
Example (2):
Solution:
f ( x ) = x 3 + 4 x 2 - 10
f (1) = - 5 , f ( 2) = 4 p (1, 2)
p1 =(1+ 2) / 2 = 1.5 ,
f ( p1 ) = f (1.5) = 2 .375 p (1,1.5)
p2 = (1+1.5) / 2 = 1.25 ,
f ( p2 ) = f (1.25) = -1.79687 p (1.25,1.5)
n a b pn f ( pn )
0 1 2 1.5 2.375
Table (2)
The root is 1.365234375
2
Example (3):
Solution:
The result shown in the following table
n a b pn f ( pn )
0 0 2 1 -1
1 1 2 1.5 0.125
Table (3)
Newton's method
Example (7):
Solution:
f (x) = x 4 − x − 10 = 0, f (x) = 4 x 3 − 1
the iteration formula is
3
xn4 − xn − 10
xn + 1 = x n − , n = 0,1, 2, 3,....
3
4 xn − 1
or in the form
3 xn4 + 10
xn + 1 = , x0 = 2, n = 0, 1, 2, ...
4 xn − 1
3
3 x04 + 10 3(2)4 + 10
x1 = = = 1.870967742
4 x0 3 − 1 4(2)3 − 1
the algorithm is shown in the flowing table
0 2 31 58 1.870967742
Table (9)
Exercise (1)
(1) By bisection method find 3 25 .
Solution:
by using Newton iteration method we have
xn 3 − a 2 x n 3 + a
xn +1 = xn − = , n = 1,2,3,... let a = 25 and since the cubic root of
3 xn2 3 xn2
2 xn 3 + 25
25 in-between 2 and 3 starting by x0 = 2.5 xn +1 = , n = 1,2,3,...
3 xn2
4
n xn xn + 1 f ( x)
1 3 2.925925926 2
5 2.924017738 2.924017738 0
3 25 2.924017738
i a b xi = ( a + b ) / 2 f ( xi )
1 1 2 1.5 -2.125
5
7 1.6875 1.703125 1.6953125 -0.041591167
x 3 + 3x − 10 = 0
f ( x ) = x 3 + 3x − 10
f ( x ) = 3 x 2 + 3
x n 3 + 3x n − 10 2x n 3 + 10
x n +1 = x n − =
3x n 2 + 3 3x n 2 + 3
i xi xi + 1 f ( xi + 1 )
0 1 2 4
1 2 1.733333333 0.407703704
5 1.69888549 1.69888549 0
R = 1.69888549
-------------------------------------------------------------------------------------------------------
6
Find the one root for the equation x 3 − 5 x 2 + 2 = 0 . Calculate the error at each
iteration.
Answer
Let f ( x ) = x 3 − 5 x 2 + 2
x -1 0 1 2 3 4 5
Then we have a root in the interval ( −1,0) and one in (0,1) the third root in the
interval (4,5)
by using Newton method with initial value -1
n xn xn+1 f ( xn+1 )
0 -1 -0.692307692 -0.728265817
4 -0.597735191 -0.597735188 0
n xn xn+1 f ( xn+1 )
5 0.680449195 0.680449195 0
7
The approximate value of the root is 0.680449195
n xn xn+1 f ( xn+1 )
0 4 5.75 26.796875
5 4.917285995 4.917285993 0
(−1, 10), (0, 9), (1, 7), (2, 5), (3, 4), (4, 3), (5, 0), (6, − 1).
Solution:
Let the equation of the L.S.L in the form y = Ax + B tabulate the data as following
x y x2 xy
-1 10 1 -10
0 9 0 0
1 7 1 7
2 5 4 10
3 4 9 12
8
4 3 16 12
5 0 25 0
6 -1 36 -6
N N N N
xk =20 yk =37 xk =92 xk yk = 25
2
k =1 k =1 k =1 k =1
92 A + 20 B = 25
Equations (2) ,(3) gives
20 A + 8B = 37
by solving these equations we get A = -1.6071429, B = 8.6428571
Example (2):
(0.5, 0.31), (1.0, 0.82), (1.5, 1.29), (2.0, 1.85), (2.5, 2.51), (3, 3.02).
Solution:
Let the equation of the L.S.L in the form y = Ax + B tabulate the data as following
x y x2 xy
1 0.82 1 0.82
2 1.85 4 3.7
3 3.02 9 9.06
N N N N
xk = 10.5 yk = =9.8 xk = =22.75 xk yk = 21.945
2
k =1 k =1 k =1 k =1
9
Equations (2) ,(3) gives
Example (3) :
x 1 2 4 6 10
y 2.6 5.6 13.3 21.2 40.1
•
Solutions:
y = a xb
log y = ln a + b log x put Y = log y , A = ln a X = log x
the linear form is Y = A + bX
10
And substitute in the normal equations(6),(7)
A = 2.68124 b = 5.21649
A = 2.68124 b = 5.21649
hence log a = 2.68124 → a = 2.1959997
Example (4):
x 1 2 3 4 5 6 7 8
Solutions:
y = a e bx
log y = log a + b log e x
The linear equationsis
Y = A + Bx where Y = log y , A = log a , B = b log e
the normal equations are
N N
Yk = NA + B xk (17)
k =1 k =1
N N N
xk Yk = A xk + B xk2 (18)
k =1 k =1 k =1
11
Tabulate the data as in the following table
x y Y=log y xY x2
from (16)
1 N N
A= Yk − B xk (18)
N k =1 k =1
substitute in (17)
N N N
N xk Yk − Yk xk
k =1 k =1 k =1
B = 2
= 0.126473509
N N
N xk2 − xk
k =1 k =1
using (18) we get A=1.058314724
a = 10 A= 11.43706854
B 0.126473509
b= = = 0.291216016
log e 0.434294482
12
Exercises
(1) Use least square method to fit the curve y = ax + b to the following data:
x = 3 at y .Hence find (0, 3.2),(2, 4.1),(4, 4.2),(6, 5.4)
xi yi xi2 x i yi
0 3.2 0 0
2 4.1 4 8.2
4 4.2 16 16.8
6 5.4 36 32.4
4 4 4 4
xi =12 yi =16.9 xi2 = 56 xi yi =57.4
i =1 i =1 i =1 i =1
4 4 4
a x i 2 + b x i = yi x i
i =1 i =1 i =1
4 4
a xi + 4b = yi
i =1 i =1
4 4 4
4 y i X i − X i y i
a = i =1 i =1 i =1 = 4(57.4) − (12)(16.9) = −0.009203297
4 4
2
4(56) − (12)2
4 X i − Xi
2
i =1 i =1
1 4 4
and b= y i − a Xi = 1
4 ( 16.9 − 4(12) ) = 4.25260989
n i =1 i =1
------------------------------------------------------------------------------------------------------
(2) Fit the curve y = a x 3 + b to the data (7.9, 0.2),(11.9, 0.4),(16.4, 0.8),( 22.6,1.6)
Answer:
4 4 4
a X i 2 + b X i = yi X i
i =1 i =1 i =1
4 4
a X i + 4b = yi
i =1 i =1
1 4 4
and b= yi −a Xi = 1
4
( 3 − 4(58.8) ) = 0.185049752037084
n i =1 i =1
------------------------------------------------------------------------------------------------------
1
(3) Fit the curve y = to the data (1, 0.5),( 2, 0.4),( 4, 0.3),(6, 0.2),(8, 0.1) .
ax +b
2
Answer:
14
x y X Y X2 XY
1 0.5 1 2 1 2
2 0.4 4 2.5 16 10
5 5 5 5 5 5
5 Y i X i − X i Y i 5 Y i X i − X i Y i
a = i =1 i =1 i =1 = i =1 i =1 i =1 = 0.12158969
2 2
5 5 5 5
5 X 2i − X i 5 X 2i − X i
i =1 i =1 i =1 i =1
1 5 5 1 5 5
and b = Y i − a X i = Y i − a X i = 1.62419614
5 i =1 i =1 5 i =1 i =1
1
Then the best curve is y =
0.12158969x 2 + 1.62419614
------------------------------------------------------------------------------------------------------
Answer:
y = a exp( − b x 2 )
where
15
Y = log y
A = − b log e
X = x2
B = log a
xi yi Xi Yi X i2 X iYi
6 6 6 6 6 6
6 Y i X i − X i Y i 6 Y i X i − X i Y i
A = i =1 i =1 i =1 = i =1 i =1 i =1 = −0.04361343671690
2 2
6 6 6 6
6 X 2i − X i 6 X 2i − Xi
i =1 i =1 i =1 i =1
1 6 6 1 6 6
and B = Y i − a X i = Y i − a X i = 0.942598495
6 i =1 i =1 6 i =1 i =1
A
b= = 0.100423649
− log e
a = 10 B = 1.260154078
----------------------------------------------------------------------------------------------------------------
16
(5) Fit the curve y = a sin 2 x + b to the data (0,4.2),( ,5.8),( ,8.3),( ,9.9),( ,12.5)
6 4 3 2
Answer:
y = a sin 2 x + b
y = aX + b
where X = sin 2 x
xi Xi yi X i2 X i yi
0 0 4.2 0 0
5 5 5 5 5 5
5 y i X i − X i y i 5 y i X i − X i y i
A = i =1 i =1 i =1 = i =1 i =1 i =1 = 8.28
2 2
5 5 5 5
5 X 2i − X i 5 X 2i − Xi
i =1 i =1 i =1 i =1
1 5 5 1 5 5
and B = y i − a X i = y i − a X i = 4
5 i =1 i =1 5 i =1 i =1
y = 8.28sin 2 x + 4
------------------------------------------------------------------------------------------------------
Answer:
17
y = a cos 2 x + b
y = aX + b
where X = cos 2 x
xi Xi yi X i2 X i yi
0 1 11.2 1 11.2
5 5 5 5 5 5
5 y i X i − X i y i 5 y i X i − X i y i
A = i =1 i =1 i =1 = i =1 i =1 i =1 = 2.51765
2 2
5 5 5 5
5 X 2i − X i 5 X 2i − Xi
i =1 i =1 i =1 i =1
1 5 5 1 5 5
and B = y i − a X i = y i − a X i = 8.51765
5 i =1 i =1 5 i =1 i =1
----------------------------------------------------------------------------------------------------------------
18
Answer:
xi X i = xi 3 yi Xi2 xi yi
1 1 10.9 1 10.9
5 5 5
a X i 2 + b X i = yi X i
i =1 i =1 i =1
5 5
a X i + 5b = yi
i =1 i =1
y = 2.499623478 x 3 + 8.461159688
----------------------------------------------------------------------------------------------------------------
19
Numerical Differentiation
f ( x + h) − f ( x − h)
f ( x ) =
2h
f ( x + h) − 2 f ( x ) + f ( x − h)
f ( x ) =
h2
1
f ( x) = f ( x − 2 h ) − 8 f ( x − h ) + 8 f ( x + h) − f ( x + 2 h)
12h
1
f ( x) = − f ( x + 2h) + 16 f ( x + h) − 30 f ( x) + 16 f ( x − h) − f ( x − 2h)
12h 2
−3 f ( x0 ) + 4 f ( x0 + h) − f ( x0 + 2h)
f ( x0 ) =
2h
3 f ( x0 ) − 4 f ( x0 − h) + f ( x0 − 2h)
f ( x0 ) =
2h
2 f ( x ) − 5 f ( x + h) + 4 f ( x + 2h) − f ( x + 3h)
f ( x ) =
h2
Example (3):
Solution:
To approximate f ( 2.0)
20
(i) By using three - point formula
− 3 f ( x ) + 4 f ( x + h) − f ( x + 2 h)
f ( x ) =
2h
− 3 f (0.2) + 4 f ( 2.1) − f ( 2.2)
f (0.2) =
2(0.1)
− 3(14.778112) + 4(17.148952) − (19.855030)
= = 22.032310
0.2
3 f ( x ) − 4 f ( x − h) + f ( x − 2 h )
f ( x ) =
2h
f ( x + h) − f ( x − h)
f ( x ) =
2h
f ( x − 2 h) − 8 f ( x − h) + 8 f ( x + h) − f ( x + 2 h)
f ( x ) =
12h
f (1.8) − 8 f (1.9) + 8 f ( 2.1) − f ( 2.2)
f ( 2.0) =
12(0.1)
21
Second derivative
f ( x + h) − 2 f ( x ) + f ( x − h)
f ( x ) =
h2
f ( 2.1) − 2 f ( 2) + f (1.9)
f (0.2) =
h2
(17.148957) − 2(14.778112) + (12.7037119)
= = 29.5932
0.01
at x = 1.8 consider:
x + h = 1.9, x + 2h = 2.0
− 3 f ( x ) + 4 f ( x + h) − f ( x + 2 h)
f ( x ) =
2h
− 3 f (1.8) + 4 f (1.9) − f ( 2.0)
f (1.8) =
2(0.1)
= (5)[ −3(10.889365) + 4(12.703199) − (14.778112)]
= (5)(− 32.668095 + 50.812796 − 14.778112) = (5)(3.366589)
= 16.832945 ,
2 f ( x ) − 5 f ( x + h) + 4 f ( x + 2h) − f ( x + 3h)
f ( x ) =
h2
2 f (1.8) − 5 f (1.9) + 4 f ( 2.0) − f ( 2.1)
f (1.8) =
(0.1) 2
2(10.889365) − 5(12.703199) + 4(14.778112) − (17.148957 )
=
(0.1) 2
= (100)(0.226226 ) = 22.6226
since
3 f ( x ) − 4 f ( x − h ) + f ( x − 2 h)
f ( x ) =
2h
22
3(19.855030) − 4(17.148957) + (14.778112) 5.747374
= = = 28.73687
2(0.1) 0.2
2 f ( x) − 5 f ( x − h) + 4 f ( x − 2h) − f ( x − 3h)
f ( x) =
h2
2 f (2.2) − 5 f (2.1) + 4 f (2.0) − f (1.9)
f (2.2) =
(0.1)2
1
f (2.2) = [2(19.855030) − 5(17.148957) + 4(14.778112) − (12.703199)]
0.01
0.374524
= = 37.4524
0.01
Solution:
− 3 f ( x ) + 4 f ( x + h) − f ( x + 2 h)
y ( x ) =
2h
−3 f (0.55) + 4 f (0.60) − f (0.65)
y(0.55) =
2(0.05)
−3(1.4444243) + 4(1.418083) − (1.388686)
= = -0.496269
0.2
23
3 f ( x ) − 4 f ( x − h) + f ( x − 2h)
y( x ) =
2h
f ( x + h) − f ( x − h)
y( x ) =
2h
f ( x − 2 h) − 8 f ( x − h) + 8 f ( x + h) − f ( x + 2 h)
y ( x ) =
12h
f (0.45) − 8 f (0.50) + 8 f (0.60) − f (0.65)
y(0.55) =
12(0.05)
1.487968 − 8(1.467462) + 8(1.418083) − 1.388686
= = -0.492916667
12(0.05)
f ( x + h ) − 2f ( x ) + f ( x − h )
y ( x ) =
h2
f (0.60) − 2f (0.55) + f (0.50)
y (0.55) =
h2
(1.418083) − 2(1.4444243) + (1.467462)
= = -1.32144
(0.05)2
24
By using five points formula:
1
y ( x ) = −f (x + 2h ) + 16f (x + h ) − 30f (x ) + 16f (x − h ) − f (x − 2h )
12h 2
1
y (55) = −f (0.65) + 16f (0.60) − 30f (0.55) + 16f (0.50) − f (0.45)
12(0.05)2
1
= −(1.388686) + 16(1.418083) − 30(1.4444243) + 16(1.467462) − 1.487968
12(0.05)2
= -1.355433333
-------------------------------------------------------------------------------------------------------
(4 a) From the following table evaluate y, y at x = 0.50
Solution:
− 3 f ( x ) + 4 f ( x + h) − f ( x + 2 h)
y ( x ) =
2h
−3 f (0.5) + 4 f (0.55) − f (0.60)
y(0.5) =
2(0.05)
−3(1.467462) + 4(1.4444243) − (1.418083)
= = -0.427718
0.2
3 f ( x ) − 4 f ( x − h) + f ( x − 2h)
y( x ) =
2h
25
3 f (0.5) − 4 f (0.45) + f (0.40)
y(0.5) =
2(0.05)
3(1.467462) − 4(1.487968) + (1.505942)
= = -0.43544
2(0.05)
f ( x + h) − f ( x − h)
y( x ) =
2h
f ( x − 2h) − 8 f ( x − h) + 8 f ( x + h) − f ( x + 2h)
y ( x ) =
12h
f (0.40) − 8 f (0.45) + 8 f (0.55) − f (0.60)
y(0.50) =
12(0.05)
1.505942 − 8(1.487968) + 8(1.4444243) − 1.418083
= = -0.434141
12(0.05)
Second derivative
f ( x + h ) − 2 f ( x ) + f ( x − h)
y( x ) =
h2
f (0.55) − 2 f (0.50) + f (0.45)
y(0.50) =
h2
(1.4444243) − 2(1.467462) + (1.487968)
= = -1.01268
2
(0.05)
26
By using five points formula:
1
f ( x ) = − f ( x + 2h) + 16 f ( x + h) − 30 f ( x ) + 16 f ( x − h) − f ( x − 2h)
12h2
1
f ( x ) = − f (0.6) + 16 f (0.55) − 30 f (0.50) + 16 f (0.45) − f (0.40)
12(0.05)2
1 −(1.418083) + 16(1.4444243)
=
12(0.05)2 −30(1.467462) + 16(1.487968) − 1.505942
= -0.98694
-------------------------------------------------------------------------------------------------------
(1) From the following table evaluate y, y at x = 1 , 1.2 and at 1.4
x 1 1.2 1.4 1.6 1.8
Solution:
− 3 f ( x ) + 4 f ( x + h) − f ( x + 2 h)
y ( x ) =
2h
−3 f (0.55) + 4 f (0.60) − f (0.65)
y(0.55) =
2(0.05)
−3(1.4444243) + 4(1.418083) − (1.388686)
= = -0.496269
0.2
3 f ( x ) − 4 f ( x − h) + f ( x − 2h)
y( x ) =
2h
27
3f (0.55) − 4f (0.50) + f (0.45) 3(1.4444243) − 4(1.467462) + (1.487968)
y (0.55) = =
2(0.05) 2(0.05)
= -0.486071
f ( x + h) − f ( x − h)
y( x ) =
2h
f ( x − 2 h) − 8 f ( x − h) + 8 f ( x + h) − f ( x + 2 h)
y ( x ) =
12h
f (0.45) − 8 f (0.50) + 8 f (0.60) − f (0.65)
y(0.55) =
12(0.05)
1.487968 − 8(1.467462) + 8(1.418083) − 1.388686
= = -0.492916667
12(0.05)
f ( x + h ) − 2f ( x ) + f ( x − h )
y ( x ) =
h2
f (0.60) − 2f (0.55) + f (0.50)
y (0.55) =
h2
(1.418083) − 2(1.4444243) + (1.467462)
= = -1.32144
(0.05)2
1
y ( x ) = −f (x + 2h ) + 16f (x + h ) − 30f (x ) + 16f (x − h ) − f (x − 2h )
12h 2
1
y (55) = −f (0.65) + 16f (0.60) − 30f (0.55) + 16f (0.50) − f (0.45)
12(0.05)2
1
= −(1.388686) + 16(1.418083) − 30(1.4444243) + 16(1.467462) − 1.487968
12(0.05)2
= -1.355433333
28
-------------------------------------------------------------------------------------------------------
(6) Use the following table to compute f (1.3) in the case h = 0.1, h = 0.01
When h = 0.1
f (x ) = f (1.3) = 14.04276
f ( x − h ) = f (1.2) = 11.59006
f ( x + h ) = f (1.4) = 16.86187
f ( x + h ) − 2f ( x ) + f ( x − h )
We use f ''( x ) =
h2
h = 0.1, h = 0.01
f (x ) = f (1.3) = 14.04276
f ( x − h ) = f (1.29) = 13.78176
f ( x + h ) = f (1.31) = 14.30741
f ( x + h ) − 2f ( x ) + f ( x − h )
We use f ''( x ) =
h2
-------------------------------------------------------------------------------------------------------
Numerical Integration
h
I = f ( x0 ) + 2 f ( x1 ) + 2 f ( x2 ) + ... + 2 f ( xn−1 ) + f ( xn )
2
Example (1):
1 1
consider the integral dx with h=0.1 and then n=10 and by using trapezoidal
0 1 + x
29
h
I = f ( x0 ) + 2 f ( x1 ) + 2 f ( x2 ) + ... + 2 f ( xn−1 ) + f ( xn )
2
substitute about the values of f (xk ) from the table we get
k xk f ( xk )
0 0 1.00000000 1.00000000
Table (1)
2 sin x
Evaluate dx take h = 0.5, 0.2, 0.1
0 x
Solution:
Considering h=0.5
30
x f(x) 2 f ( x)
1 1 1
2 0.454648713 0.454648713
Table (2)
h
IT = f ( x0 ) + 2 f ( x1 ) + 2 f ( x2 ) + ... + 2 f ( xn −1 ) + f ( xn )
2
0.2
= [1+1.917702154+1.68294197+1.329993315+0.454648713]=1.596321538
2
at h=0.2
h
I = f ( x0 ) + 2 f ( x1 ) + 2 f ( x2 ) + ... + 2 f ( xn −1 ) + f ( xn )
2
0.2
= [1 + 1.986693308 + 1.947091712 + 1.882141578 + 1.793390227
2
+ 1.68294197 + 1.553398477 + 1.407785329 + 1.249467004
+ 1.082052923 + 0.454648713] = 1.603961124
x f(x) 2f(x)
0 1 1
0.2 0.993346654 1.986693308
0.4 0.97354855 1.947091712
0.6 0.941070789 1.882141578
0.8 0.896695113 1.793390227
1.0 0.841470984 1.68294197
1.2 0.776699238 1.553398477
1.4 0.703892664 1.407785329
1.6 0.624733501 1.249467004
1.8 0.541026461 1.082052923
2 0.454648713 0.454648713
31
At h = 0.1
h
IT = f (x ) + 2 f (x1 ) + f (x 2 ) + ... + f (xn −1 ) + f (xn )
2 0
0.2
= [1 + 1.996668333 + 1.986693308 + 1.970134711 + 1.94091712
2
+ 1.917702154 + 1.882141578 + 1.840621964 + 1.793390227
+ 1.740726466 + 1.68294197 + 1.620377018 + 1.553398477
+ 1.482397208 + 1.407785329 + 1.329993315 + 1.249467004
+ 1.166664483 + 1.082052923 + 0.996105355 + 0.454648713]
= 1.604741308
IT = 1.604741308
x f ( x) 2 f ( x)
0 1 1
0 .1 0.998834166 1.996668333
0 .2 0.993346654 1.986693308
0 .3 0.985067335 1.970134711
0 .4 0.973545855 1.94091712
0 .5 0.958851077 1.917702154
0 .6 0.941070789 1.882141578
0 .7 0.920310981 1.840621964
0 .8 0.896695113 1.793390227
0 .9 0.870363232 1.740726466
1 .0 0.841470984 1.68294197
1 .1 0.810188509 1.620377018
1 .2 0.776699238 1.553398477
1 .3 0.741198604 1.482397208
1 .4 0.703892664 1.407785329
1 .5 0.664996657 1.329993315
1 .6 0.6244733501 1.249467004
1 .7 0.583332241 1.166664483
1 .8 0.514026461 1.082052923
1 .9 0.498052677 0.996105355
2 0.454648713 0.454648713
32
Simpson’s 1/3 Rule of Integration Method
h
I S = [ f ( x0 ) + 4 f ( x1 ) + 2 f ( x2 ) + 4 f ( x3 ) + 2 f ( x4 ) + 4 f ( x5 ) + 2 f ( x6 )
3
+ ... + 2 f ( xn− 2 ) + 4 f ( xn−1 ) + f ( xn )]
1 dx
Example (3): Evaluate using Simpson’s rule (h=0.1)
2
01+ x
Solution:
1
a = 0, b = 1, f ( x) = , xk = x0 + kh = 0 + k (0.1) = 0.1 k
2
1+ x
0.1
Is = 1 + 4(0.9901 + 0.9174 + 0.8 + 06711 + 0.5525)
3
+2(0.9615 + 0.8621 + 0.7353 + 0.6098) + 0.5 = 0.7853933
IT = 0.784981495
0 0 1 1
1 0.1 0.9901 3.9604
2 0.2 0.9615 1.923
3 0.3 0.9174 3.6696
4 0.4 0.8621 1.7242
5 0.5 0.8 3 .2
6 0.6 0.7353 1.4706
7 0.7 0.6711 2.6844
8 0.8 0.6098 1.2196
9 0.9 0.5525 2.21
10 1.0 0.5 0.5
33
Example (4):
1
dx
Evaluate 1+ x2
using Simpson’s rule(h=0.1)
0
Solution:
a = 0, b = 1.2, f ( x) = x4 + 5 x − 1
xk = x0 + kh
k xk f (xk ) 2f (x k ) 2f ( x k ) 2f ( x k )
or 4f ( x k ) or 3f ( x k )
0 0 1 -1 -1 -1
5 1.0 5.00 10 20 15
IT = 2.92064
I s = 2.89792
I Exact = 2.89766
34
i xi f ( xi ) 2 f ( xi )
1e x
−1
(1) dx 0 0 0 0
0 x
1 0.1 0.332579645 0.665159289
10 1 1.718281828 1.718281828
I= 0.920238782
i xi f ( xi ) 2 f ( xi ) 4 f ( xi )
0 0 0 0
10 1 1.718281828 1.718281828
9.126805758 18.55593977
I= 0.922758184
35
i xi f ( xi ) 2 f ( xi )
1
(2) tan x 0 0 0 0
0
10 1 1.247961428 1.247961428
I=0.721866596
i xi f ( xi ) 2 f ( xi ) 4 f ( xi )
0 0 0 0
10 1 1.2479614 1.247961428
36
7.132552482 14.609559
I= 0.724737045
1
1+ x
2
(3) dx
0
Solution:
i xi f ( xi ) 2 f ( xi )
0 0 1 1
10 1 1.414213562 1.414213562
I= 1.148382904
37
i xi f ( xi ) 2 f ( xi ) 4 f ( xi )
0 0 1 1
10 1 1.4142136 1.414213562
11.50151774 22.932281
I=1.147793281
38