TR2103 Introduction To Numerical Methods Assignment 1-1 (Submit Before 30 October)
TR2103 Introduction To Numerical Methods Assignment 1-1 (Submit Before 30 October)
TR2103 Introduction To Numerical Methods Assignment 1-1 (Submit Before 30 October)
1 Determine an interval of length one unit in which the negative real root, which is
Answer:
The number of changes in the sign of the coefficients (-9,18,-37,-70) is 1. Therefore the
equation has one positive root.
Since the smallest negative real root in the magnitude is required so a table of values is
form for x < 0.
x -5 -4 -3 -2 -1 0
F(x) -560 -210 -40 4 -24 -70
f(-1), f(-2) < 0 the negative root of smallest magnitude lies in the interval (-2,-1).
2 Find the root correct to two decimal places of the equation xex = cos x, using the method
of false position.
Answer:
f ( x )=cos x−x e x =0
f ( 0 )=cos (0)
f ( 0 )=1
f ( x )=cos x−x e x =0
f ( 1 ) =cos ( 1 )−1 e
f ( 1 ) =−1.718
x0 f 1−x 1 f 0
x 2=
f 1−f 0
(0)(−1.718)−(1)(1)
x 2=
−1.718−1
x 2=0.3679
f ( x 2 ) =f ( 0.3679 )
f ( x 2 ) =cos x−x e x
f 2=0.46848
x2 f 1−x 1 f 2
x 3=
f 1−f 2
(0.3679)(−1.718)−(1)(0.46848)
x 3=
−1.718−0.46848
x 3=0.50335
f ( x 3 ) =f ( 0.50335 )
f ( x 3 ) =cos x−x e x
f 3=0.16729
x 3 f 1−x 1 f 3
x4 =
f 1−f 3
(0.50335)(−1.718)−(1)(0.16729)
x4 =
−1.718−0.16729
x 4 =0.54742
f ( x 4 )=f ( 0.54742 )
f ( x 4 )=cos x −x e x
f 4=0.05358
x 4 f 1−x 1 f 4
x 5=
f 1−f 4
(0.54742)(−1.718)−(1)(0.05358)
x 5=
−1.718−0.05358
x 5=0.561108
f ( x 5 ) =f ( 0.561108 )
f ( x 5 ) =cos x−x e x
f 5=0.01655
x 5 f 1−x 1 f 5
x 6=
f 1−f 5
(0.561108 )(−1.718)−(1)(0.01655)
x 6=
−1.718−0.01655
x 6=0.56529
f ( x 6 ) =f ( 0.56529 )
f ( x 6 ) =cos x−x e x
f 6=0.005048
x 6 f 1−x 1 f 6
x 7=
f 1−f 6
(0.56529)(−1.718)−(1)( 0.005048)
x 7=
−1.718−0.005048
x 7=0.56657
|x 7−x 6|=0.56657−0.56529=0.00128
So, x ≈ x 7=0.56657 .
3 Perform four iterations of the Newton’s method to find the smallest positive root of the
equation f(x) = x3 – 5x + 1 = 0.
Answer:
f ( x )=x 3−5 x +1
f ' ( x )=3 x 2−5
x 0=0
f ' ( 0 ) =3(0)2−5=−5
1
Newton Raphson first iteration method x 1=0 — =0.2
5
x 1=0.2
|x 1−x 0|=0.2−0=0.2>1e-4
k = 1 for iteration 2 is
f (x 1 )
x 2=x 1−
f '( x 1 )
x 2=0.2−¿ ¿
|x 2−x 1|=0.20164−0.2=0.0016>1e-4
k = 2 for iteration 3 is
f ( x2 )
x 3=x 2−
f ' (x 2 )
x 2=0.20164−¿ ¿
2x1 + x2 + 3x3 = 13
x1 + x2 + 3x3 = 6
Answer:
3 3 4 20
[ ][ ]
3 1 3 13
1 1 3 6
R 1 ↔ R3
1 1 3 6
[ ][ ]
3 1 3 13
3 3 4 20
R1
R 2− ( )
5
1 1 3 6
[ 1.8 0.8 2.4 11.8
3 3 4 20 ][ ]
R 3− ( 10R )
1
1 1 3 6
[ 1.8 0.8 2.4 11.8
2.9 2.9 3.7 19.4 ][ ]
R2 ↔ R3
1 1 3 6
[ 2.9 2.9 3.7 19.4
1.8 0.8 2.4 11.8 ][ ]
3.2
R 3− ( 10.1 )R 2
1 1 3 6
[ 2.9 2.9 3.7 19.4
0 0 1 5.7 ][ ]
5.7
x 3= =5.7
1
19.4−1(5.7)
x 2= =4.724
2.9
2 2 3
2 1 1
1 3 5
Answer:
2 2 3
[ ] 2 1 1 ¿
1 3 5
R1 /2
1 1 3/2
[ 2 1 1 ¿
1 3 5 ]
R2−2 R1 , R 3−R1
1 1 3/2
[ 0 −1 −2 ¿
0 2 7/2 ]
R2 ↔ R3
1 1 3/2
[ 0 2 7/2 ¿
0 −1 −2 ]
R2 / ( 2 )
1 1 3 /2
[ 0 1 7/ 4 ¿
0 −1 −2 ]
R1−R 2 , R3 + R2
1 0 −1/ 4
[ 0 1 7 /4 ¿
0 0 −1/ 4 ]
R3 /(−1/4)
1 0 −1/ 4
[ 0 1 7 /4 ¿
0 0 1 ]
R1 +(1 /4)R 3 , R2−(7 /4) R 3
1 0 0
[ ] 0 1 0 ¿
0 0 1
Therefore the inverse of the matrix is
2 −1 −1
[
−9 7
5 −4 −2
4
]
6 Solve the system of equations
using the Jacobi and Gauss-Seidel iteration method. Obtain the result correct to three
decimal places.
1. Jacobi Method
1
x(k1 +1)= (12.6−(2 x(k) (k)
2 +2 x3 ))
26
1
x(k2 +1)= (−14.3−(3 x(k) (k )
1 + x 3 ))
27
1
x(k3 +1)= (6.0−(2 x(k) (k)
1 +3 x 2 ))
17
First Iteration:
1
x(1)
1 = (12.6−(2( 0)+ 2(0)))=0.48 5
26
1
x(1)
2 = (−14.3−(3 (0)+(0)))=−0.52 0
27
1
x (31) = ( 6.0−( 2 ( 0 ) +3 ( 0 ) ) ) =0.353
17
Second Iteration:
1
x(2)
1 = (12.6−(2(−0.52 0)+2( 0.353)))=0 .498
26
1
x(2)
2 = (−14.3−(3 (0.48 5)+(0 .353)))=−0.5 9 7
27
1
x (32 )= ( 6.0−( 2 ( 0.485 )+ 3 (−0.520 ) ) )=0.38 8
17
Third Iteration:
1
x(3)
1 = (12.6−(2(−0.59 7)+ 2(0.38 8)))=0.50 1
26
1
x(3)
2 = (−14.3−(3(0.49 8)+(0.3 88)))=−0.5 99
27
1
x (33 )= ( 6.0−( 2 ( 0.498 ) +3 (−0.59 7 ) ) ) =0 .399
17
Fourth Iteration:
1
x(41 )= (12.6−(2(−0.599)+2(0.399)))=0.5 00
26
1
x(42 )= (−14.3−(3(0.50 1)+(0 .399)))=−0.600
27
1
x (34 )= ( 6.0−( 2 ( 0 .50 1 ) +3 (−0.599 ) ) ) =0.3 99
17
Fifth Iteration:
1
x(5)
1 = (12.6−( 2(−0. 600)+2(0.3 99)))=0.500
26
1
x(5)
2 = (−14.3−( 3(0.500)+(0.399)))=¿-0.600
27
1
x (35 )= ( 6.0−( 2 ( 0.500 ) +3 (−0. 600 ) ) )=¿0.400
17
1
x(k1 +1)= (12.6−(2 x(k) (k)
2 +2 x3 ))
26
1
x(k2 +1)= (−14.3−(3 x(k+1 )
1 + x (k)
3 ))
27
1
x(k3 +1)= (6.0−(2 x(k+1)
1 +3 x(k2 +1)))
17
First Iteration:
1
x(1)
1 = (12.6−(2( 0)+ 2(0)))=0.485
26
1
x(1)
2 = (−14.3−(3 (0.485)+(0)))=−0.5 84
27
1
x (31) = ( 6.0−( 2 ( 0.485 )+ 3 (−0.584 ) ) ) =0. 399
17
Second Iteration:
1
x(1)
1 = (12.6−(2(−0.584)+2(0.399)))=0.499
26
1
x(1)
2 = (−14.3−(3 (0.499)+(0.399)))=−0.615
27
1
x (31) = ( 6.0−( 2 ( 0.499 )+ 3 (−0.615 ) ) ) =0 .403
17
Third Iteration:
1
x(1)
1 = (12.6−(2(−0.615)+ 2(0.403)))=0 .501
26
1
x(1)
2 = (−14.3−(3 (0.501)+(0 .403)))=−0. 600
27
1
x (31) = ( 6.0−( 2 ( 0.501 ) +3 (−0.600 ) ) )=0 .399
17
Fourth Iteration:
1
x(1)
1 = (12.6−(2(−0.600)+ 2(0 .399)))=0. 500
26
1
x(1)
2 = (−14.3−(3 (0.500)+(0.399)))=−0.599
27
1
x (31) = ( 6.0−( 2 ( 0.500 ) +3 (−0.599 ) ) ) =0.399
17
Fifth Iteration:
1
x(1)
1 = (12.6−(2(−0.599)+ 2(0 .399)))=0.500
26
1
x(1)
2 = (−14.3−(3 (0 .500)+(0 .399)))=−0. 599
27
1
x (31) = ( 6.0−( 2 ( 0.500 )+ 3 (−0.599 ) ) )=0.39 9
17