Aaron,

Thanks so much. I ended up needing both techiniques to simplify the larger
expression I was after; for now, using SymPy 0.7.2 is enough. I'll
definitely try to the git version if needed!


On Wed, Jan 23, 2013 at 8:10 PM, Aaron Meurer <[email protected]> wrote:

> 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.
>
>
>


-- 
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)

-- 
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.


Reply via email to