Why is this simplification possible?

So I have stumbled into a simplification operation in a maths book about integrals, but it does not provide any explanation why or how is this operation is possible.
$${5*(cos^2x-sin^2x)\over sinx+cosx}=5*(cosx-sinx)$$ I have tried to apply a number of trigonometric identities and transformations but a solution eludes me. Obviously you can just divide by 5 to get ${cos^2x-sin^2x\over sinx+cosx}=cosx-sinx$.
I tried to apply $sin^2x+cos^2x=1$, in different ways, but got nowhere. I would like to know how is this simplification is possible.

• $\cos^2(x) - \sin^2(x) = (\cos(x) - \sin(x))(\cos(x) + \sin(x))$ Mar 27 '14 at 17:42
• And don't be fooled by the incorrect placement of the exponents in $\cos^2 x$ and $\sin^2 x$. Mar 27 '14 at 17:46
• To all of the answers here it is important that $\cos x\neq \sin x$. Mar 27 '14 at 17:47
• @JPMcCarthy I think you meant to write it as $\cos x \neq -\sin x$, which makes the denominator on the left zero. Oct 17 '20 at 1:56
• @syockit absolutely. Oct 17 '20 at 2:07

Use the conjugate rule, $a^2 - b^2 = (a+b)(a-b)$.
Thus $$\frac{5(\cos^2 x - \sin^2 x)}{\sin x + \cos x} = \frac{5(\cos x + \sin x)(\cos x - \sin x)}{\sin x + \cos x} = 5(\cos x - \sin x)$$
\begin{align}{5(\cos^2x-\sin^2x)\over \sin x+\cos x} & = \frac{5(\cos x - \sin x)(\cos x + \sin x)}{\sin x + \cos x} \\ \\ & = \require{cancel}\frac{5(\cos x - \sin x)(\cancel{\cos x + \sin x})}{\cancel{\cos x+ \sin x}}\\ \\ & = 5(\cos x-\sin x)\end{align}
$a^2-b^2$= $(a+b)(a-b)$, hence $\cos^{2}(x)-\sin^{2}(x)$ = $(\cos x+\sin x)(\cos x-\sin x)$.