I am given this piecewise function $f: \mathbb{R} \rightarrow \mathbb{R}$,

$f(x)= \left\{\begin{array}{ll}x^2 & x>0 \\ 0 & x ≤ 0 \\ \end{array} \right. $

I have to determine if the function is differentiable over $\mathbb{R}$ or not. The way I think about differentiability is like this:

"Can a function be differentiated at every point?"

But that doesn’t really help me, I have been looking for a specific formula I can generally use to determine if a function is differentiable or not, but with no luck.

How should I go about finding out if this function is differentiable or not?

  • 1
    $\begingroup$ Hint: Use the definition of derivative: $$ f'(x) = \lim_{h \rightarrow 0} \dfrac{f(x + h) - f(x)}{h} $$ given the limit on the RHS exists. Consider the limit when $x < 0, x > 0$ and $x = 0$. Does those limits exist in these cases ? $\endgroup$ Mar 2 at 13:36
  • 2
    $\begingroup$ You know that $f$ is differentiable everywhere that $x\ne 0$ because the two pieces are differentiable. Therefore, you must show that $f$ is differentiable at $0$. $\endgroup$
    – John Douma
    Mar 2 at 17:00

2 Answers 2


Perhaps a slightly clearer approach is simply the following. A function $f$ is said to be differentiable at $x$ if the following limit

$$ \lim_{h\to0} \frac{f(x+h)-f(x)}{h} $$

exists and is finite. Now note that the limit above exist if and only if the limit from above and below are equal (and are finite).

So we may define (if they exist)

$$ f'_\pm (x)= \lim_{h\to0^\pm} \frac{f(x+h)-f(x)}{h} $$

and we say $f$ is differentiable at $x$ if $f'_+(x)=f'_-(x)\neq \pm \infty$, in which case $f'(x)= f'_+(x)=f'_-(x)$.

Clearly your function is differentiable for all $x>0$ and for all $x<0$. It remains to check $x=0$. Now

$$f'_+(0) = \lim_{h\to0^+} \frac{h^2-0}{h} = 0. $$

On the other hand

$$f'_-(0) = \lim_{h\to0^-} \frac{0-0}{h} = 0. $$

The two limits coincide so the function is differentiable over the whole real line.

  • $\begingroup$ Great, thanks this makes sense. So we how now proofed that $f$ is differentiable. How would I go about showing that $f’(x)$ is also differentiable? $\endgroup$
    – N G
    Mar 2 at 17:29
  • $\begingroup$ Same thing. But now $f'(x) = 2x$ for $x>0$ and $0$ for $x\le0$, so you can intuitively see that's not going to happen by looking at the graph of the function. $\endgroup$
    – lcv
    Mar 2 at 17:46
  • $\begingroup$ Wouldn’t it be $f’(x) = 2$ for $x > 0$ Since $f(x) = 2x$ in this case, and 0 for $x <= 0$ $\endgroup$
    – N G
    Mar 2 at 19:05
  • $\begingroup$ Yes exactly. So the two limits are different at $x=0$. $\endgroup$
    – lcv
    Mar 2 at 23:13

First, we must check the continuity, because continuity is a necessary condition for differentiability. The only point we must check is the junction $x=0$ $$\lim_{x\to 0^+}f(x)=\lim_{x\to 0^+} x^2=0$$ $$\lim_{x\to 0^-}f(x)=\lim_{x\to 0^-} 0=0$$ so $f$ is continuous over $\mathbb{R}.$ Now we want to study if it's differentiable.

Notice that if $x>0$, then $f(x)=x^2$ which is differentiable, with derivative $f'(x)=2x.$ The same happens if $x\leq 0$, this time with $f'(x)=0.$ So we can consider $$f'(x)= \begin{cases} 2x & x>0 \\ 0 & x\leq 0 \end{cases} $$ Is it continuous? If yes, then $f$ if differentiable over $\mathbb{R}.$ Again, the only point we have to study is $x=0$, so we have $$\lim_{x\to 0^+}f'(x)=\lim_{x\to 0^+} 2x=0$$ $$\lim_{x\to 0^-}f'(x)=\lim_{x\to 0^-} 0=0$$ In conclusion, $f$ is differentiable over $\mathbb{R}.$

  • 1
    $\begingroup$ You have not dealt with the differentiability at $x=0$ properly. It depends on both positive and negative values of $x$; all you have shown is that the left-hand derivative exists at $0$. $\endgroup$ Mar 2 at 13:58
  • $\begingroup$ @ancientmathematician It is not true that $f$ is differentiable in $x_0$ if there exists the left-hand derivative and the right-hand derivative in $x_0$ and they are equals? $\endgroup$
    – Davide
    Mar 2 at 14:02
  • $\begingroup$ But you didn't show that the RH derivative exists, you only considered differentiability in $x>0$. Change that to $x\geqslant 0$ and all is OK. The fact that $f'(x)\to 0$ as $x\to 0+$ isn't enough. $\endgroup$ Mar 2 at 14:05
  • $\begingroup$ Perhaps because the right/left hand side derivative are (should be) defined as $f_{\pm}'(x) =\lim_{h\to0^\pm} [f(x+h)-f(x)]/h$ ? $\endgroup$
    – lcv
    Mar 2 at 16:44
  • 1
    $\begingroup$ @Davide FWIW, it's true that if (i) $f$ is defined and continuous in a neighborhood of $x_0$, (ii) $f$ is differentiable in a deleted neighborhood of $x_0$, and (iii) $\lim(f', x_0)$ exists, then $f$ is differentiable at $x_0$, and $f'(x_0)=\lim(f', x_0)$. <> This is not true by definition, however, but requires work with the mean value theorem. $\endgroup$ Mar 2 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .