# Why is the differentiability of a piecewise defined function studied using the definition of derivative?

Why is the differentiability of a piecewise defined function often studied using the definition of derivative?

For example, let: \begin{align*} f(x) &= x\cdot |x-1|\\ &= \left\{ \begin{array}{lcl}x (-x+1)& \text{if} & x < 1 \\ x (x-1) & \text{if} & x \geq 1 \end{array} \right.\\ &= \left\{ \begin{array}{lcl}-x^2+x& \text{if} & x < 1 \\ x^2-x & \text{if} & x \geq 1 \end{array} \right. \end{align*}

$f$ is continuous in $\mathbb{R}$ except, maybe, when $x=1$: \begin{align*} \lim_{x \to 1^{-}} f(x) &= \lim_{x \to 1} (-x^2+x) = 0\\ \lim_{x \to 1^{+}} f(x)&= \lim_{x \to 1} (x^2 -x) = 0 \end{align*}

$f$ is continuous when $x=1$ because: $$\lim_{x \to 1^{-}} f(x) = \lim_{x \to 1^{+}} f(x) = f(1)$$

As to the differentiability at that point (by derivative's definition):

\begin{align*} \lim_{h \to 0^{-}} \frac{f(1+h)-f(1)}{h} &= \lim_{h \to 0} \frac{\left[-(1+h)^2 + (1+h)\right] - \left[-1^2 + 1\right]}{h}\\ &= \lim_{h\to 0} \frac{- h(h+1)}{h} = -1\\ \strut\\ \lim_{h \to 0^{+}} \frac{f(1+h)-f(1)}{h} &= \lim_{h \to 0} \frac{\left[(1+h)^2 - (1+h)\right] - \left[1^2 - 1\right]}{h}\\ &= \lim_{h\to 0} \frac{h(h+1)}{h} = 1 \end{align*}

$$\lim_{h \to 0^{-}} \frac{f(1+h)-f(1)}{h} \neq \lim_{h \to 0^{+}} \frac{f(1+h)-f(1)}{h}$$

so $f$ is not differentiable when $x=0$.

The "second" method is:

$$f'(x) = \left\{ \begin{array}{lcl} -2x + 1& \text{if} & x < 1 \\ 2x-1 & \text{if} & x > 1 \end{array} \right.$$

$$f'(1^{-}) = -1 \neq f'(1^{+}) = 1$$

Is there any case in which the differentiability study by using the derivative (the second method) would be wrong?

## 1 Answer

Consider the function $$f(x) = \left\{\begin{array}{ll} x^2\sin\left(\frac{1}{x}\right) &\text{if }x\neq 0,\\ 0 &\text{if }x=0. \end{array}\right.$$

The function is differentiable at $0$, with derivative equal to $0$: \begin{align*} \lim_{h\to 0}\frac{f(h)-f(0)}{h} &= \lim_{h\to 0}\frac{h^2\sin(\frac{1}{h})}{h} \\ &=\lim_{h\to 0}h\sin(\frac{1}{h}) = 0. \end{align*} However, using the "second method", we look at the derivative of $x^2\sin(\frac{1}{x})$: $$\left(x^2\sin\left(\frac{1}{x}\right)\right)' = 2x\sin\frac{1}{x} - \cos\frac{1}{x}.$$ And $$\lim_{x\to 0}\left(2x\sin\frac{1}{x}-\cos\frac{1}{x}\right)$$ does not exist. Using the method, we would incorrectly conclude that the derivative does not exist at $0$.

In general, a derivative does not have to be continuous; so the second method may yield "false negatives", functions that are differentiable but which the technique suggests are not.

• Thanks! it solved my question. Is there any formal demonstration? – user23108 Mar 28 '12 at 20:20
• @Albert: Formal demonstration of what? I gave an example of a function for which the method gives the wrong conclusion. That constitutes a proof that the method may give the wrong conclusion. – Arturo Magidin Mar 28 '12 at 20:21
• Sorry, I just got confused: I wanted an example of a continuous function – user23108 Mar 28 '12 at 20:36
• @AlbertT. Of a continuous function that does what? The function I give is continuous everywhere; in fact, it's differentiable everywhere. It's the derivative that is not continuous. – Arturo Magidin Mar 28 '12 at 20:37
• Sorry again. I just copied the function incorrectly. Thanks for all. – user23108 Mar 28 '12 at 20:47