I'd like to solve y = (x+1)**3 - 2
for x
in sympy to find its inverse function.
I tried using solve
, but I didn't get what I expected.
Here's what I wrote in IPython console in cmd (sympy 1.0 on Python 3.5.2):
In [1]: from sympy import *
In [2]: x, y = symbols('x y')
In [3]: n = Eq(y,(x+1)**3 - 2)
In [4]: solve(n,x)
Out [4]:
[-(-1/2 - sqrt(3)*I/2)*(-27*y/2 + sqrt((-27*y - 54)**2)/2 - 27)**(1/3)/3 - 1,
-(-1/2 + sqrt(3)*I/2)*(-27*y/2 + sqrt((-27*y - 54)**2)/2 - 27)**(1/3)/3 - 1,
-(-27*y/2 + sqrt((-27*y - 54)**2)/2 - 27)**(1/3)/3 - 1]
I was looking at the last element in the list in Out [4]
, but it doesn't equal x = (y+2)**(1/3) - 1
(which I was expecting).
Why did sympy output the wrong result, and what can I do to make sympy output the solution I was looking for?
I tried using solveset
, but I got the same results as using solve
.
In [13]: solveset(n,x)
Out[13]: {-(-1/2 - sqrt(3)*I/2)*(-27*y/2 + sqrt((-27*y - 54)**2)/2 - 27)**(1/3)/
3 - 1, -(-1/2 + sqrt(3)*I/2)*(-27*y/2 + sqrt((-27*y - 54)**2)/2 - 27)**(1/3)/3 -
1, -(-27*y/2 + sqrt((-27*y - 54)**2)/2 - 27)**(1/3)/3 - 1}