Find the root of the following equation using the Newton-Raphson method. Choose the initial guess as x(0) = 10. Choose the error tolerance as tol=1e-6. In other words, the iterations should be stopped when the error
|x(1) − x(i-¹)| ≤ tol.
x^2.5 23x^1.5 - 50x + 1150 = 0
scr01.m:
% function f(x)
f = @(x) x^2.5 + 23*x^1.5 -50*x + 1150;
% function f'(x)
fp = @(x) 2.5*x^1.5 + 23*1.5*x^0.5 - 50;
% function g(x) = x - f(x)/f'(x)
g = @(x) x - f(x) / fp(x);
tol = 1e-6;
xi1 = 10; % x(i-1)
xi = g(xi1);
while abs(xi - xi1) > tol
xi1 = xi;
xi = g(xi1);
end
display(xi)
Command window:
>> scr01
xi =
1.7444 +12.4284i
>> f(xi)
ans =
0.0000e+00 + 1.1369e-13i
Comments
Leave a comment