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.

Related Links

Need help revising a simple formula to make it universal
SWIFT trig functions
Simplifying atan(tan(a+b))
2 Different Radians constant calcuations whats the difference?
Trigonometry & Sunset
Calculating collisions with Radians incrementing
How do arbitrary-precision libraries like mpmath evaluate simple trigonometric functions?
How can I calculate the angle
Finding Shortest Distance Between Two Parallel Lines, With Arbitrary Point [closed]
how to convert depth in Z-cordinate
How can I simplify this expression with trigonometric in Maple?
Require trigonometry assistance with ship/wave movement
Trigonometry - Find where two curves intersect
How to calculate point 'along' unit circle radian [closed]
Issues with bullet entry points for “shoulder mounted” guns
Using the coordinates of two of a triangle's vertices to calculate the coordinates of the third

Categories

HOME
windows
url-redirection
twitter-bootstrap-3
polymer
interface
solaris
graphics
solver
error-handling
knitr
seo
tail
hpc
google-admin-sdk
banner
angularfire2
qpython
datastage
renjin
qsqlquery
easyphp
smartclient
google-maps-autocomplete
jquery-ias
href
angular-routing
visual-studio-extensions
aggregation
zxing
resourcebundle
direct3d11
aws-codecommit
livelink
kodi
jmockit
sharding
modalviewcontroller
video-capture
protege4
z-notation
verifiable-c
metawidget
kill
laravel-elixir
datacachefactory
branching-and-merging
outputcache
signal-strength
photos
x++
openresty
mschart
convex-optimization
java-bytecode-asm
yii2-user
oracleclient
arules
er-diagram
payload
d3-force-directed
cmp
renaming
polyline
hadoop-2.7.2
refinerycms
swizzling
embedding
uiactionsheet
asyncdisplaykit
highland.js
maybe
character-replacement
rewrite
file-move
jdk1.7
baasbox
mirror
cross-join
android-cookiemanager
iiop
big-ip
metatrader5
angular-carousel
paste
syndicationfeed
accesscontrolexception
high-resolution
cocoalibspotify-2.0
facebook-timeline
wp7test
mysql-error-2013
android-loadermanager
multiplexing
window-decoration
flex-mobile
denied
saxparseexception
jqote
tournament
quotation-marks
nhprof
cruisecontrol.rb
object-database
isapi-extension
echo3
build-environment
ifilter

Resources

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