sympy: trigonometric sum-product identities -
i have expression: sin(x)+sin(y)
there well-known trig identity express product of sin , cos.
is there way sympy apply identity?
simplify
, trigsimp
nothing.
trigsimp
, aristocrates points out, reverse, because sin(x) + sin(y)
simpler 2*sin((x + y)/2)*cos((x - y)/2)
.
trigsimp
internally uses algorithm based on paper fu, et. al., pattern matching on various trigonometric identities. if @ source code, identities written out in individual functions (the functions named after sections in fu's paper).
looking @ list of simplifications @ top of file, 1 want
tr9 - contract sums of sin-cos products
testing out, looks works
in [1]: sympy.simplify.fu import tr9 in [2]: tr9(sin(x) + sin(y)) out[2]: ⎛x y⎞ ⎛x y⎞ 2⋅sin⎜─ + ─⎟⋅cos⎜─ - ─⎟ ⎝2 2⎠ ⎝2 2⎠
we factor these out more user-friendly functions, now, fu.py
file pretty documented, if function names not particularly memorable.
Comments
Post a Comment