How to find the anti-derivative is $\left|x\right|$? Let the function $f(x) = \cases{1 & x>0 \\ -1 & x<0}$. I want to show that the anti-derivative of $f(x)$ is $\left|x\right|$.
Let's split to cases:
If $x\le 0$ then $F(x) = \int_{-1}^x f(x) = \int_{-1}^x (-1) = (x+1)(-1) = -x - 1$
If $x\ge 0$ then $F(x) = \int_{-1}^0 f(x) + \int_0^xf = -1 + x$
Now, it doesn't look like $\left|x\right|$. I've been told to use $F(x) = 1 + \int_{-1}^x f$ but I don't understand the rationality behind that.
 A: You problem is the notion of THE antiderivative. There are many antiderivatives for your function (any two of which differ by a constant). 
In other words, if $F' = f$, then $(F + C)' = f$ as well, where $C$ is any constant. 
In your case, the function $F$ you've computed is indeed an antiderivative of $f$, but picking $C = 1$ leads to a more simply expressed antiderivative, namely $G(x) = |x|$. 
N.B. user86418's comment is an excellent point: $F$ is not an antiderivative for $f$ at $x = 0$, because at $x = 0$, $F$ is not differentiable, and hence it's impossible for $F'(0) = f(0)$. But on $K = \mathbb R - \{0\}$, what I've said is correct...but not quite complete. Since there's function $H$ with $H' = f$ everywhere (you just can't make it work at zero! See below.), you're limited to antiderivatives on $K$ (the punctured real line). And if $P$ and $Q$ are two antiderivatives on $K$, then $F$ and $G$ differ by a constant on each component of $K$. You could, for instance, have taken your antiderivative $F$, and built 
$$
P(x) = \begin{cases} F(x)-4 & x \le 0 \\ F(x) + 13 & x > 0 \end{cases}
$$
and had an equally good antiderivative (on $K$). 
How do I know that there's no antiderivative on all of $\mathbb R$? Because "derivatives have the intermediate value property": if $h$ is differentiable at every point of some interval $[a, b]$, with $h'(a) = A$ and $h'(b) = B$, then for any $C$ between $A$ and $B$, there's a point $c \in [a, b]$ with $h'(c) = C$. 
That result seems pretty surprising to me every time I see it. It's known as Darboux's Theorem. (See this question, along with its comments and answers, for further enlightenment.)
