reducing $\cos{x} + 2\sin{x}$ to $R\cos{x - a}$ finds strange phase-shift So, I'm analysing the function $\cos{x} + 2\sin{x} (*)$ and determining whether it is convertible to the single function $R\cos{x - a}$ for $a \in (0, \frac{\pi}{2}); R > 0$; so I begin by observing the maximum/minimum of $(*)$ and determining its max./min. at $\pm\sqrt{5}$, so then I apparently have that $R = \sqrt{5}$ as the radius/magnitude of the corresponding function.
Next, I seek to find the phase-shift difference between my $\sqrt{5}\cos{x}$ and $\cos{x} + 2\sin{x}$, so, I take two reference points at their relative roots, i.e. $\cos{x} + 2\sin{x} = 0 \iff x = -\arctan{\frac{1}{2}} + n\pi, n \in \mathbb{Z}$, and respectively, $\sqrt{5}\cos{x} = 0 \iff x = \frac{\pi}{2} + n\pi, n \in \mathbb{Z}$. So I figure that if I take the x's matching with the roots of the functions in the same period, then I should have the phase-shift and my function mutation should be done.
I take $n = 1$ for both functions, so I have $x_{\sqrt{5}\cos{x}} = \pi + \frac{\pi}{2}$ and $x_{\cos{x} + 2\sin{x}} = \pi - \arctan{\frac{1}{2}}$. Then I take their absolute difference, and theoretically this should be the shift. So, $|x_{\sqrt{5}\cos{x}} - x_{\cos{x} + 2\sin{x}}| = |[\pi + \frac{\pi}{2}] - [\pi - \arctan{\frac{1}{2}}]| = |\frac{\pi}{2} + \arctan{\frac{1}{2}}| \approx 2.034$.
So immediately this evaluation seems incorrect; 2.034 radians is well over half a period, and according to plots of these functions the difference does not seem this drastic.
Observe the plot for $y = \sqrt{5}\cos{x - (\frac{\pi}{2} + \arctan{\frac{1}{2}})}$ and $y = \cos{x} + 2\sin{x}$
 
Evidently incorrect, so I then plot $x = -\arctan{\frac{1}{2}}$ and $y = \cos{x} + 2\sin{x}$ to actually determine where this x-value was being matched:

For some reason, the $-\arctan{\frac{1}{2}}$ was in a completely separate period relative to $\sqrt{5}\cos{x}$ at $n=1$. And here my question(s) arises: why is this root observed in a separate period? How can I find where the start of these periods are? Is there a better method to finding the difference between these trigonometric functions besides at the roots?
 A: I would like to suggest another approach to this problem, which I find more illuminating, based on Euler's formula, which says that $\cos x$ is the real part of $e^{ix}$ and $\sin x$ is the real part of $-ie^{ix}$, so we can put $\cos x+2\sin x$ in the desired form by looking at the real part of $e^{ix}-2ie^{ix}$. But this is just
$$
(1-2i)e^{ix},
$$
so both $R$ and $a$ can be found simply by plotting the complex number $1-2i$ and seeing what its distance from the origin is ($R$) and what angle its makes, counterclockwise from the positive $x$-axis ($a$).
 You will find that $\tan a=-2$, since in general for a complex number $z=x+iy$ the angle $a$ will satisfy $\tan a=y/x$, and in this case $y=-2$ and $x=1$.
A: Let's say you want to write, with $r\ge0$:
$$a\cos \theta+b\sin\theta=r\cos(\theta-\phi)=r\cos \phi\cos \theta+r\sin \phi\sin \theta$$
We are done if $a=r\cos\phi$ and $b=r\sin\phi$, hence $a^2+b^2=r^2$, which gives $r=\sqrt{a^2+b^2}$.
Then any $\phi$ such that $\cos\phi=\dfrac{a}{\sqrt{a^2+b^2}}$ and $\sin\phi=\dfrac{b}{\sqrt{a^2+b^2}}$.
If $a>0$, it's equivalent to find $\phi$ such that $\tan\phi=\dfrac ba$, hence $\phi=\arctan(\frac ba)$.
The other cases, to get $\phi\in(-\pi,\pi]$:


*

*If $a<0$ and $b<0$, $\phi=\arctan(\frac ba)-\pi$

*If $a<0$ and $b\ge0$, $\phi=\arctan(\frac ba)+\pi$

*If $a=0$ and $b\ne0$, $\phi=\mathrm{sign}(b)\dfrac \pi2$

*If $a=b=0$, $\phi$ is not well defined.


In your case, $a=1$ and $b=2$, so $r=\sqrt5$ and $\phi=\arctan2\in(0,\pi/2)$.
Notice that this is equivalent to convert the complex number $a+ib$ to polar form $r\exp(i\phi)$. The value of $\phi$ given here is the principal value of the argument.
A: Recall the identity $R\cos(x-a) = R\cos(x)\cos(a) + R\sin(x)\sin(a)$. Its just the angle difference formula, but Ive tossed in a constant factor.
Just compare like terms.  The left hand side is already correct. You want $R\cos(a)=1$ and $R\sin(a)=2$.  
By way of the Pythagorean Identity we can infer that $R = \pm\sqrt{5}$.  Choose one (or test both, to be fair).  You have plenty of equations left over to solve for $a$. Your solution should be unambiguous.
