Is there a function whose derivative is $|x|$? Is there a function $y=f(x)$ such that $$\frac{df}{dx}|_{x=a} =|a|$$ for all $a\in \mathbb R$? I'm in a debate with my friend over it and we are stuck
 A: I think that $\dfrac{\left\lvert x\right\rvert x}2=\operatorname{sgn}(x)\dfrac{x^2}2$ works. (That is, it's $\dfrac{x^2}2$ when $x\ge0$, and $-\dfrac{x^2}2$ when $x\le0$.)
Proof: When $a$ is positive, we have $\left.\dfrac{\left\lvert x\right\rvert x}2\right\vert_{x=a}=\dfrac{a^2}2$, and the derivative is $a=\lvert a\rvert$.
When $a$ is negative, we have $\left.\dfrac{\left\lvert x\right\rvert x}2\right\vert_{x=a}=-\dfrac{a^2}2$, and the derivative is $-a=\lvert a\rvert$.
When $a$ is $0$, $\displaystyle\lim_{a\to0^+}f'(a)=\lim_{a\to0^-}f'(a)=0=|a|$.
A: Let $f(x) = \int_0^x | s | \, ds$. By the fundamental theorem of calculus $f'(
x) = |x|$.
A: You need to have a positive slope everywhere so $f(x)=\frac12 x^2$ is insufficient.
Nowhere does it say the function can't be composed of multiple pieces. So, 
\begin{equation*}
f(x) = \begin{cases} \frac12 x^2 \qquad \text{for } x \geq 0, \\
 -\frac12 x^2 \qquad \text{for }  x<0.
\end{cases}
\end{equation*}
$f(x)$ is continuous, and differentiable since $|-0| = |0|$.
