x(i+1)=y(i​)-((f(y(i)​)/d(y(i)))​); // error in this line..

1 回表示 (過去 30 日間)
Umar Bhai
Umar Bhai 2019 年 4 月 4 日
回答済み: KSSV 2019 年 4 月 4 日
% Program Code of Newton-Raphson Method in MATLAB
a=input('Enter the function in the form of variable x:','s');
y(1)=input('Enter Initial Guess:');
error=input('Enter allowed Error:');
f=inline(a);
dif=diff(sym(a));
d=inline(dif);
for i=1:100
x(i+1)=y(i)-((f(y(i))/d(y(i))));x(i+1)=y(i)-((f(y(i))/d(y(i))));
error(i)=abs((y(i+1)-y(i))/y(i));
if err(i)<error
break
end
end
root=y(i);
  1 件のコメント
KSSV
KSSV 2019 年 4 月 4 日
You need to rethink on your code. There is no y(i+1) and you are extracting it. Google for Newton Raphson code and you will get. LEarn from it.

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2019 年 4 月 4 日

カテゴリ

Help Center および File ExchangeNewton-Raphson Method についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by