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

How does atan appear in haversine formula?
Sympy cancelling terms in the Jacobian of polar coordinates transformation
Distance formula between two Lat/Longs Autoit?
Trigonometric Functions in Pseudo Code
Inverse-Kinematics: How to calculate angles for servos of a robotic arm to reach all possible points in a canvas?
How to calculate Heading using Gyro and magnetometer
Integral of a sign function proof
Best way working with trigonometric functions
Calculate place of point C to be equal distance away from points A and B
How to compute sum of angles from sine and cossine?
Counting trig ops as measure() function to fu() in sympy
Find a coordinate along a path
Angle calculation resulting in strange behavior
Shift angle orientation using atan2
estimate angle between two lines y = 1000x and y = 999x
Need help revising a simple formula to make it universal

Categories

HOME
phpword
apache-flink
forms
depth
interface
components
bitbucket-api
edge
entity-framework-core
google-apps
p2p
32bit-64bit
renjin
capistrano3
coin3d
alpacajs
intershop
chargify
google-content-api
nim
charles
user-experience
question2answer
postscript
visual-studio-extensions
epsilon
perlbrew
jquery-multiselect
bulletphysics
pylons
firebase-analytics
handler
datastax-enterprise-graph
exchangewebservices
quantlib
volatile
weather
angularjs-material
clickjacking
gnat-gps
pdw-file-browser
baidu-map
roblox
raft
alphabetical
xcode7.3
openalpr
sessionstorage
recurrent-neural-network
loading
google-data-api
signals-slots
numberpicker
parser-generator
microsoft-metro
importerror
uiimage
monkey-testing
reportservice2010
dbcontext
compiler-design
pdf-conversion
cpu-cache
trigger.io
shinobi
rxtx
javafx-css
juice-ui
rmongo
docpad
parfor
jboss-tools
tooleap
project-organization
grass
concept-insights
ascii-art
lazybones
ess
phonertc
coda
doctype
alloy-ui
osc
rapidsvn
theos
boost-program-options
spy++
genymotion-call
imagefilter
wcm
raygun
dct
gnumeric
paste
radiant
sphinxql
kendo-dataviz
scrypt
cmmi
kaleidoscope
josql
inkcanvas
oracle-enterprise-linux
window-decoration
role
workflow-services
update-statement
delimited-text
tabpanel

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