Integral representation of $|x-a|$ Are there integral representations of the absolute value function $|x-a|$ with $x$, $a$ real numbers? 
My initial thought was to write $|x-a| = \sqrt{(x-a)^2}$, and then find an integral representation for $\sqrt{f(x)}$ where $f(x) = (x-a)^2$. But I am not sure if this is the `easiest' way to do it.
 A: $$\int_a^x \operatorname{sgn}(t-a)dt$$
where $\operatorname{sgn}(x)$ is the signum function.
Hope it helps:)
A: Since $|x - a|$ can be defined piecewise as $a - x$ for $x < a$ and $x - a$ for $x > a$, I think you should also be able to express the integral of the function as $ax - x^{2}/2$ for $x < a$ and $x^{2}/2 - ax$ for $x > a$. 
A: You have to split it into cases.
If $x-a<0\implies x<a$, then $|x-a|=-(x-a)$:
$$\int|x-a|\,dx=-\int(x-a)\,dx=-\frac{x^2}{2}+ax+C.$$
If $x-a=0\implies x=a$, then $|x-a|=0$:
$$\int|x-a|\,dx=\int 0\,dx=K.$$
If $x-a> 0\implies x> a$, then $|x-a|=x-a$:
$$\int|x-a|\,dx=\int(x-a)\,dx=\frac{x^2}{2}-ax+M.$$
As you can see, the antiderivative is a piecewise-defined function. Moreover, the fact that at $x=a$ the antiderivative is $K$ means that the original function is differentiable there and therefore continuous at that point. This simply means that the curve should not have a gap there So, you just need to find appropriate values for $C$ and $M$ that depend on $K$ to make the curve continuous at $x=a$. You do that by solving these equations for $C$ and $M$ respectively: $-\frac{a^2}{2}+a\cdot a+C=K$ and $\frac{a^2}{2}-a\cdot a+M=K$.
Finally, this is the antiderivative:
$$
f(x)=
\begin{cases}
-\frac{x^2}{2}+ax+K-\frac{a^2}{2},\ x<a\\
K,\ x=a\\
\frac{x^2}{2}-ax+K+\frac{a^2}{2},\ x> a.
\end{cases}
$$
A: If $f$ is convex on $[a,b]$, then $$f(x)=\int_a^x f'_+(t)\text{ d}t.$$
The function $f(x)=|x-a|$ is convex.
