Newton's method

22 Ansichten (letzte 30 Tage)
ilaria scanu
ilaria scanu am 12 Jun. 2022
Beantwortet: Chunru am 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 Kommentare
Torsten
Torsten am 12 Jun. 2022
Hint: In Newton's method, take
f(x) = x^3 - R
as the function.
Sam Chak
Sam Chak am 12 Jun. 2022
Bearbeitet: Sam Chak am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chunru
Chunru am 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

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by