I was checking a trigonometric addition formula
cos(x)*cos(y) - sin(x)*sin(y) = cos(x+y)
using trigsimp()
in SymPy
.
from sympy import cos, sin, symbols, trigsimp
q = symbols('q')
print('trigsimp')
print(trigsimp(-sin(q)*sin(1*q) + cos(q)*cos(1*q)))
print(trigsimp(-sin(q)*sin(2*q) + cos(q)*cos(2*q)))
print(trigsimp(-sin(q)*sin(3*q) + cos(q)*cos(3*q)))
print(trigsimp(-sin(q)*sin(4*q) + cos(q)*cos(4*q)))
print(trigsimp(-sin(q)*sin(5*q) + cos(q)*cos(5*q)))
print(trigsimp(-sin(q)*sin(6*q) + cos(q)*cos(6*q)))
and the results are
trigsimp
cos(2*q)
cos(3*q)
cos(4*q)
-sin(q)*sin(4*q) + cos(q)*cos(4*q)
cos(6*q)
cos(7*q)
As shown above, the expression -sin(q)*sin(4*q) + cos(q)*cos(4*q))
was not simplified to cos(5*q)
.
I tried simplify() but the results were same.
Is this a type of pitfalls of the simplification in SymPy
, or is there a way to simplify the expression above?
I tried this condition with Python 3.8.5 and SymPy 1.11.1.
Thank you in advance for your help,