Reputation: 579
I apologize if I am missing something fundamental. I am new in SymPy
.
The problem arises with the trigonometric identity
$$\sin^3x\cos^3 x = \frac{3\sin 2 x-\sin 6x}{32}$$
With Mathematica's Simplify
Simplify[Sin[x]^3 Cos[x]^3 == (3 Sin[2 x] - Sin[6 x])/32] (*returns True*)
With SymPy
import sympy as sy
sy.simplify(sy.sin(x)**3*sy.cos(x)**3 == (3*sy.sin(2*x) - sy.sin(6*x))/32) # returns False
Upvotes: 0
Views: 83
Reputation: 579
I found that the following approach also works:
sy.simplify(sy.expand(exp2,trig=True))==exp1 #returns True
Thanks to @ForceBru for pointing me out that the == operator compares two expressions for exact structural equality, not algebraic equivalence. I learn that one should simplify or expand expressions before comparing them with ==.
Upvotes: 0
Reputation: 44838
Try using sympy.Eq
instead of ==
:
sy.Eq(sy.sin(x)**3*sy.cos(x)**3, (3*sy.sin(2*x) - sy.sin(6*x))/32)
==
will compare the two symbolic representations for equality on-the-spot, while sympy.Eq
represents an equation.
In [19]: sy.simplify(sy.Eq(sy.sin(x)**3*sy.cos(x)**3, (3*sy.sin(2*x) - sy.sin(6*x))/
...: 32))
Out[19]: True
Upvotes: 3