Put together sine and cosine of the same angle : tcollect tCollect

### 5.24.5 Put together sine and cosine of the same angle : tcollect tCollect

tcollect or tCollect takes as argument an expression containing trigonometric functions.
tcollect first linearizes this expression (e.g. in terms of sin(n*x) and cos(n*x)), then, puts together sine and cosine of the same angle.
Input :

tcollect(sin(x)+cos(x))

Output :

sqrt(2)*cos(x-pi/4)

Input :

tcollect(2*sin(x)*cos(x)+cos(2*x))

Output :

sqrt(2)*cos(2*x-pi/4)