Professional Documents
Culture Documents
Newton Raphson (NM)
Newton Raphson (NM)
Newton Raphson (NM)
f(xi-1)
f(x i )
xi +1 = x i -
f ′(xi )
θ
x
xi+ 2 xi+ 1 xi
Derivation
f(x) AB
tan(α ) =
AC
f(xi) B
f ( xi )
f ' ( xi ) =
xi − xi +1
α A f ( xi )
C
x xi +1 = xi −
xi+1 xi f ' ( xi )
Algorithm for Newton-Raphson
Method
Step 1
Evaluate df/dx = f′ (x) symbolically: that is find an analytical
expression for the first derivative of the function with
respect to x.
Newton-Raphson Method: Step 2
Calculate the next estimate of the root
f(xi )
xi +1 = xi -
f'(xi )
xi +1- xi
∈a = x 100
xi +1
Step 3
• Find if the absolute relative approximate error is
greater than the pre-specified relative error tolerance.
f ( x ) = x 3-0.165 x 2
+3.993 x10 - 4
Iteration #1
x0 = 0.02
f ( x0 )
x1 = x0 −
f ' ( x0 )
3.413x 10 −4
x1 = 0.02 −
− 5.4 x10 −3
= 0.08320
∈a = 75 .96 %
Iteration #2
x1 = 0.08320
f ( x1 )
x2 = x1 −
f ' ( x1 )
− 1.670 x10 −4
x2 = 0.08320 −
− 6.689 x10 −3
= 0.05824
∈a = 42.86%
Iteration #3
x2 = 0.05824
f ( x2 )
x3 = x2 −
f ' ( x2 )
3.717 x10 −5
= 0.05284 −
− 9.043 x10 −3
= 0.06235
∈a = 6.592 %
Newton’s Method: computer algo
Do while |x2 - x1| >= tolerance value 1
or |f(x2)|>= tolerance value 2
or f’(x1) ~= 0
Set x2 = x1 - f(x1)/f’(x1)
Set x1 = x2;
END loop
Example 2:
• Let us solve the following
problem:
x5 + x3 + 4x2 - 3x – 2 = 0
Then f(x) = x5 + x3 + 4x2 - 3x – 2
df/dx = 5x4 + 3x2 + 8x - 3
• Let us first draw a graph and
see where are the roots;
• The roots are between (-1.7,-
1.3), (-1,0), & (0.5,1.5)
• Then let us write a computer
program in MATLAB that
will compute the root using
Newton-Raphson method.
Computer Program in MATLAB
% A program that Uses Newton-Raphson method
% to find the roots of x = x^3 +x^2 -3x -3
% Input: x0 = initial guess;
% n = number of iterations; default: n = 10;
% Output: x = estimate of the root;
n = 10; x0 = -2.0
x = x0; % Initial Guess
for k=1:n
f = x^5 + x^3 + 4*x^2 - 3*x - 2;
dfdx = 5*x^4 + 3*x^2 + 8*x - 3;
x = x - f/dfdx;
fprintf('%3d %12.3e %12.3e %18.15f\n',k-1,f,dfdx,x);
end
Newton’s Method
Result of the computer program: x0 = -2.0 and iterations n = 10.
5.00E-06
2.50E-06
0.00E+00
-0.03 -0.02 -0.01 0 0.01 0.02 0.03
-2.50E-06
0.02
-5.00E-06
f ( x ) = x 3 − 0.03x 2 + 2.4x10−6 = 0
-7.50E-06
-1.00E-05
Division by
zero
Drawbacks (continued)
1.5
f(x)
1
0.5
x
0
-2
-0.0630690 0.54990 2 4
4.462 6
7.539828 10
-0.5
-1
-1.5
f ( x ) = Sin x = 0
Root Jumping
Drawbacks (continued)
6
f(x)
5
4
f ( x) = x2 + 2 = 0
3
3
2
2
11
4
x
0
-2 -1 0 1 2 3
-1.75 -0.3040 0.5 3.142
-1
for k=1:n
f = x^3 - 4*x^2 + x – 10.0;
dfdx = 3*x^2 - 8*x + 1.0;
x = x - f/dfdx;
fprintf('%3d %12.3e %12.3e %18.15f\n',k-1,f,dfdx,x);
end
Example 3: results
Result of the computer program: x0 = -2.0 and iterations n = 10.
for k=1:n
f = exp(x) + x – 10.0;
dfdx = exp(x) + 1.0;
x = x - f/dfdx;
fprintf('%3d %12.3e %12.3e %18.15f\n',k-1,f,dfdx,x);
end
Example 4: results
Result of the computer program: x0 = -2.0 and iterations n = 10.