how to simplify half angle trigonometric function

193 views
Skip to first unread message

chaowen guo

unread,
May 30, 2016, 6:13:06 PM5/30/16
to sympy
Hi:

My formula has a lot of square of half angle trigonometric functions. We all know that sin(x/2)**2=(1-cos(x))/2 and cos(x/2)**2=(1+cos(x))/2. But how to do that in sympy? I try trigsimp and expand_trig, both of them are not working.

import sympy
x=sympy.symbols('x',real=True)
sympy.expand_trig(sympy.cos(x/2)**2)
sympy.trigsimp(sympy.sin(x/2)**2)

output is the original half angle formula.

Is there any function like trigreduce in maxima? It does such job.

Shekhar Prasad Rajak

unread,
Jun 5, 2016, 1:46:16 PM6/5/16
to sympy
HI,
Also feel similar kind of problem. In your case you can do 

>>> from sympy.simplify.fu import fu
>>> fu(S.Half - cos(2*x)/2)
# o/p:    sin(x)**2
>>> from sympy.simplify.fu import TR7
>>> TR7(cos(x)**2)
# o/p:    cos(2*x)/2 + 1/2

Hope these will help.

--
Shekhar

Shekhar Prasad Rajak

unread,
Jun 6, 2016, 2:15:02 AM6/6/16
to sympy
You can also try this 

In [ ]: from sympy.simplify.trigsimp import trigsimp_groebner

In [ ]: trigsimp_groebner(sin(x/2)**2, hints=[2])
Out[ ]: 
  cos(x)   1
- ────── + ─
    2      2

In [ ]: trigsimp_groebner(cos(x/2)**2, hints=[2])
Out[ ]: 
cos(x)   1
────── + ─
  2      2


--
Shekhar

On Tuesday, 31 May 2016 03:43:06 UTC+5:30, chaowen guo wrote:
Reply all
Reply to author
Forward
0 new messages