1/2 (Sqrt[3] + Sqrt[3] Cos[2 w x] + Sin[2 w x]) /.
a_. Sin[x_] + b_. Cos[x_] -> Sqrt[a^2 + b^2] Sin[x + ArcTan[a, b]]
For coefficient forms without other angle trigonometric functions, the auxiliary angle formula can be easily applied using the above code.
For a more complex problem where the trigonometric expression contains two angles A and B, treat A as fixed so all its trigonometric values become constants. Then apply the auxiliary angle formula to simplify with respect to the parameter angle B.
5 - 2 Sqrt[2] Cos[A] Cos[B] + 2 Sin[A] - 2 Sqrt[2] Sin[B]
The above form needs to be converted to the following target form:
5 + 2 Sin[A] - Sqrt[8 Cos[A]^2 + 8] Sin[B + \[Phi]]
Using the initial code, the result treats angle B as fixed, with all corresponding trigonometric values becoming constants. The generated output is a trigonometric function of angle A.
5 - 2 Sqrt[2] Cos[A] Cos[B] + 2 Sin[A] - 2 Sqrt[2] Sin[B] /.
a_. Sin[x_] + b_. Cos[x_] -> Sqrt[a^2 + b^2] Sin[x + ArcTan[a, b]]
(*5-2 Sqrt[2] Sin[B]+Sqrt[4+8 Cos[B]^2] Sin[A+ArcTan[2,-2 Sqrt[2] Cos[\
B]]]*)
How should the code be modified to obtain the desired result below?
5 + 2 Sin[A] - Sqrt[8 Cos[A]^2 + 8] Sin[B + \[Phi]]