A rather remarkable identity is that, for any $\alpha$ and $\beta$, we can find a $\theta$ and $c$ such that:
$$\alpha\sin(x)+\beta\cos(x)=c\sin(x+\theta).$$
To show this, we can expand the right-hand side by the angle-sum identity for sine:
$$\alpha\sin(x)+\beta\cos(x)=c\sin(x)\cos(\theta)+c\cos(x)\sin(\theta)$$
and if we group coefficients of $\sin$ and $\cos$ together, we get
$$\alpha = c\cos(\theta)$$
$$\beta = c\sin(\theta)$$
which has a really nice intuitive interpretation: the point $(\alpha,\beta)$ is equal to $(c,\theta)$ in polar coordinates. In particular, we can find $c$ and $\theta$ by algebraic means. Firstly, square both the above equations and add the results. This gives
$$\alpha^2+\beta^2=c^2(\cos(\theta)^2+\sin(\theta)^2)=c^2$$
so $c=\sqrt{\alpha^2+\beta^2}$. Then, if we take the ratio of the two equations, we get
$$\frac{\beta}{\alpha}=\tan(\theta)$$
$$\theta=\tan^{-1}\left(\frac{\beta}{\alpha}\right)$$
(though we have to be careful since $\tan$ is periodic in $\pi$ - we need to ensure that we don't get the wrong inverse tangent, which is why I include the interpretation that $\theta$ is the angle to $(\alpha,\beta)$ from the $x$-axis).
Putting things back together, this gives
$$\alpha\sin(x)+\beta\cos(x)=\sqrt{\alpha^2+\beta^2}\sin\left(x+\tan^{-1}\left(\frac{\beta}{\alpha}\right)\right)$$
and plugging in $\alpha=1$ and $\beta=-1$ gives the identity you found.