To find the area under the curve \( y = |\sin x - \cos x| \) over the interval \( 0 \leq x \leq \frac{\pi}{2} \), we first identify where \( \sin x = \cos x \). Solving \( \sin x = \cos x \), we have \( \tan x = 1 \), which gives \( x = \frac{\pi}{4} \). Therefore, the integral becomes split at \( x = \frac{\pi}{4} \):
For \( 0 \leq x \leq \frac{\pi}{4} \), \(\sin x \geq \cos x\), so \( |\sin x - \cos x| = \sin x - \cos x \). The integral over this interval is:
\( \int_{0}^{\frac{\pi}{4}} (\sin x - \cos x) \, dx \).
Integrating, we get:
\( [-\cos x - \sin x]_{0}^{\frac{\pi}{4}} = \left(-\cos\left(\frac{\pi}{4}\right) - \sin\left(\frac{\pi}{4}\right)\right) - (-\cos(0) - \sin(0)) \).
Substitute values:
\( -\frac{\sqrt{2}}{2} - \frac{\sqrt{2}}{2} + 1 = 1 - \sqrt{2} \).
For \( \frac{\pi}{4} \leq x \leq \frac{\pi}{2} \), \(\cos x \geq \sin x\), so \( |\sin x - \cos x| = \cos x - \sin x \). The integral over this interval is:
\( \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} (\cos x - \sin x) \, dx \).
Integrating, we get:
\( [\sin x - \cos x]_{\frac{\pi}{4}}^{\frac{\pi}{2}} = \left(\sin\left(\frac{\pi}{2}\right) - \cos\left(\frac{\pi}{2}\right)\right) - \left(\sin\left(\frac{\pi}{4}\right) - \cos\left(\frac{\pi}{4}\right)\right) \).
Substitute values:
\( (1 - 0) - \left(\frac{\sqrt{2}}{2} - \frac{\sqrt{2}}{2}\right) = 1 - 0 = 1 \).
Adding both integrals, we find the total area:
\( (1 - \sqrt{2}) + 1 = 2 - \sqrt{2} \).
Conclusion: The area under the curve is \( 2(\sqrt{2} - 1) \) square units.