# Integrating/differentiating the signum function correctly

I was having a look into the signum function on Wikipedia, and it gives the definition of it as: $$sgn(x)= \begin{cases} 1, & x>0 \\ 0, & x=0 \\ -1, & x<0 \end{cases}$$

However, if I integrate this function for all $$x$$, I wind up with $$|x|+c$$ (assuming that the constant of integration is the same for each condition). $$\int sgn(x)\,dx= \begin{cases} \int 1\,dx, & x>0 \\ \int 0\,dx, & x=0 \\ \int -1\,dx, & x<0 \end{cases} \\= \begin{cases} x, & x>0 \\ 0, & x=0 \\ -x, & x<0 \end{cases} +c \\= \begin{cases} x, & x\ge0 \\ -x, & x<0 \end{cases} +c \\= |x|+c$$

If I differentiate $$|x|+c$$, however, I get the result of $$\frac{|x|}{x}$$ which assumes x is not zero, but is different from the definition. Wikipedia mentions that this definition is true for $$x\ne0$$; but how would I return to the original definition from the derivative - assuming the integration was correct?

Well, $$|x|$$ isn't differentiable at $$x=0$$, so you can't hope to retrieve anything there. If $$f$$ is a general (not necessarily continuous) $$L^1_{loc}$$-function (i.e. integrable over compact intervals), then defining $$F(x)=\int_0^x f(t)\textrm{d}t,$$ it's only true that $$F'(x)=f(x)$$ holds almost everywhere. In your case, you get the conclusion for every $$x\neq 0$$.