Definite Integration

Evaluate $\displaystyle \int \limits_{0}^{2 \pi} \left|\cos x\right| \; dx$


Let $I = \displaystyle \int \limits_{0}^{2 \pi} \left|\cos x\right| \; dx$ $\;\;\; \cdots \; (1)$

$\left|\cos x\right| = \begin{cases} + \cos x, & 0 < x < \dfrac{\pi}{2} \\ - \cos x, & \dfrac{\pi}{2} < x < \dfrac{3 \pi}{2} \\ + \cos x, & \dfrac{3 \pi}{2} < x < 2 \pi \end{cases}$ $\;\;\; \cdots \; (2)$

$\therefore$ $\;$ In view of equation $(2)$, equation $(1)$ can be written as

$\begin{aligned} I & = \int \limits_{0}^{\frac{\pi}{2}} \cos x \; dx - \int \limits_{\frac{\pi}{2}}^{\frac{3 \pi}{2}} \cos x \; dx + \int \limits_{\frac{3 \pi}{2}}^{2 \pi} \cos x \; dx \\\\ & = \left[\sin x\right]_{0}^{\pi / 2} - \left[\sin x\right]_{\pi / 2}^{3 \pi / 2} + \left[\sin x\right]_{3 \pi / 2}^{2 \pi} \\\\ & = \left[\sin \left(\dfrac{\pi}{2}\right) - \sin 0\right] - \left[\sin \left(\dfrac{3 \pi}{2}\right) - \sin \left(\dfrac{\pi}{2}\right)\right] + \left[\sin \left(2 \pi\right) - \sin \left(\dfrac{3 \pi}{2}\right)\right] \\\\ & = \left(1 - 0\right) - \left(- 1 - 1\right) + \left(0 + 1\right) \\\\ & = 4 \end{aligned}$