Home » Blog » Compute the integral from 0 to π/2 of |sin x – cos x|

Compute the integral from 0 to π/2 of |sin x – cos x|

Compute the following integral:

    \[ \int_0^{\frac{\pi}{2}} | \sin x - \cos x | \, dx. \]


Since \cos x - \sin x \geq 0 on the integral \left[ 0, \frac{\pi}{4} \right] and \cos x - \sin x < 0 on \left( \frac{pi}{4}, \frac{\pi}{2} \right] we have,

    \begin{align*}  \int_0^{\frac{\pi}{2}} | \sin x - \cos x | \, dx &= \int_0^{\frac{\pi}{4}} (\cos x - \sin x) \, dx + \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} (\sin x - \cos x) \, dx \\  &= \sin \frac{\pi}{4} + \cos \frac{\pi}{4} - 1 + \cos \frac{\pi}{4} - \cos \frac{\pi}{2} - \sin \frac{\pi}{2} + \sin \frac{\pi}{4} \\  &= \frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2} - 1 + \frac{\sqrt{2}}{2} - 0 - 1 + \frac{\sqrt{2}}{2} \\  &= 2 \sqrt{2} - 2. \end{align*}

Point out an error, ask a question, offer an alternative solution (to use Latex type [latexpage] at the top of your comment):