I have a function x * |x|
To get the derivative I used the first principals:
$$ f'(x) = ( (x-h) * | x + h | - (x * |x|) )/ h $$
So if x is + I got
$$ x ^ 2 + xh - xh - h^2 - x^2 / h $$ $$ -h^2/h$$ $$ -h $$ $$ 0 $$
If x is negative:
$$ x^2 - 2xh + h^2 - x^2$$ $$ -2xh+h^2 $$ $$ h (-2x + h)/h$$ $$ -2x + h $$ $$ -2x $$
So I checked with a derivative calculator and it says the answer is 2x....
So I'm not exactly sure why I got -2x, and why do we only used the negative part, why is the answer not -2x for negative x and 0 for positive x... why is only one chosen?