How to differentiate $x^2-|x^3|$?
I tried breaking it into a piecewise function but I've been told this is not necessary.
How can I approach this in another way?
How to differentiate $x^2-|x^3|$?
I tried breaking it into a piecewise function but I've been told this is not necessary.
How can I approach this in another way?
use $|x|=\sqrt{x^2}$
so the equation becomes equivalent to $$x^2-\sqrt{x^6}$$
$$f(x)=x^2-|x^3|=\begin{cases}x^2-x^3~,~x\geq 0\\ x^2+x^3~,~x\leq 0\end{cases}$$
$$\implies f'(x)=\begin{cases}2x-3x^2=x(2-3x)~,~x\gt 0\\ 0~,~x=0\\ 2x+3x^2=x(2+3x)~,~x\lt 0\end{cases}$$
I think this is the simplest way to do it.
You can use piecewise functions. There is no problem with that. Any other approach mimics the same thing and will give you the exact same result.
We have the case of a composition of functions $g \circ f; g(x)=|x|, f(x)=x^3 $. The general result is that then $g \circ f $ is differentiable if (not of iff! ) g is differentiable at $f(x)$. But $g$ is differentiable everywhere except at 0 , so $g(f(x)$ may at worst not be differentiable at $0$, so that the only possible problem with the derivative of $|x^3|$ is at $0$, since $x^3$ is everywhere -differentiable and $|x|$ is differentiable everywhere but 0. But let of $0$, $3x^2 $ and $-3x^2$ both approach 0, so $x^2- |x^3|$ is everywhere differentiable.
EDIT: ultimately, the derivatives of $-x^3 , x^3$ are both everywhere continuous, and, in particular, are both continuous at $0$. By sequential continuity it follows that the limit t $0$ is $0$.
Alternatively:
We have $f(0) = 0$ and $f(x) = x^2(1 - |x|)$, as $|x|^3 = |x|x^2$.
Hence the derivative at zero,
$$f'(0) = \lim_{x \to 0} \frac{f(x) - f(0)}{x} = \lim_{x \to 0} \frac{x^2(1-|x|)}{x} = \lim_{x \to 0} x(1-|x|) = 0$$
One trick you can use is :
$$\frac{\rm d}{{\rm d}x} \vert x \vert = \frac{\vert x \vert}{x}$$
So with the chain rule you get:
$$\begin{align} \frac{\rm d}{{\rm d}x} x^2 - \vert x^3 \vert &= 2x - \frac{\rm d}{{\rm d}x} \vert x^3 \vert \\ &= 2x - \frac{\vert x^3 \vert}{x^3} \frac{\rm d}{{\rm d}x} x^3 \\ &= 2x - \frac{\vert x^3 \vert}{x^3} 2x^2 \\ &= 2x - \frac 2x \vert x^3 \vert \\ \end{align}$$