trigsimp() would be what would do it, if anything. Some recent changes (after the last release) have improved trigsimp, so that it can now do this. As a work-around, you can just factor it first
In [11]: print trigsimp(factor(expr2)) 1 Another trick that works well is to replace sin(x)**2 with 1 - cos(x)**2: In [15]: expr2.subs(sin(s)**2, 1 - cos(s)**2).expand() Out[15]: 1 Or you could try the git master trigsimp, which is much more powerful than the one in the release. See https://github.com/sympy/sympy/wiki/Getting-the-bleeding-edge. Aaron Meurer On Wed, Jan 23, 2013 at 2:10 PM, Bryan Jones <[email protected]> wrote: > All, > > I'd like SymPy to simplify some trig expressions (see below), but I'm > stumped. What's the appropriate call (I assume to one of the functions in > http://docs.sympy.org/0.7.2/modules/simplify/simplify.html)? I've tried > several and can't seem to figure out the right approach. > > > from sympy import symbols, sin, cos > > from sympy.simplify import * > > s = symbols('s') > > expr = sin(s)**2 + cos(s)**2 > > print('Original expression: %s' % expr) > > print('Simplifies to: %s' % simplify(expr)) > > expr2 = (expr**2).expand() > > print('Original squared: %s' % expr2) > > print('Simplifies to: %s' % trigsimp(expr2)) > > > The output: > > Original expression: sin(s)**2 + cos(s)**2 > > Simplifies to: 1 > > Original squared: sin(s)**4 + 2*sin(s)**2*cos(s)**2 + cos(s)**4 > > Simplifies to: sin(s)**4 - cos(s)**4 + 2*cos(s)**2 > > > I'd like the last line to read: "Simplifies to: 1" > > Any ideas? > > Thanks! > > Bryan > > -- > 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]. > Visit this group at http://groups.google.com/group/sympy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- 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]. Visit this group at http://groups.google.com/group/sympy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
