<s>[INST] Given any $a,b$, find $A,B$ such that $a\sin(x) + b\cos(x) = A\sin(x+B)$ I understand that if $f''+f = 0, f(0) = a$, $f'(0) = b$ we can have $f = b\sin +a\cos$. so if $f(x) = A\sin(x+B)$, we choose $a = A\cos(B)$ and $b = A\sin(B)$ 
How do we find $a$ and $b$ conversely?
 [/INST] Let $\theta$ be such that $\cos \theta = a/\sqrt{a^2 + b^2}$ and $\sin \theta = b/\sqrt{a^2 + b^2}$. Then $$a\sin(x) + b\cos(x) = \sqrt{a^2 + b^2}(\cos(\theta)\sin(x) + \sin(\theta)\cos(x)) = \sqrt{a^2 + b^2}\sin(x + \theta).$$
</s>