Question:
$\int_{0}^{4}|x-1| d x$
Solution:
$I=\int_{0}^{4}|x-1| d x$
It can be seen that, $(x-1) \leq 0$ when $0 \leq x \leq 1$ and $(x-1) \geq 0$ when $1 \leq x \leq 4$
$I=\int_{1}^{1}|x-1| d x+\int_{1}^{4}|x-1| d x$ $\left(\int_{a}^{b} f(x)=\int_{a}^{c} f(x)+\int_{c}^{b} f(x)\right)$
$=\int_{0}^{1}-(x-1) d x+\int_{0}^{4}(x-1) d x$
$=\left[x-\frac{x^{2}}{2}\right]_{0}^{1}+\left[\frac{x^{2}}{2}-x\right]_{1}^{4}$
$=1-\frac{1}{2}+\frac{(4)^{2}}{2}-4-\frac{1}{2}+1$
$=1-\frac{1}{2}+8-4-\frac{1}{2}+1$
$=5$