Question

MATLAB Newtons Method. Use initial guess of xo. Use Matlab. x2-3x2+ 3x - 1 = 0

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Script:

close all
clear
clc

syms x
f = x^3 - 3*x^2 + 3*x - 1;
x0 = 0; tol = 1e-9;
newton_raphson(f, x0, tol);

function x = newton_raphson(f, x0, tol)
x = x0; xold = x0; num_iter = 0;
df = diff(f);
while true
num_iter = num_iter + 1;
x = x - subs(f,x)/subs(df,x); % Newton Update Rule
if abs(x - xold) < tol % Termination condition
break
end
xold = x;
end
fprintf('Solution: %.6f, Number of Iterations: %d, Tolerance: %e\n', x, num_iter, tol)
end

Output:

Solution: 1.000000, Number of Iterations: 50, Tolerance: 1.000000e-09

Add a comment
Know the answer?
Add Answer to:
MATLAB Newtons Method. Use initial guess of xo. Use Matlab. x2-3x2+ 3x - 1 = 0
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT