Why is $\cos(x/2)+2\sin(x/2)=\sqrt5 \sin(x/2+\tan^{-1}(1/2))$ true? According to Wolfram Alpha the following equality holds:
$$\cos\left(\frac{x}{2}\right)+2\sin\left(\frac{x}{2}\right)=\sqrt5 \sin\left(\frac{x}{2}+\tan^{-1}\left(\frac{1}{2}\right)\right)$$
I also checked it numerically. Why is it true?
 A: Let us consider the general case $$A=a \sin(x)+b\cos(x)$$ Without changing anything, we can rewrite $$A=\sqrt{a^2+b^2}\Big(\frac{a}{\sqrt{a^2+b^2}} \sin(x)+\frac{b}{\sqrt{a^2+b^2}} \cos(x)\Big)$$ Now, let us define$$\frac{a}{\sqrt{a^2+b^2}}=\cos(\phi)$$ so $$\sin^2(\phi)=1-\cos^2(\phi)=1-\frac{a^2}{a^2+b^2}=\frac{b^2}{a^2+b^2}$$ and so $$\sin(\phi)=\frac{b}{\sqrt{a^2+b^2}}$$ Replacing in the initial expression, we then have $$A=\sqrt{a^2+b^2}\Big(\cos(\phi) \sin(x)+\sin(\phi)\cos(x)\Big)=\sqrt{a^2+b^2}\sin(x+\phi)$$ and from the definitions, you can notice that $$\tan(\phi)=\frac{\sin(\phi)}{\cos(\phi)}=\frac ba$$ which makes $$\phi=\tan^{-1}\big(\frac ba\big)$$
Similar things could be done defining instead $$\frac{a}{\sqrt{a^2+b^2}}=\sin(\theta)$$ which make $$\cos(\theta)=\frac{b}{\sqrt{a^2+b^2}}$$ and then $$A=\sqrt{a^2+b^2}\Big(\sin(\theta) \sin(x)+\cos(\theta)\cos(x)\Big)=\sqrt{a^2+b^2}\cos(x-\theta)$$
So basically, using this approach allows to transform $A$ as a sine or a cosine depending on what you need for the remaining of the work.
A: Consider 
$$\frac{1}{\sqrt{5}}\cos y+\frac{2}{\sqrt{5}}\sin y.\tag{1}$$
Let $\theta$ be the angle whose sine is $1/\sqrt{5}$ and whose cosine is $2/\sqrt{5}$. Then by the usual addition law for the sine function, Expression (1) is equal to $\sin(y+\theta)$. Note that the tangent of $\theta$ is $1/2$.
A: Using $\sin(\alpha + \beta) = \sin \alpha \cos \beta + \cos \alpha \sin \beta$,
\begin{align}
  \sin\left(x + \tan^{-1} \left(\frac 1 2\right) \right)
  &= \sin x \cos \left(\tan^{-1}\left(\frac 1 2\right)\right) +
     \cos x \sin \left(\tan^{-1}\left(\frac 1 2\right)\right) \\
  &= \sin x \frac 2 {\sqrt 5} + \cos x \frac 1 {\sqrt 5}.
\end{align}
