# Beginner deravative of peice wise question and connection with differentiation and continouity

Hi I am wondering if someone can help to explain to me the following;

Say we have $$f(x)= \begin{cases} x^{2}, &\text{ if x \ge 0 } \\ 0, &\text{if x \lt 0} \\ \end{cases}$$

and we want to calculate f'(x)

well the cases that are not zero are clear because it can easily be seen that the limits will exist etc, but I am confused a bit at the case at $x=0$ , ie I know that

$$f'(x)= \begin{cases} 2x, &\text{ if x \gt 0 } \\ 0, &\text{if x \lt 0} \\ \end{cases}$$

but I want to know what happens at 0.

So, would I take one sided limits to make sure that $f'(x)$ is continuous , and use the definition to find its value?

$$\lim_{x \to o+} \frac{f(x)-f(0)}{x-0}=lim_{x \to 0+} x=0$$

$$\lim_{x \to 0-} \frac{f(x)-f(0)}{x-0}=lim_{x \to 0-} 0=0$$

Since both sided limits exist and are equal, we have that the limit exists and so from definition would we have that

$$f'(x)= \begin{cases} 2x, &\text{ if x \ge 0 } \\ 0, &\text{if x \lt 0} \\ \end{cases}$$

But my confusion is, from the definition we have $f'(0)=0$, and this is at 0 itself, so should what I have above be

$$f'(x)= \begin{cases} 2x, &\text{ if x \gt 0 } \\ 0, &\text{if x \le 0} \\ \end{cases}$$

and if not, why? is calculating that limit to be zero only to signify it exists, but since f was defined as $x^{2}$ at zero, we take the derivative there as well?

Thanks all!

• For the derivative to exist at $x=0$ you need the left and right limit in the definition to be the same. Since your function (and the derivative) is continuos at this point it doesn't matter how you write it. – user269620 Jan 8 '16 at 0:37
• (i) The very best way to tackle differentiability at $0$ is to use the definition. Does the limit of $\frac{f(0+h)-f(0)}{h}$ exist, and if so what is it? (ii) In your $x^2\sin(1/x)$ example it is $f$ that is differentiable everywhere, not $f'$. – André Nicolas Jan 8 '16 at 0:44
• @AndréNicolas Thanks I figured out that second part. For the first part, I found it yes, using the definition I get the limit to be zero. But I am confused on if this is the derivative at x=o, so why is it 2x at x=0, ( Ie, which of the two piece wise I put at the bottom paragraph is the right one) – PersonaA Jan 8 '16 at 0:46
• I hope someone will deal soon with your question about the right and left limits of the derivatives. I cannot do it for at least five hours. Anyway, the question of the existence and value of the derivative at $0$ has been settled by a direct use of the definition of the derivative. – André Nicolas Jan 8 '16 at 0:53
• The question has changed a lot. Toward the bottom you have two displayed formulas for $f'(x)$. The formulas say the same thing, so they are both right. – André Nicolas Jan 8 '16 at 16:25