Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Assignment # 1

Mth603 – Numerical Analysis


VU ID: BC210417807
Name: Qurat-ul-ain

Question # 1:
Use Newton-Raphson method to find the root of 3
f ( x )=x −2 x +2
with x =0.2 (perform only three iterations).
0

Solution:
Given: f ( x )=x −2 x +2 and the initial guess, x =0.2 we will apply
3
0

Newton-Raphson formula to find a better approximation for


the root.
The formula for the Newton-Raphson Method is:
f ( xn)
x n+1=x n − '
f ( xn )

Where:
x n+1 is the next iteration.
xn is the current iteration.
f ( xn) is the function value at x n

'
f ( xn ) is the derivative of the function at xn

Finding the derivative of f(x)


3
f ( x )=x −2 x +2
f ' ( x )=3 x 2−2

First Iteration:

Newton-Raphson formula for n = 0


f ( x0 )
x 1=x 0− '
f ( x0)

Finding f ( x ) ∧f (x ) for n = 0
n
'
n

f ( x 0 ) =f ( 0.2 ) =( 0.2 )3−2 ( 0.2 ) +2

f ( x 0 ) =0.008−0.4+2=1.608
' ' 2
f ( x 0 )=f ( 0.2 )=3 ( 0.2 ) −2
'
f ( x 0 )=0.12−2=−1.88

f ( x0 )
x 1=x 0− '
f ( x0)

1.608
x 1=0.2−
−1.88
1.608
x 1=0.2+
1.88
x 1=0.2+0.855

x 1=1.055

Second Iteration:

Newton-Raphson formula for n = 1


f ( x1 )
x 2=x 1− '
f ( x1 )

Finding '
f ( x n ) ∧f (x n ) for n = 1
3
f ( x 1 ) =f ( 1.055 )= (1.055 ) −2 ( 1.055 ) +2

f ( x 1 ) =1.1742−2.11+2=1.064
f ' ( x 1 )=f ' ( 1.055 )=3 ( 1.055 )2−2
'
f ( x 1 )=3.339−2=1.339

f ( x1 )
x 2=x 1−
f ' ( x1 )

1.064
x 2=1.055−
1.339
x 2=1.055−0.7946

x 2=0.2604

Third Iteration:

Newton-Raphson formula for n = 2


f ( x2 )
x 3=x 2−
f ' ( x 2)

Finding '
f ( x n ) ∧f (x n ) for n = 2
f ( x 2 ) =f ( 0.2604 )=( 0.2604 )3−2 ( 0.2604 )+ 2

f ( x 2 ) =0.0176−0.5208+2=1.4968
' ' 2
f ( x 2 )=f ( 0.2604 )=3 ( 0.2604 ) −2
'
f ( x 2 )=0.2034−2=−1.7965

f ( x2 )
x 3=x 2− '
f ( x 2)

1.4968
x 3=0.2604−
−1.7965
1.4968
x 3=0.2604 +
1.7965
x 3=0.2604 +0.8331

x 3=1.093

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:
System is already in diagonally dominant form
10 x+ y+ z=24
−x +20 y + z=21
−x−2 y +100 z=300

Write the system iteration form


1
x= [ 24− y−z ] … … … … … ( 1 )
10
1
y= [ 21+ x−z ] … … … … … ( 2 )
20
1
z= [ 300+ x +2 y ] … … … … … (3 )
100

1
st
Iteration:

Put initial value x=0 , y=0 , z=0in equations (1), (2) and (3)
1
x= [ 24−0−0 ] = 24 =2.4
10 10
1
y= [ 21+0−0 ] = 21 =1.05
20 20
1 300
z= [ 300+0+ 2(0)]= =3
100 100

2
nd
Iteration:
Put the values x=2.4 , y =1.05 , z=3in equations (1), (2) and (3)
1
x= [ 24−1.05−3 ] = 19.95 =1.995
10 10
1
y= [ 21+2.4−3 ] = 20.4 =1.0 2
20 20
1 3 04.5
z=
100
[ 300+2.4 +2 ( 1.05 ) ] =
100
=3 .045

3
rd
Iteration:

Put the values x=1.995 , y=1.0 2 , z=3 .045in equations (1), (2) and (3)
1
x= [ 24−1.0 2−3 .045 ] = 19.9 35 =1.993
10 10
1
y= [ 21+1.995−3 .045 ] = 19.95 =0.997
20 20
1 304. 035
z=
100
[ 300+1.995+ 2 ( 1.0 2 ) ] =
100
=3.04 0

You might also like