Given the function $f(x) =|x-1|$ in $\mathbb{R}$, I’m asked to find its primitive function.

50 Views Asked by At

Given the function $f(x) =|x-1|$ in $\mathbb{R}$, I’m asked to find its primitive function.

My Attempt:

$$\int|x-1|dx=\begin{array}{c} \int(x-1)dx\ \ \text{if }x\ge1\\ \int(-x+1)dx\ \ \text{if }x<1 \end{array} $$

Therefore: $$\int|x-1|dx=\begin{array}{c} \frac{x^{2}}{2}-x+c\ \text{ if } x\ge1\\ -\frac{x^{2}}{2}+x+c\ \text{ if }x<1 \end{array}$$

My problem is that if you look on the interval in $[1,1.5]$, for instance, you’ll get that the integral is negative. Given that we know that if a function is non-negative in some interval, then the function’s integral in that interval is also non-negative, it seems that my primitive function is false as it does not obtain this property.

The primitive function I found contradicts that theorem, but I don’t understand in which part I was wrong integrating the function.