Sum and Difference Identities for Trigonometric Functions
Formulas
Composition into sine
$$ A \cos \theta + B \sin \theta = C\sin(\theta + \phi) $$
Here, $C = \sqrt{A^{2} + B^{2}}$, $\phi = \sin^{-1} \left( \dfrac{A}{\sqrt{A^{2} + B^{2}}} \right) = \cos^{-1} \left( \dfrac{B}{\sqrt{A^{2} + B^{2}}} \right)$ are given.
Composition into cosine
$$ A \cos \theta + B \sin \theta = C\cos(\theta - \phi) $$
Here, $C = \sqrt{A^{2} + B^{2}}$, $\phi = \sin^{-1} \left( \dfrac{B}{\sqrt{A^{2} + B^{2}}} \right) = \cos^{-1} \left( \dfrac{A}{\sqrt{A^{2} + B^{2}}} \right)$ are given.
Proof
Grouping two terms $A \cos \theta + B \sin \theta$ into $\sqrt{A^{2} + B^{2}}$,
$$ A \cos \theta + B \sin \theta = \sqrt{A^{2} + B^{2}} \left( \dfrac{A}{\sqrt{A^{2} + B^{2}}}\cos \theta + \dfrac{B}{\sqrt{A^{2} + B^{2}}}\sin \theta \right) $$
Where $-1 \lt \dfrac{A}{\sqrt{A^{2} + B^{2}}} \lt 1$, let’s denote this value as $\sin \phi$.
$$ \sin \phi = \dfrac{A}{\sqrt{A^{2} + B^{2}}} $$
Then, as $\sin^{2} \phi - 1 = \cos^{2} \phi$,
$$ \sin^{2} \phi - 1 = \dfrac{A^{2}}{A^{2} + B^{2}} - \dfrac{A^{2} + B^{2}}{A^{2} + B^{2}} = \dfrac{B^{2}}{A^{2} + B^{2}} = \cos \phi $$
$$ \implies \dfrac{B}{\sqrt{A^{2} + B^{2}}} = \cos \phi $$
Now, if we set $C = \sqrt{A^{2} + B^{2}}$, according to the addition formula of trigonometric functions,
$$ A \cos \theta + B \sin \theta = C \left( \sin\phi \cos\theta + \cos\phi \sin\theta \right) = C\sin(\theta + \phi) $$