Derivatives of function when the function is defined differently for different values of x

90 Views Asked by At

If $$ f(x) := \begin{cases} 0 & x = 0 \\ x + x^2\sin(1/x) & x \neq 0 \end{cases} $$ then by the definition of derivative I get $f'(0) = 1$, and if I differentiate $x + x^2\sin(1/x)$ and then plug in $0$ I also get $f'(0) = 1$, but I don't know why I can plug in $0$ here since isn't $f(x)=x + x^2\sin(1/x)$ only when $x\neq0$?

And I'm also wondering since $f(x)=0$ when $x=0$ why can't we just differentiate this function and say $f'(0) = 0$.

Another question I have is that if $$ f'(x) := \begin{cases} x^3 & x\geq 0 \\ -x^3 & x < 0 \end{cases} $$ why do we have to consider $x=0$ to be a separate case when trying to find the derivatives (for $x=0$ we have to use the definition of derivative to show $f'(0) = 0$ but for $x\neq0$ we can just differentiate it directly)?

1

There are 1 best solutions below

0
On

First of all, since $f'(x)=1+2x\sin\left(\frac1x\right)-\cos\left(\frac1x\right)$, you simply cannot plug in $0$.

Concerning the second question, suppose that you define$$\begin{array}{rccc}g\colon&\mathbb R&\longrightarrow&\mathbb R\\&x&\mapsto&\begin{cases}x&\text{ if }x\neq0\\0&\text{ if }x=0.\end{cases}\end{array}$$If the method that you suggested worked, we would have $g'(0)$. But $g$ is the identity function (that is, $g(x)=x$ for each $x$) and therefore $g'(0)=1$).

FInally, my answer to the second question also answers the third one.