Well, unfortunately, it looks like that particular equation is not implemented. 
 However, you should know a few things.  First, don't use == for equality.  
That is strictly a boolean comparison operator from Python.  See 
http://docs.sympy.org/gotchas.html#double-equals-signs.

Second, it is best to pass the variable that you want to solve for to solve.  
Otherwise, it tries to solve for all of them, and (I am assuming) you don't 
really care about solving for gamma.  

Third, be careful about using 1/2.  This will give you either the floating 
point number 0.5 or the integer 0, depending on if "from __future__ import 
division" was executed.  See 
http://docs.sympy.org/gotchas.html#python-numbers-vs-sympy-numbers.  The best 
workaround is to use S(1)/2 first, so that it becomes SymPy's Rational(1, 2) 
(sorry about these limitations, but that is the cost of developing over Python).

So doing it correctly, I get:

In [7]: solve(S(1)/2 - 3*cos(x)/4 + cos(x)**3/4 - gamma, x)
...
NotImplementedError: Unable to solve the equation(tsolve: at least one Function 
expected at this point

It should be able to do it but it can't.  Chris, does this work better on any 
of the 1694 issues?

If you don't mind doing a little work on your own (because solve() currently 
isn't smart enough to do it itself), you can use this clever workaround to 
obtain the solutions:

In [13]: sols = solve(S(1)/2 - 3*y/4 + y**3/4 - gamma, y)

In [14]: print [solve(i, x) for i in [cos(x) - j for j in sols]]

[[acos(1/((1/2 - I*3**(1/2)/2)*(1 - 2*gamma + (-4*gamma + 
4*gamma**2)**(1/2))**(1/3)) + (1 - 2*gamma + (-4*gamma + 
4*gamma**2)**(1/2))**(1/3)/2 - I*3**(1/2)*(1 - 2*gamma + (-4*gamma + 
4*gamma**2)**(1/2))**(1/3)/2)], [acos(1/((1/2 + I*3**(1/2)/2)*(1 - 2*gamma + 
(-4*gamma + 4*gamma**2)**(1/2))**(1/3)) + (1 - 2*gamma + (-4*gamma + 
4*gamma**2)**(1/2))**(1/3)/2 + I*3**(1/2)*(1 - 2*gamma + (-4*gamma + 
4*gamma**2)**(1/2))**(1/3)/2)], [acos(-1/(1 - 2*gamma + (-4*gamma + 
4*gamma**2)**(1/2))**(1/3) - (1 - 2*gamma + (-4*gamma + 
4*gamma**2)**(1/2))**(1/3))]]

Aaron Meurer

On Aug 31, 2010, at 5:25 AM, Dan wrote:

> Hi folks,
> 
> I'm not an expect in Mathematica but I have managed to solve a trig.
> expression in Wolfram Alpha first time round, http://bit.ly/cLVFcP. I
> like to stay with Python as much as I can, but haven't been able to do
> this using Sympy. Could you please point out where I'm going wrong in
> the following?
> 
> var('gamma')
> solve([1/2 - 3*cos(x)/4 + cos(x)**3/4 - gamma == 0])
> 
> Best,
> 
> Dan

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to