Answer to Question #278312 in MatLAB for mani

Question #278312

Find the root of the following equation using the Newton-Raphson method. Choose the



initial guess as 𝑥



(0) = 10. Choose the error tolerance as tol=1e-6. In other words, the



iterations should be stopped when the error



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:50-0500

clc;

clear all;

close all;


% function 

f = @(x) x^2.5 + 23*x^1.5 -50*x + 1150;


% derivative

f_prime = @(x) 2.5*x^1.5 + 23*1.5*x^0.5 - 50;


% function for next iteration according to the Newton-Raphson method

g = @(x) x - f(x) / f_prime(x);


% tolerance

tol = 1e-6;


x_old = 10; % previous value of x

x = [x_old]; % array to store x after each iteration


x_new = g(x_old); % new value of x


ii = 0;

while abs(x_new - x_old) > tol

  x_old = x_new;

  x_new = g(x_old);

  x = [x, x_new]; % append array with current iteration

end


fprintf('The value of x after 2 iterations: %f%+fj\n', real(x(3)), imag(x(3)))

fprintf('The converged solution: %f%+fj\n', real(f(x(end))), imag(f(x(end))))

fprintf('The number of iterations required to reach this converged solution: %i\n', length(x)-1)


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