# What is the integral of |sin(x)|?

The function $| \sin \left(x\right) |$ is defined as follows:

$| \sin \left(x\right) | = \sin \left(x\right) , \mathmr{if} \sin \left(x\right) \ge q 0$
$| \sin \left(x\right) | = - \sin \left(x\right) , \mathmr{if} \sin \left(x\right) < 0$

So, the integral is defined as:

$\int | \sin \left(x\right) | \mathrm{dx} = \int \sin \left(x\right) \mathrm{dx} , \mathmr{if} \sin \left(x\right) \ge q 0$
$\int | \sin \left(x\right) | \mathrm{dx} = \int - \sin \left(x\right) \mathrm{dx} , \mathmr{if} \sin \left(x\right) < 0$

Since the integral is linear:

$\int - \sin \left(x\right) \mathrm{dx} = - \int \sin \left(x\right) \mathrm{dx}$

And we have:

$\int | \sin \left(x\right) | \mathrm{dx} = - \cos \left(x\right) + C , \mathmr{if} \sin \left(x\right) \ge q 0$
$\int | \sin \left(x\right) | \mathrm{dx} = \cos \left(x\right) + C , \mathmr{if} \sin \left(x\right) < 0$

or, for $n \in \mathbb{Z}$,

$\int | \sin \left(x\right) | \mathrm{dx} = - \cos \left(x\right) + C , \mathmr{if} x \in \left[2 n \pi , \left(2 n + 1\right) \pi\right]$
$\int | \sin \left(x\right) | \mathrm{dx} = \cos \left(x\right) + C , \mathmr{if} x \in \left(\left(2 n - 1\right) \pi , 2 n \pi\right)$