Newton's method

21 visualizaciones (últimos 30 días)
ilaria scanu
ilaria scanu el 12 de Jun. de 2022
Respondida: Chunru el 13 de Jun. de 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 comentarios
Torsten
Torsten el 12 de Jun. de 2022
Hint: In Newton's method, take
f(x) = x^3 - R
as the function.
Sam Chak
Sam Chak el 12 de Jun. de 2022
Editada: Sam Chak el 12 de Jun. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Chunru
Chunru el 13 de Jun. de 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

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by