title: sympy: how to simplify trig expression
body: <p>I have a trig expression</p>
  
  <pre><code>(-14*sin(x)**3 + 35*sin(x) + 6*sqrt(3)*cos(x)**3 + 9*sqrt(3)*cos(x))/((cos(2*x) + 4))
  </code></pre>
  
  <p>which I know simplifies to </p>
  
  <pre><code>sqrt(3)*3*cos(x) + 7*sin(x)
  </code></pre>
  
  <p>but I can't seem to find a way to do it using sympy. Is there a clever way of doing it?</p>
  
  <pre><code>In [1]: from sympy import *
  In [2]: from sympy.abc import x
  In [3]: a = (-14*sin(x)**3 + 35*sin(x) + 6*sqrt(3)*cos(x)**3 + 9*sqrt(3)*cos(x))/((cos(2*x) + 4))
  In [4]: b = sqrt(3)*3*cos(x) + 7*sin(x)
  In [5]: trigsimp(a-b)
  Out[5]: 0
  In [6]: trigsimp(a)
  Out[6]: (-14*sin(x)**3 + 35*sin(x) + 6*sqrt(3)*cos(x)**3 + 9*sqrt(3)*cos(x))/(cos(2*x) + 4)
  In [7]: a.simplify()
  Out[7]: (-14*sin(x)**3 + 35*sin(x) + 6*sqrt(3)*cos(x)**3 + 9*sqrt(3)*cos(x))/(cos(2*x) + 4)
  In [8]: trigsimp(expand_trig(a))
  Out[8]: (-14*sin(x)**3 + 35*sin(x) + 6*sqrt(3)*cos(x)**3 + 9*sqrt(3)*cos(x))/(cos(2*x) + 4)
  In [9]: expand_trig(trigsimp(a))
  Out[9]: (-14*sin(x)**3 + 35*sin(x) + 6*sqrt(3)*cos(x)**3 + 9*sqrt(3)*cos(x))/(2*cos(x)**2 + 3)
  In [10]: fu(a)
  Out[10]: (-14*sin(x)**3 + 35*sin(x) + 6*sqrt(3)*cos(x)**3 + 9*sqrt(3)*cos(x))/(cos(2*x) + 4)
  </code></pre>