So I was recently solving a question about the derivative of $|\sin(x)|$ and the answer above me used a piecewise function to solve the problem.

I used the definition $|x|=\sqrt{x^2}$, and the problem became incredibly easy to solve. So, I guess what I am wondering, is why people define $|x|$ by a piecewise function like:

$|x|= \begin{cases} x , & \text{if } x \geq 0\\ -x, & \text{otherwise} \end{cases}$

Because it is harder to differentiate and the only possible application is integration. Plus, my definition is easier to prove:


The absolute value of a real number is defined as the magnitude of the real number.

The magnitude of a complex number $a+bi$ is $\sqrt{a^2+b^2}$, and if $b$ is $0$ because the number is real, then $|a|=\sqrt{a^2}$.

So, in conclusion, I want to know how this piecewise definition came about, and why I never see my definition. If possible, I would like to know the flaws with my definition.

  • $\begingroup$ It is actually rather common to define $\vert x\vert$ as $\sqrt{x^2}$. Even without that definition one can easily find, using the limit definition of derivative, that the derivative of $\vert x\vert$ is $\frac{x}{\vert x\vert}=\frac{\vert x\vert}{x}$ and then use the chain rule when finding the derivative of $\vert f(x)\vert$. $\endgroup$ – John Wayland Bales Apr 13 '17 at 3:34
  • 2
    $\begingroup$ It's as simple as the fact that the definition ought to be the most straightforward mathematical expression possible. Often definitions aren't mathematically convenient, that is why so many identities exist in the world of math. The identity you've given here is VERY common. In fact, a simple search on Wikipedia puts it as the second equation under the "Definition and properties" section. At the end of the day, both are equivalent, but one is a more sensible definition. $\endgroup$ – David Apr 13 '17 at 3:54
  • $\begingroup$ Actually the first definition I ever saw was $|x|=\max(x,-x)$. $\endgroup$ – A. Bellmunt Sep 14 '18 at 15:16

I'm not sure if there is a good answer to this question. Both definitions have their merits. Your definition is just a special case of the definition of the standard metric on $\mathbf{R}^n$. Namely, $$ d_E(x,y)=\sqrt{\sum_{i=1}^n(x^i-y^i)^2}$$ where $x=(x^1,\ldots, x^n)$ and $y=(y^1,\ldots y^n)$. In this case, $\lvert x\rvert $ is simply the Euclidean distance of $x$ from the origin in $\mathbf{R}$. That is, $$ \lvert x\rvert=\sqrt{x^2}.$$ On the other hand, sometimes it is nice to regard $\lvert x\rvert$ as two lines. That is, $$ \lvert x\rvert=\begin{cases} x&x\ge 0\\ -x&x<0. \end{cases}$$ In the latter case, we just know that we can pretend $\lvert x\rvert$ is either $x$ or $-x$ depending on which side of the origin we are on. In short, both of these definitions are fundamental and equally valid.


The definition for $|x|$ is naturally stated in terms of diferent conditions, depending whether $x \geq 0$ or $x<0$ because $|x|$ is distance from $0$ to $x$ and we agree that distance is always $\geq 0$.

The definition $|x|=\sqrt {x^2}$ is also fine because when we talk about square root we agree that square root of nonnegative real number is nonnegative itself so $\sqrt {x^2}$ is never a negative number and it equals $|x|$ because of $(-x)^2=x^2$.

The way in which you arrived at "your" definition is kind of not practical because you use complex numbers to define distance on the real line and they are certainly not needed to do that.

  • 1
    $\begingroup$ I think this is a perfectly sensible answer (more in line with my thoughts on the matter than the accepted one), the downvote is certainly perplexing to me. $\endgroup$ – pjs36 Apr 13 '17 at 4:44
  • $\begingroup$ @pjs36 Don`t worry be happy. I also do not understand the reasons for a downvote. $\endgroup$ – Paladin Apr 13 '17 at 4:50
  • $\begingroup$ You focused on the additional part of my question that I added on as an afterthought, while the two fundamental parts where slightly... ignored? That's why I accepted the other one, it answers the question. This seems more like an opinion. $\endgroup$ – Robin Aldabanx Apr 13 '17 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.