Newton's method

2 次查看(过去 30 天)
ilaria scanu
ilaria scanu 2022-6-12
回答: Chunru 2022-6-13
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 个评论
Torsten
Torsten 2022-6-12
Hint: In Newton's method, take
f(x) = x^3 - R
as the function.
Sam Chak
Sam Chak 2022-6-12
编辑:Sam Chak 2022-6-12
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.

请先登录,再进行评论。

采纳的回答

Chunru
Chunru 2022-6-13
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by