Uploaded by nazirdipalpur

Fall 2023 MTH603 1 SOL

advertisement
FALL 2023
MTH603
Solution of Assignment # 1
Section In-charge: Arooba Fatima
Total Marks 20
Question 1:
Marks=10
Use Secant method to compute the root of the equation
x3 - 5 x + 1 = 0, [0,1]
with the accuracy of 4-decimal point.
Solution:
1st iteration:
x0 = 0 and x1 = 1
f ( x0 ) = f (0) =1 and f ( x1 ) = f (1) = −3
īœ x2 =
x0 f ( x1 ) − x1 f ( x0 )
0(−3) − 1(1)
=
f ( x1 ) − f ( x0 )
−3 − 1
x2 = 0.25
f ( x2 ) = f (0.25) = (0.25)3 − 5(0.25) + 1 = − 0.2344
2nd iteration:
x1 =1 and x2 = 0.25
f ( x1 ) = f (1) = − 3 and f ( x2 ) = f (0.25) = −0.2344
x3 =
x1 f ( x2 ) − x2 f ( x1 )
1(−0.2344) − 0.25(−3)
=
f ( x2 ) − f ( x1 )
−0.2344 − (−3)
x3 = 0.1864
f ( x3 ) = f (0.1864) = (0.1864)3 − 5(0.1864) + 1 = − 0.07448
3rd iteration:
x2 = 0.25 and x3 = 0.1864
f ( x2 ) = f (0.25) = − 0.2344 and f ( x3 ) = f (0.1864) = 0.07448
x4 =
x2 f ( x3 ) − x3 f ( x2 )
0.25(0.07448) − 0.1864( −0.2344)
=
f ( x3 ) − f ( x2 )
0.07448 − (−0.2344)
x4 = 0.2017
f ( x4 ) = f (0.2017) = (0.2017)3 − 5(0.2017) + 1 = − 0.00029
4th iteration:
x3 = 0.1864 and x4 = 0.2017
f ( x3 ) = f (0.1864) = 0.07448 and f ( x4 ) = f (0.2017) = − 0.00029
x5 =
x3 f ( x4 ) − x4 f ( x3 )
0.1864(−0.00029) − 0.2017(0.07448)
=
f ( x4 ) − f ( x3 )
(−0.00029) − (0.07448)
x5 = 0.2016
f ( x5 ) = f (0.2016) = (0.2016)3 − 5(0.2016) +1 = 0.0001
The approximation root of the equation x3 -5x+1=0 using secant method is 0.2016
(after 4th iteration).
Question 2:
Marks=10
Using Gauss Siedal Iteration Method to solve system of linear equations
by taking initial starting vector as (0, 0, 0)T .
6 x1 − 2 x2 − x3 + x4 = 3
− x1 + 6 x2 − x3 − x4 = −9
2 x1 − x2 + 6 x3 + 2 x4 = 15
x1 + x2 − x3 + 6 x4 = 27
Solution:
1
x1( n +1) = [3 + 2 x2 ( n ) + x3( n ) − x4 ( n ) ]
6
1
x2 ( n +1) = [−9 + x1( n +1) + x3( n ) + x4( n ) ]
6
1
x3( n +1) = [15 − 2 x1( n +1) + x2( n +1) − 2 x4 ( n ) ]
6
1
x4 ( n +1) = [27 − x1( n +1) − x2 ( n +1) + x3( n +1) ]
6
For n=0
1
x1(1) = [3 + 2(0) + (0) − (0)] = 0.5
6
1
x2 (1) = [−9 + (0.5) + (0) + (0)] = −1.4167
6
1
x3(1) = [15 − 2(0.5) + (−1.4167) − 2(0)] = 2.0972
6
1
x4 (1) = [27 − (0.5) − (−1.4167) + (2.0972)] = 5.0023
6
For n=1
1
x1(2) = [3 + 2(−1.4167) + (2.0972) − (5.0023)] = −0.4564
6
1
x2 (2) = [−9 + (−0.4564) + (2.0972) + (5.0023)] = −0.3928
6
1
x3(2) = [15 − 2(−0.4564) + (−0.3928) − 2(5.0023)] = 0.9192
6
1
x4 (2) = [27 − (−0.4564) − (−0.3928) + (0.9192)] = 4.7947
6
For n=2
1
x1(3) = [3 + 2(−0.3928) + (0.9192) − (4.7947)] = −0.2769
6
1
x2 (3) = [−9 + (−0.2769) + (0.9192) + (4.7947)] = −0.5938
6
1
x3(3) = [15 − 2(−0.2769) + (−0.5938) − 2(4.7947)] = 0.8951
6
1
x4 (3) = [27 − (−0.2769) − (−0.5938) + (0.8951)] = 4.7943
6
For n=3
1
x1(4) = [3 + 2(−0.5938) + (0.8951) − (4.7943)] = −0.3478
6
1
x2 (4) = [−9 + (−0.3478) + (0.8951) + (4.7943)] = −0.6097
6
1
x3(4) = [15 − 2(−0.3478) + (−0.6097) − 2(4.7943)] = 0.9162
6
1
x4 (4) = [27 − (−0.3478) − (−0.6097) + (0.9162)] = 4.8123
6
For n=4
1
x1(5) = [3 + 2(−0.6097) + (0.9162) − (4.8123)] = −0.3526
6
1
x2 (5) = [−9 + (−0.3526) + (0.9162) + (4.8123)] = −0.604
6
1
x3(5) = [15 − 2(−0.3526) + (−0.604) − 2(4.8123)] = 0.9128
6
1
x4 (5) = [27 − (−0.3526) − (−0.604) + (0.9128)] = 4.8116
6
For n=5
1
x1(6) = [3 + 2(−0.604) + (0.9128) − (4.8116)] = −0.3511
6
1
x2 (6) = [−9 + (−0.3511) + (0.9128) + (4.8116)] = −0.6045
6
1
x3(6) = [15 − 2(−0.3511) + (−0.6045) − 2(4.8116)] = 0.9124
6
1
x4 (6) = [27 − (−0.3511) − (−0.6045) + (0.9124)] = 4.8113
6
For n=6
1
x1(7) = [3 + 2(−0.6045) + (0.9124) − (4.8113)] = −0.3513
6
1
x2 (7) = [−9 + (−0.3513) + (0.9124) + (4.8113)] = −0.6046
6
1
x3(7) = [15 − 2(−0.3513) + (−0.6046) − 2(4.8113)] = 0.9126
6
1
x4 (7) = [27 − (−0.3513) − (−0.6046) + (0.9126)] = 4.8114
6
(Fall-2023)
MTH-603 Assignment No.1
Section Incharge: Kiran Naseem Aslam
Maximum Marks: 20
Question 1
10 Marks
Find a root of the given equation đ‘Ĩ 3 − đ‘Ĩ − 11 = 0, in the interval (2,3) using Bisection Method
after Five Iterations.
Note: Accuracy up to four decimal places is required.
Solution:
We can see that f(2)=-5<0 and f(3)=13 >0. So, our root will lie between (2,3).
The First approximation to the root is
đ‘Ĩ1 =
2+3
= 2.5
2
Now, f(2.5)=2.125 >0 , therefore root will lie between (2,2.5).
The 2nd approximation to the root is
đ‘Ĩ2 =
2 + 2.5
= 2.25
2
Now, f(2.25)=-1.85938<0 , therefore root will lie between (2.5,2.25).
The 3rd approximation to the root is
đ‘Ĩ3 =
2.5 + 2.25
= 2.375
2
Now, f(2.375)=0.02148 >0 , therefore root will lie between (2.25,2.375).
The 4th approximation to the root is
đ‘Ĩ4 =
2.25 + 2.375
= 2.31250
2
Now, f(2.3125)=-0.94604< 0 , therefore root will lie between (2.375, 2.3125).
The 5th approximation to the root is
đ‘Ĩ5 =
2.375 + 2.3125
= 2.34375
2
So, the 2.3438 is the approximate root of the function after fifth iteration and of course this is
not exact root of the function because f(2.3437) ≠ 0.
Question 2
10 Marks
Find a root of the given equation in the interval (1,2) using Newton-Raphson Method after four
iterations
đ‘Ĩ 3 − 20 = −2đ‘Ĩ 2 − 10đ‘Ĩ
Take Initial value 1.2.
Note: Accuracy up to four decimal places is required.
Solution:
First rearrange given equation
đ‘Ĩ 3 + 2đ‘Ĩ 2 + 10đ‘Ĩ − 20 = 0
Let 𝑓(đ‘Ĩ) = đ‘Ĩ 3 + 2đ‘Ĩ 2 + 10đ‘Ĩ − 20.
𝑓 ′ (đ‘Ĩ) = 3đ‘Ĩ 2 + 4đ‘Ĩ + 10
As we know Newton –Raphson Formula is
đ‘Ĩ𝑛+1 = đ‘Ĩ𝑛 −
𝑓(đ‘Ĩ𝑛 )
𝑓 ′ (đ‘Ĩ𝑛 )
So,
đ‘Ĩ𝑛+1 = đ‘Ĩ𝑛 −
đ‘Ĩ𝑛3 + 2đ‘Ĩ𝑛2 + 10đ‘Ĩ𝑛 − 20
3đ‘Ĩ𝑛2 + 4đ‘Ĩ𝑛 + 10
đ‘Ĩ𝑛+1
2(đ‘Ĩ𝑛3 + đ‘Ĩ𝑛2 + 10)
=
3đ‘Ĩ𝑛2 + 4đ‘Ĩ𝑛 + 10
We can see that f(1)=-7<0 and f(2)=16 >0. So, our root will lie between (1,2). Since initial value
đ‘Ĩ0 = 1.2 so,
For First approximation put n=0
đ‘Ĩ0+1
2(đ‘Ĩ03 + đ‘Ĩ02 + 10)
=
3đ‘Ĩ02 + 4đ‘Ĩ0 + 10
2((1.2)3 + (1.2)2 + 10) 26.336
đ‘Ĩ1 =
=
= 1.37741
3(1.2)2 + 4(1.2) + 10
19.12
Similarly,
For 2nd iteration put n=1
đ‘Ĩ2 =
29.02105
= 1.36883
21.20136
đ‘Ĩ3 =
28.87692
= 1.36881
21.0964
đ‘Ĩ4 =
28.87656
= 1.36880
21.09614
For 3rd iteration put n=2
For 4th iteration put n=3
Hence , the root is 1.3688.
Section in charge : Husna Muzaffar
𝐐𝐮𝐞đŦ𝐭đĸ𝐨𝐧# 𝟏:
Marks 10
Solve the system of equations by using Crout’s method.
2đ‘Ĩ + 5đ‘Ļ + 3𝑧 = 16
3đ‘Ĩ + đ‘Ļ + 2𝑧 = 11
−3đ‘Ĩ + 7đ‘Ļ + 8𝑧 = 10
Solution:
Solution:
𝟐𝒙 + 𝟐𝒚 + 𝟑𝒛 = 𝟏𝟔 − − − − − (𝟏)
𝟑𝒙 + 𝒚 + 𝟐𝒛 = 𝟏𝟏 − − − − − (𝟐)
−𝟑𝒙 + 𝟕𝒚 + 𝟖𝒛 = 𝟏𝟎 − − − − − (𝟑)
Convert the given system in the matrix form.
16
2 5 3 đ‘Ĩ
[ 3 1 2] [đ‘Ļ] = [11]
10
−3 7 8 𝑧
Now,
đ‘Ĩ
16
2 5 3
A=[ 3 1 2] , x = [đ‘Ļ] , B = [11]
𝑧
10
−3 7 8
Crouts’s method. For LU decomposition
Let đŋ = 𝐴𝑈
𝑙11
2 5 3
[ 3 1 2] = [𝑙21
𝑙31
−3 7 8
0
𝑙22
𝑙32
𝑙11
2 5 3
[ 3 1 2] = [𝑙21
𝑙31
−3 7 8
𝑙11 đ‘ĸ12
𝑙21 đ‘ĸ12 + 𝑙22
𝑙31 đ‘ĸ12 + 𝑙32
𝑙11=2
𝑙11 đ‘ĸ12 = 5 => đ‘ĸ12 = 5⁄2
0 1
0 ] [0
𝑙33 0
đ‘ĸ12
1
0
đ‘ĸ13
đ‘ĸ23 ]
1
𝑙11 đ‘ĸ13
𝑙21 đ‘ĸ13 + 𝑙22 đ‘ĸ23 ]
𝑙31 đ‘ĸ13 + 𝑙32 đ‘ĸ23 + 𝑙33
𝑙11 đ‘ĸ13 = 3 => đ‘ĸ13 = 3⁄2
𝑙21 = 3
𝑙21 đ‘ĸ12 + 𝑙22 = 1 => 3(5⁄2)+ 𝑙22 =1
15
+ 𝑙22 = 1
2
𝑙22 = 1 −
15 −13
=
2
2
𝑙21 đ‘ĸ13 + 𝑙22 đ‘ĸ23 = 2
3
−13
(3) ( ) + (
đ‘ĸ )=2
2
2 23
9 13
− đ‘ĸ =2
2 2 23
−
13
9
đ‘ĸ23 = 2 −
2
2
−
13
4−9
đ‘ĸ23 =
2
2
−
13
−5
đ‘ĸ23 =
2
2
đ‘ĸ23 =
5
13
𝑙31 = −3
𝑙31 đ‘ĸ12 + 𝑙32 = 7
5
−3 ( ) + (𝑙32 ) = 7
2
−15
+ 𝑙32 = 7
2
𝑙32 = 7 +
𝑙32 =
15
2
29
2
𝑙31 đ‘ĸ13 + 𝑙32 đ‘ĸ23 + 𝑙33 = 8
3
(−3)( ) +
2
29
2
5
+ đĩ + 𝑙33=8
90
𝑙33 =13
A = đŋ𝑈
2
2 5 3
[ 3 1 2] = [ 3
−3 7 8
−3
5
−13
2
29
2
0 1 5
2
0][
0 1
90
13 0 0
3
2
5 ]=[
13
1
2 5 3
3 1 2]
−3 7 8
𝐀𝒙 = 𝑩 & 𝑨 = đ‘ŗđ‘ŧ => đ‘ŗ𝒖𝒙 = 𝐁
đ‘Ļ1
2
0
0
16
đ‘Ļ
[ 3 −6.5
]
[
]
=
[
0
2
11]
−3 14.5 6.9231 đ‘Ļ3
10
2đ‘Ļ1 = 16 − − − − − − − − − − − (i)
3đ‘Ļ1 − 6.5đ‘Ļ2 = 11 − − − − − − − − − − − (ii)
−3đ‘Ļ1 + 14đ‘Ļ2 + 6.9231đ‘Ļ3 = 10 − − − − − − − − − − − (iii)
đ‘Ļ1 = 8
Put 𝒚𝟏 = 𝟖 đĸ𝐧 𝐞đĒ𝐮𝐚𝐭đĸ𝐨𝐧 (đĸđĸ)
3(8) − 6.5đ‘Ļ2 = 11
24 − 6.5đ‘Ļ2 = 11
−6.5đ‘Ļ2 = 11 − 24
đ‘Ļ2 = 2
Put
đ‘Ļ1 = 8 and đ‘Ļ2 = 2 in equation (iii) we get
đ‘Ļ3 = 0.723
1. UX=Y
īƒĻ
īƒ§
X =īƒ§
īƒ§
īƒ¨
īƒļ
īƒˇ
īƒˇ
īƒˇ
īƒ¸ in UX = Y
x
y
z
â–Ē z = y3 = 0.722
â–Ē
y=
( y2 − u23 īƒ— z ) = 2 − 0.385 īƒ— 0.722 ī‚ģ 1.722
â–Ē x = ( y1 − u12 īƒ— y − u13 īƒ— z ) = 8 − 2.5 īƒ—1.722 −1.5 īƒ— 0.722 = 2.611
x = 2.611, y = 1.722, and z = 0.722
𝐐𝐮𝐞đŦ𝐭đĸ𝐨𝐧# 𝟐:
Solve the following system of equations by using Jacobi′ s iterative method for
the first three iterations by taking initial starting of solution vector as (0,0,0).
4đ‘Ĩ − đ‘Ļ − 𝑧 = 3
−2đ‘Ĩ + 6đ‘Ļ + 𝑧 = 9
−đ‘Ĩ + đ‘Ļ + 7𝑧 = −6
Solution:
1st Iteration: Put initial values x=0, y=0 and z=0 in equations (i), (ii) and (iii)
1
3
x = īƒŠīƒĢ3 + 2 ( 0 ) + 2 ( 0 ) īƒšīƒģ = = 0.375
8
8
1
9
y = īƒŠīƒĢ9 + 2 ( 0 ) − 0 īƒšīƒģ = = 1.5
6
6
1
6
z = īƒŠīƒĢ6 + 2 ( 0 ) − 0 īƒšīƒģ = = 0.8571
7
7
2nd Iteration
Put the values x=0.375, y=1.5 and z=0.8571 in equations (i), (ii) and (iii)
1
7.7142
x = īƒŠīƒĢ3 + 2 (1.5) + 2 ( 0.8571) īƒšīƒģ =
= 0.9642
8
8
1
8.8929
y = īƒŠīƒĢ9 + 2 ( 0.375) − 0.8571īƒšīƒģ =
= 1.4822
6
6
1
5.25
z = īƒŠīƒĢ6 + 2 ( 0.375) − 1.5īƒšīƒģ =
= 0.75
7
7
3rd Iteration
Put the values x=0.9642, y=1.4822 and z=0.75 in equations (i), (ii) and (iii)
1
7.4644
x = īƒŠīƒĢ3 + 2 (1.4822 ) + 2 ( 0.75) īƒšīƒģ =
= 0.9330
8
8
1
10.1784
y = īƒŠīƒĢ9 + 2 ( 0.9642 ) − 0.75īƒšīƒģ =
= 1.6964
6
6
1
6.4462
z = īƒŠīƒĢ6 + 2 ( 0.9642 ) − 1.4822īƒšīƒģ =
= 0.9208
7
7
(Fall-2023)
MTH-603 Assignment No.1
Section In charge: Zulfiqar Ahmad Noor
Question 1
10 Marks
Use Newton Raphson method to find the root of f ( x) = x 3 − 2 x + 2 with x0 = 0.2
(Perform only three iterations)
Solution:
Question 2
Solve the system of equation by Jacobi method starting with (0,0,0)
10 x + y + z = 24
− x + 20 y + z = 21
− x − 2 y + 100 z = 300
(Perform only two iteration)
Solution:
10 Marks
Download