Problem with $a\sin(x)+b\cos(x)=\pm\sqrt{a^2+b^2}\sin\left(\arctan\left(\frac{b}{a}\right)+x \right) $ 
Consider $f(x)=a\sin(x)+b\cos(x)$

where $a,b$ are some real constants.
Putting $f(x)=R\sin(\alpha+x)$, I got
$$f(x)=\pm\sqrt{a^2+b^2}\sin\left(\arctan\left(\frac{b}{a}\right)+x \right) \tag{1}$$
According to my Desmos graphs:
$$f(x)=+\sqrt{a^2+b^2}\sin\left(\arctan\left(\frac{b}{a}\right)+x \right) \tag{2}$$
for $a>0$
and
$$f(x)=-\sqrt{a^2+b^2}\sin\left(\arctan\left(\frac{b}{a}\right)+x \right) \tag{3}$$
for $a<0$.
So the sign $\pm$ taken is independent of the value of $b$.
I tried to prove this by discussing the possible values taken by each of $a$ and $b$: e.g. when $a,b>0$
$$0<\arctan\left(\frac{b}{a}\right)<\frac{\pi}{2} \tag{4}$$
But I struggled to proceed in discussing $$\sin\left(\arctan\left(\frac{b}{a}\right)+x \right) $$ because $\sin()$ can take any values regardless of what $a,b$ are.
Is there a way to determine which sign should be taken in the RHS of $(1)$?
 A: Denote
$$
\alpha = \arctan \frac{b}{a}.
$$
Then evidently
$$
\tan \alpha = \frac{b}{a}.
$$
Let's start with identity
$$
\sin^2 \alpha + \cos^2 \alpha = 1
$$
and divide each term by $\cos^2 \alpha$ to get
$$
\tan^2 \alpha + 1 = \frac{1}{\cos^2 \alpha} \implies \cos^2 \alpha = \frac{1}{1+\tan^2 \alpha} = \frac{a^2}{a^2 + b^2}.
$$
This gives us also
$$
\sin^2 \alpha = \frac{b^2}{a^2 + b^2}.
$$
Now (looking at $\alpha$) you can decide when one should take positive/negative value for $\sin$ and $\cos$.
Suppose, for example
$$
0 \le \alpha < \frac{\pi}{2}.
$$
This means that both sine and cosine will be nonnegative and we have
$$
\sin \alpha = \frac{|b|}{\sqrt{a^2 + b^2}}, \; \cos \alpha = \frac{|a|}{\sqrt{a^2 + b^2}}.
$$
This will give us
$$
\sin(\alpha+x ) = \sin \alpha \cos x + \cos \alpha \sin x = \frac{|a|}{\sqrt{a^2 + b^2}} \sin x + \frac{|b|}{\sqrt{a^2 + b^2}} \cos x.
$$
Now let's consider the case
$$
0 > \alpha > -\frac{\pi}{2}.
$$
This means that sine will be negative and cosine will be positive. So
$$
\sin \alpha = -\frac{|b|}{\sqrt{a^2 + b^2}}, \; \cos \alpha = \frac{|a|}{\sqrt{a^2 + b^2}}.
$$
$$
\sin(\alpha+x ) = \sin \alpha \cos x + \cos \alpha \sin x = \frac{|a|}{\sqrt{a^2 + b^2}} \sin x - \frac{|b|}{\sqrt{a^2 + b^2}} \cos x.
$$
