# Integrate $\int_0^\pi\sqrt{\frac{1+\cos(2x)}{2}}dx$

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!

• Use $\int_a^b f(x)dx = \int_a^c f(x)dx + \int_c^b f(x)dx$. Set $a=0, b=\pi, c=\pi /2$. And the rest follows by the definition of absolute values. – zxcvber Mar 28 '18 at 6:10
• You're correct, $\cos x\ge 0$ for $x\in[0,\pi/2]$ and $\cos x\le 0$ for $x\in[\pi/2,\pi]$. So $|\cos x| = \cos x$ for $x\in[0,\pi/2]$ and $-\cos x$ for $x\in[\pi/2,\pi]$. – Quang Hoang Mar 28 '18 at 6:13

$|\cos(x)|$ means absolute value of $\cos (x)$
$\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$.