The problem is:
$$\int_0^\pi\sqrt{\frac{1+\cos(2x)}{2}}dx$$
It is obvious that by using trig identities we can come up with:
$$\int_0^\pi\sqrt{\cos^2(x)} =$$ $$= \int_0^\pi|\cos(x)|dx$$
Here I have a slight problem. My professor offered a solution:
$$\int_0^\pi|\cos(x)|dx = \int_0^\frac{\pi}{2}\cos(x)dx + \int_\frac{\pi}{2}^\pi-\cos(x)dx$$
From here, it is simple to calculate, but I do not understand this separation into two integrals. I figure it's because of the absolute value of the cosine function, but I cannot quite grasp it... The minus before the cosine in the second integral is also confusing. If someone could elaborate, I would be very grateful. Thanks!
$|\cos(x)|$ means absolute value of $\cos (x)$
\begin{align} |\cos(x) |= \begin{cases} \cos(x) &, \text{if } \cos(x) \ge 0\\ -\cos (x)& , \text{if } \cos(x) <0 \end{cases} \end{align}
$\cos(x) \ge 0 $ when $x$ is from $0$ to $\frac{\pi}2$
and $\cos(x) \le 0$ when $x$ is from $\frac{\pi}{2}$ to $\pi$.
\begin{align}\int_0^\pi|\cos(x)|dx&= \int_0^\frac{\pi}{2}|\cos(x)|dx + \int_\frac{\pi}{2}^\pi|\cos(x)|dx \\& = \int_0^\frac{\pi}{2}\cos(x)dx + \int_\frac{\pi}{2}^\pi-\cos(x)dx \end{align}