the function 'solve' doesn't give all the solutions.

2 ビュー (過去 30 日間)
Richard
Richard 2013 年 10 月 9 日
コメント済み: Richard 2013 年 10 月 10 日
% this does not give all the solutions
syms u;
solve(1-0.99-(u+1)*exp(-u));
double(ans)
see the short 3-line code there, try it out.
The solutions should be u1=-0.996308, and u2=6.63835
But this code only gives me u1, and mentions nothing about u2.
Can any one tells me why or which function should I use to get all the answers.
Thanks!
  2 件のコメント
Roger Stafford
Roger Stafford 2013 年 10 月 9 日
My very ancient version of 'solve' gives both your solutions. I don't know why your version should give only one of them.
Walter Roberson
Walter Roberson 2013 年 10 月 9 日
I have noticed the MuPAD's solve() seems to have difficulty in finding solutions involving LambertW.

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

採用された回答

Friedrich
Friedrich 2013 年 10 月 9 日
編集済み: Friedrich 2013 年 10 月 9 日
Hi,
seems like you are interested in real solutions only. So use:
>> solve(1-0.99-(u+1)*exp(-u),'Real',true)
ans =
- lambertw(0, -exp(-1)/100) - 1
- lambertw(-1, -exp(-1)/100) - 1
If you dont set Real to true MATLAB solves it Complex which would give an infinite amount of solutions. When you use MuPAD Notepad you will obtain:
So only k=0 and k =-1 give Real solutions.
UPDATE: Since you want real solutions only its might be better to use a numeric solver:
>> feval(symengine,'numeric::solve','1-0.99-(u+1)*exp(-u)','AllRealRoots')
ans =
[ [u == -0.99630759688740599414645321772374], [u == 6.6383520679938122693712394050244]]
  1 件のコメント
Richard
Richard 2013 年 10 月 10 日
編集済み: Richard 2013 年 10 月 10 日
Yes. You are right. I am only interested in the real solutions. I use this occasionally when I don't have an equations solver. But when I have internet access, I also like to use Wolfram Alpha. It is a cool online mathematics tool! Thanks so much for your help and information, Friedrich!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by