### trigonometry

#### Counting trig ops as measure() function to fu() in sympy

```How do I count the number of trig operations in an expression?
I have an expression of the form a*sin(x)+b*cos(x) that I would like sympy to convert to c*sin(x+phi).
#asmeurer made a comment in an earlier question about simplifying trig expressions that suggested the fu() algorithm can be tuned to minimize an arbitrary measure.
I suspect I can get my expression to reduce if I set measure to be the number of trig ops in the expression.
```
```The following is a way to get the set of functions:
>>> from sympy.functions.elementary.trigonometric import TrigonometricFunction
>>> eq=a*sin(x)+b*cos(x)
>>> len(eq.atoms(TrigonometricFunction))
2
If you wanted the actual number of times that such functions occurred (counting the same function more than once) you might try a custom function like preorder_traversal from sympy.core.exprtools, registering each time a TrigonometricFunction was encountered.```

### Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization