Implication of absolute value in $f_X(x)=|x|/10$ for $-2\le x\le4$ $$f_X(x)=\frac{|x|}{10}\qquad-2\le x\le4$$
For the above density function, it is explained that in finding $E[X]$, the expression must be split up because for $x<0$, $|x|=-x$.
I thought that $|x|$ is always $x$ whether $x$ is negative or positive.
How is it true in this case that for $x<0$, $|x|=-x$????
 A: 
I thought that |x| is always x whether x is negative or positive. 
  How is it true in this case that for x<0, |x|=−x????

So, this is an integer number line
 
Any number we don't know yet, we can just call $x$.
(Geometric) Definition: $|x|$ is the distance of $x$ from $0$.
Now if $x=-3$, the distance of $-3$ from $0$ can't be $-3$, because the distance is always positive. 
That's why $|-3|=-(-3)=3$ is the distance of $-3$ from $0$ (using the fact that $- \cdot - = +$)
And in general (the mathematical definition)
$$|x| = \left\{
   \begin{array}{rl}
     x, & \text{if }  x \geq 0, \\
     -x, & \text{if } x < 0.
   \end{array}\right.$$
and $|x|$ is always not negative.
$$E(X)=\int_{-2}^{4}x~f_X(x)~dx=\int_{-2}^{4}x|x|/10~dx =-\int_{-2}^{0}x^2/10~dx+\int_{0}^{4}x^2/10~dx=28/15$$
A: The absolute value function, by definition, never produces a negative result, and produces the unsigned distance of its argument from $0$. Thus if $x<0$, it must be that $|x|=-x$, to make the negative argument positive again.
