Doubt about splitting a definite trigonometric integral I was studying some already solved trigonometric integrals with absolute value.
I do not understand why this integral:
$$\int_0^\sqrt3|x-1|\arctan(x)\,\mathrm dx=\int_0^1-(x-1)\arctan(x)\,\mathrm dx+\int_1^\sqrt3(x-1)\arctan(x)\,\mathrm dx$$
has to be split in two integrals, where the first one goes from $0$ to $1$. Does it have to be $1$ or can it be any number less than $\sqrt3$?
Same things with this other one, why the does the first integral hast to end with $\dfracπ2$?
$$\int_{-\pi/2}^{3\pi/2}(x+1)^2|\cos x|\,\mathrm dx=\int_{-\pi/2}^{\pi/2}(x+1)^2|\cos x|\,\mathrm dx-\int_{\pi/2}^{3\pi/2}(x+1)^2|\cos x|\,\mathrm dx.$$
 A: The function $|x-1|$ is equal to $-(x-1)$ on $(-\infty, 1]$ and is equal to $x-1$ on $[1,\infty)$. So you split the integral at $1$ because that way, the two remaining integrals do not have an absolute value you would otherwise need to deal with. The split must be at $1$, otherwise you do not lose the absolute values.
The same reason goes for the second integral you list: you split the integral there because that's where the function under the absolute value changes its sign.
A: The absolute value function $\lvert x \rvert$ is defined as $$\lvert x \rvert=\begin{cases}
x,&\text{if  $x\geq 0 $}\\
-x,&\text{if  $x\lt 0 $}
\end{cases}.$$ As you can see from the definition, the function takes different values(but,always non-negative) on different intervals. So when you calculate $\lvert x-1 \rvert$, you have to check the intervals.
Note that $$\lvert x-1 \rvert=\begin{cases}
x-1,&\text{if  $x-1\geq 0 $}\\
-(x-1),&\text{if  $x-1\lt 0 $}
\end{cases}.$$
So your integral
$$\int_0^\sqrt3 \ |x-1|\operatorname{arctan}(x)\mathrm{d}x$$ becomes   $$\int_0^1\ -(x-1)\operatorname{arctan}(x)\mathrm{d}x + \int_1^\sqrt3\ (x-1)\operatorname{arctan}(x)\mathrm{d}x$$ because $\lvert x-1 \rvert=-(x-1)$ on the interval  $(-\infty,1) $. 
The function $\lvert \cos x \rvert$ always gives non-negative values. But
 $\cos x\ge0$ for $-\dfrac\pi2\le x\le\dfrac\pi2$
and $\cos x<0$ for $\dfrac\pi2\lt x\lt\dfrac{3\pi}2$.
 So we define $$\lvert \cos x \rvert=\begin{cases}
\cos x,&\text{if  $-\dfrac\pi2\le x\le\dfrac\pi2$}\\
-\cos x,&\text{if  $\dfrac\pi2\lt x\lt\dfrac{3\pi}2$}
\end{cases}.$$
