필터 지우기
필터 지우기

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