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?

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.
