Solve function not giving complex solutions

5 views (last 30 days)
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.

Accepted Answer

Yoav B
Yoav B on 8 Feb 2016
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

More Answers (1)

Star Strider
Star Strider on 6 Feb 2016
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 Comments
Star Strider
Star Strider on 6 Feb 2016
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!