Solve function not giving complex solutions

Hello. For some reason solve does not seem to give all the existing solutions to simple equations. For instance, entering:
syms x
s=solve(x^2+1,x)
I get:
Warning: Explicit solution could not be found. > In solve at 179
s =
[ empty sym ]
The two solution I expected to see are of course +i and -i. I use Matlab R2014A. Any idea what might be causing this? Thanks in advance.

 採用された回答

Yoav B
Yoav B 2016 年 2 月 8 日

1 投票

I contacted Mathworks support. It turns out that all is needed here is to clear the default assumptions for symbolic variables. The following code would do the job.
syms x clear

1 件のコメント

Star Strider
Star Strider 2016 年 2 月 8 日
Interesting. Appreciate your following this up.

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

その他の回答 (1 件)

Star Strider
Star Strider 2016 年 2 月 6 日

1 投票

I got the same result. The Symbolic Math Toolbox very much seems to need tweaking.
Using vpasolve returns the correct result:
syms x
s = vpasolve(x^2 + 1,x)
s =
1.0i
-1.0i

5 件のコメント

Yoav B
Yoav B 2016 年 2 月 6 日
編集済み: Yoav B 2016 年 2 月 6 日
Thank you. Well, I gues I'll use vpasolve instead. The funny thing is that even the code given in the documentation
syms x
solve(x^4 + 1 == 2*x^2 - 1)
doesn't work. I wonder how this is possible.
Star Strider
Star Strider 2016 年 2 月 6 日
My pleasure.
Beats me. I get the same result (in R2015b).
You discovered this, so I’ll let you report it to Contact Support as a quite definite bug. Include the URL of this thread in your message to them so you don’t have to repeat all of it.
Before you contact them, have MATLAB open, and type ver in the Command Window. Copy-paste the output to the appropriate window in the web page.
Best I can do!
Meanwhile, if you desperately need to do symbolic calculations, the Wolfram Alpha website will let you do an incredible number of things for the cost of the electricity and communications time to type them in and copy the result. I use it frequently when the Symbolic Math Toolbox (that is not free) leaves me in the lurch.
John D'Errico
John D'Errico 2016 年 2 月 6 日
編集済み: John D'Errico 2016 年 2 月 6 日
Not a bug as far as I can see. Works fine. R2015b.
syms x
s=solve(x^2+1==0,x)
s =
-1i
1i
s=solve(x^2+1,x)
s =
-1i
1i
Star Strider
Star Strider 2016 年 2 月 6 日
I got the same
s =
Empty sym: 0-by-1
result OP got in R2015b. That’s the reason I suggested the vpasolve approach. I don’t know what the problem is.
Yoav B
Yoav B 2016 年 2 月 7 日
Thank you both. I'll report it.

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

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

タグ

質問済み:

2016 年 2 月 6 日

コメント済み:

2016 年 2 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by