How to simpify $\cos x - \sin x$

How does one simplify

$$\cos x - \sin x$$

I tried multiplying by $\cos x + \sin x$, but that just gets me $$\cos x - \sin x = \frac{\cos 2x}{\cos x + \sin x}$$ which is worse.

Yet wolframalpha gives me $\cos x - \sin x = \sqrt{2}\sin\left(\dfrac{\pi}{4}-x\right)$. How does one obtain this algebraically?


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.


It's the magic of $$\sin\left(\frac\pi4\right)=\cos\left(\frac\pi4\right)=\frac{1}{\sqrt2}$$ $$\cos x - \sin x=\sqrt2\left[\frac{\cos x-\sin x}{\sqrt2} \right]=\sqrt2\left[\frac{1}{\sqrt2}\cos x - \frac{1}{\sqrt2}\sin x\right]$$

Now use

$$\sin(a-b)=\sin a\cos b-\cos a\sin b$$ with using $b=x$ and $a=\dfrac\pi4$