Answer to Question #278338 in MatLAB for mani

Question #278338

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


i. Please report the value of x after 2 iterations


ii. Please report the converged solution, where error is less than 1e-6.


iii. Please report the number of iterations required to reach this converged solution.


1
Expert's answer
2021-12-11T18:45:45-0500
% 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);
iter = 1;
while abs(xi - xi1) > tol
    if iter == 2
        if isreal(xi)
            fprintf("The value of x after %d iterations is %f\n", iter, xi);
        else
            fprintf("The value of x after %d iterations is %f + (%f)j\n", ...
                     iter, real(xi), imag(xi));
        end
    end
    xi1 = xi;
    xi = g(xi1);
    iter = iter + 1;
end
if isreal(xi)
    fprintf("The converged solution is %f\n", xi);
else
    fprintf("The converged solution is %f + (%f)j\n", real(xi), imag(xi));
end
fprintf("Reached in %d iterations\n", iter);


>> scr01
The value of x after 2 iterations is 12.854749 + (11.698557)j
The converged solution is 1.744372 + (12.428368)j
Reached in 8 iterations
>> f(xi)
ans =
   0.0000e+00 + 1.1369e-13i

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS