Root of exponential function not complete

I am trying to find the roots of the equation
exp(-0.5*x)-0.4/(1+0.5*x)
and with the following code, only one of the 2 roots is found:
syms x
eq1=exp(-0.5*x)-0.4/(1+0.5*x)==0;
sol=solve(eq1,x);
vpa(sol,6)
ans =
-1.64929
But there is another root of this equation which is found using the fzero command
eq1=@(x) exp(-0.5*x)-0.4/(1+0.5*x);
sol=fzero(eq1,[-10 10]);
vpa(sol,6)
ans =4.04463
Again the given solution is only one of the 2. How can I get both of them at any time with one command? Thanks

回答 (1 件)

madhan ravi
madhan ravi 2018 年 10 月 28 日
編集済み: madhan ravi 2018 年 10 月 28 日

0 投票

syms x
eq1=exp(-0.5*x)-0.4/(1+0.5*x)==0;
fplot(exp(-0.5*x)-0.4/(1+0.5*x)) %always compare the result with the graph
solution1=vpasolve(eq1,x,[-2 0])
solution2=vpasolve(eq1,x,[0 5])
grid on

7 件のコメント

Needless Needless Also
Needless Needless Also 2018 年 10 月 28 日
Thanks for answering, but vpasolve also gives only one solution, the same as fzero (4.0446). The -1.64929 is not found
madhan ravi
madhan ravi 2018 年 10 月 28 日
Did you see the graph it appears there’s only one solution right?
Needless Needless Also
Needless Needless Also 2018 年 10 月 28 日
編集済み: Needless Needless Also 2018 年 10 月 28 日
Sorry, but I see two roots. Am I wrong?
madhan ravi
madhan ravi 2018 年 10 月 28 日
Ah i missed it
madhan ravi
madhan ravi 2018 年 10 月 28 日
See edited specify the intervals
Needless Needless Also
Needless Needless Also 2018 年 10 月 28 日
This works but, what about any other equation? Shouldn't it be a pretty simple task for MatLab to find the roots just with vpasolve(eq1,x)? Of course I can always check the graph but I think you get what I mean.
madhan ravi
madhan ravi 2018 年 10 月 28 日
Yes I know even I have thought about it ;) but yet no discernible idea in my mind though

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

カテゴリ

ヘルプ センター および File ExchangeGet Started with Symbolic Math Toolbox についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 10 月 28 日

コメント済み:

2018 年 10 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by