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:
Proof:
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.
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.