Ee332 - Lab-Sheets - Student Workbook
Ee332 - Lab-Sheets - Student Workbook
METHOD
Name:
Abdullah Khalid AL Howays Grade (20)
Registration Number:
1847830
BA
Lab Section:
Objectives
1. To determine roots of an equation in single variable using Newton-Raphson method.
2. To understand the MATLAB implementation of the Newton-Raphson method.
3. To analyze of results using different initial values and error tolerance.
Algorithm
𝑓 𝑥𝑖
𝑥𝑖+1 𝑥𝑖
𝑓 𝑥𝑖
Termination Criteria:
where 𝑥𝑖+1 is the root of current (new) iteration and 𝑥𝑖 is the root of previous (old) iteration. The
notation 𝜀𝑎,𝑖+1 % represents the error for current estimate of the root (𝑥𝑖+1 ).
Pseudocode
FUNCTION NewtRaph(x0, es, imax)
i = 1
xi = x0
eai = ∞
DO
xi+1 = xi f(xi)/f (xi)
IF xi+1 ≠ 0 THEN
eai+1 = ABS((xi+1 xi)/xi+1)*100
END IF
DISPLAY i, xi, f(xi), f (xi), eai
IF eai < es OR iter imax EXIT
i = i + 1
END DO
NewtRaph = xi
END NewtRaph
Lab Work
function y func Z X
X 12 6 x 14
L x n
3 2
function y dfunc Z X
Yi 3 X n
2 4 X 6
initial guess
Xo 3 o i
tolerance
tolerance 2
Iterations
iteration o
fromthe secondIterations
while I
liberation liberation 1 i
Iteration 𝒙𝒊 𝒇 𝒙𝒊 𝒇′ 𝒙𝒊 ) 𝜺𝒂,𝒊 %
0 3 oooo 5 oooo 9.0000
1 3.5555 2.3319 17.7037 15.62
2 3 42380.1480 15.4725 3.85
3 3.41420 0007 15.3145 O 28
5. Repeat step 4 until percentage approximate relative error ( a (%) ) is less than s = 0.2% .
Iteration 𝒙𝒊 𝒇 𝒙𝒊 𝒇′ 𝒙𝒊 ) 𝜺𝒂,𝒊 %
0 3 oooo 5 oooo 9.0000
1 3.5555 2.3319 17.7037 15.62
2 3 42380.1480 15.4725 3.85
3
3.414260 0007 15.3145 O 28
4 3.41424 0.0000 15.3137 O 0002
𝒙𝒊 𝒇 𝒙𝒊 𝒇′ 𝒙𝒊 ) 𝜺𝒂,𝒊 %
Iteration
0 1 oooo 7 oooo 1 oooo
1 8 oooo 588.0000218 oooo 87.50
2 5.3027 169.5309 99.5685 50.87
3 3 oooo 46.9805 47.2824 47.2g
4 2.6064 11.6563 24.8071 38.12
5 2.1366 2.0642 16.2416 21.99
6 2.0095 0.1337 14.1523 6.32
7 2 oooo 0.00071 14.0008 0.47
1. How does the choice of the initial guess affect the solution?