4

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?

Ghozt
  • 705

2 Answers2

5

Since $|x|=\sqrt{x^2}$ we have $f(x)=x\cdot\sqrt{x^2}\Rightarrow f'(x)=\sqrt{x^2}+x\cdot\dfrac{1}{2\sqrt{x^2}}\cdot2x=|x|+\dfrac{x^2}{\left|x\right|}$.

EDIT: Further simplification: $f(x)=\dfrac{\left|x\right|^2+x^2}{\left|x \right|}= \dfrac{2\left| x\right|^2}{\left| x\right|}=2\left| x\right|$.

Michael Hoppe
  • 18,614
2

I think if you use the following equivalent definition, then the result will be achieved more concrete: $$f'(x_0)=\lim_{x\to x_0}\frac{f(x)-f(x_0)}{x-x_0}$$ In fact, while $x_0>0$ then $x\to x_0$ make $x$ to be positive and when $x_0<0$ then $x\to x_0$ make $x$ to be negative. So we will have $x|x|=x^2$ or $x|x|=-x^2$ respectively. Just think about $x_0=0$.

Mikasa
  • 67,942
  • I still don't understand, if we say x|x| is either +x^2 or -x^2 then solving f'(x) would be 2x for +x^2 and -2x^2 - 2x for -x^2... so is the derivative of x|x| both 2x and -2x^2 - 2x? – Ghozt Oct 15 '13 at 13:22