Newton's method

20 views (last 30 days)
ilaria scanu
ilaria scanu on 12 Jun 2022
Answered: Chunru on 13 Jun 2022
URGENT HELP!!
"Write a matlab program to calculate R^(1/3), for all R >0 with a use of iterative Newton method. Examine graphically the chosen function f, in order to check for which points this method will converge."
This is my code, but I think it's not correct:
x = linspace(0,10)
f=@(x) x^(1/3);
df=@(x) (1/3)*x^(-2/3);
n=10; %number of iterations
for i=2:n
x(i)=x(i-1)-f(x(i-1))/df(x(i-1));
end
  2 Comments
Torsten
Torsten on 12 Jun 2022
Hint: In Newton's method, take
f(x) = x^3 - R
as the function.
Sam Chak
Sam Chak on 12 Jun 2022
Edited: Sam Chak on 12 Jun 2022
If you need to find R^(1/3) and the value of R is given, then why do you create a function x^(1/3)? Is R a variable, something like the user input?
The rhetorical question.
If you want to find R^(1/3) = x, which is x exactly, then you can make both sides
[R^(1/3)]^3 = x^3
R = x^3
Now, this is a cubic equation. You can solve the polynomial problem.

Sign in to comment.

Accepted Answer

Chunru
Chunru on 13 Jun 2022
R = 5; % input
f=@(x) x.^3 - R; % f(x) = 0
df=@(x) 3*x.^2; % df/dx
n=10; %number of iterations
x(1) = 1; % initial vaule
for i=2:n
x(i) = x(i-1) - f(x(i-1))/df(x(i-1));
end
x
x = 1×10
1.0000 2.3333 1.8617 1.7220 1.7101 1.7100 1.7100 1.7100 1.7100 1.7100
R.^(1/3)
ans = 1.7100

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!