exp(-x) - sinx = 0

10 ビュー (過去 30 日間)
reza
reza 2014 年 1 月 10 日
編集済み: Youssef Khmou 2014 年 1 月 11 日
hi, i'm planning to reach the root of this function:
exp(-x) - sinx = 0;
here is my code:
------------------------------
x0 = input('please enter x0 ::: ');
eps = input('please enter steps ::: ');
% eps is the step
iterator = 0;
for i=0:eps:x0
x=x+exp(-x) - sin(x);
iterator = iteratio + 1;
end
disp('root ::: '); disp(x);
disp('iterate count ::: '); disp(iterator);
------------------------------
well i can't make it work. can you help me with that?

回答 (2 件)

Mischa Kim
Mischa Kim 2014 年 1 月 10 日
Try the fzero function. Unless, of course, you would like to do it on your own.

reza
reza 2014 年 1 月 10 日
Now it's working,
x0 = input('please enter x0 ::: '); eps = input('please enter steps ::: '); iterator = 0; x=0; iterator = 0; for i=0:eps:x0 x=x+exp(-x) - sin(x); iterator = iterator + 1; end disp('root ::: '); disp(x); disp('iterate count ::: '); disp(iterator);
thanks to all.
  6 件のコメント
Mischa Kim
Mischa Kim 2014 年 1 月 11 日
By solutions you mean roots? Here is the function plot:
Youssef  Khmou
Youssef Khmou 2014 年 1 月 11 日
編集済み: Youssef Khmou 2014 年 1 月 11 日
alright, infinite number of solutions with period of ~3.1
thanks

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

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by