2

I'm not sure how to get Sympy to perform / simplify these types of identities?

It does things like sin(a + b), but doesn't seem to do others (like the one in the title)

baxx
  • 3,956
  • 6
  • 37
  • 75

1 Answers1

2

One approach is to try various combinations of simplification functions/methods such as rewrite and simplify. For example, the following gives the result you want:

import sympy as sp

x = sp.var('x', real = True)

f = sp.tan(x/2)

sp.re(f.rewrite(sp.exp).simplify().rewrite(sp.sin)).simplify()

sin(x)/(cos(x) + 1)

Stelios
  • 5,271
  • 1
  • 18
  • 32
  • The `sympy.simplify.fu` module has a lot of trig simplifications, but it doesn't seem to have this one yet. – asmeurer Jul 07 '16 at 23:57