Some help on trigonometric function in sympy please

90 views
Skip to first unread message

Javier

unread,
Nov 19, 2010, 8:26:48 AM11/19/10
to sympy
Hi all,

Anyone knows if there is a simple way of doing an expansion of
sin(x)**p and cos(x)**p as a sum of cos(ix) or sin(ix) in sympy. I
currently can do it in maple with the combine command but I want to
use sympy.


The idea is that for example:

sin(x)**5 = 1/16 sin(5 x) - 5/16 sin(3 x) + 5/8 sin(x)
cos(x)**5 = 1/16 cos(5 x) + 5/16 cos(3 x) + 5/8 cos(x)

Can anyone help me please?

Thanks in advance

Aaron S. Meurer

unread,
Nov 19, 2010, 1:07:18 PM11/19/10
to sy...@googlegroups.com
Unfortunately, this simplification is not yet implemented in SymPy (though the reverse is, see expand(trig=True)). See http://code.google.com/p/sympy/issues/detail?id=1590.

It shouldn't be too hard to implement, though, you just need to implement the series expansions given at http://en.wikipedia.org/wiki/Trig_identities#Power-reduction_formula.

Actually, there is another way that you can do it, which involves taking advantage of the complex exponential form of sine and cosine. You would do something like this:

In [3]: (cos(x)**5).rewrite(exp).expand().rewrite(cos)
Out[3]:
cos(5⋅x) 5⋅cos(x) 5⋅cos(3⋅x)
──────── + ──────── + ──────────
16 8 16


Aaron Meurer

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

Reply all
Reply to author
Forward
0 new messages