[Math] Showing a piece-wise function is differentiable everywhere/Clarification

calculus

Just a thought and a concept which I need to be clarified.

Given a function $f:\mathbb{R} \rightarrow \mathbb{R}$

Now my understanding of the term "differentiable everywhere" means it is differentiable at all points in its domain $\mathbb{R}$? If this is incorrect then can someone give me a simple to understand definition?

Now consider a piece-wise function (I just made this up from my head, not sure if it is differentiable everywhere) with,

$$f(x) = \left\{\begin{array}{cc}x^2 & \text{if }x\geq 0 \\ -x^2& \text{if }x < 0\end{array}\right.$$

How would we show that it's "differentiable everywhere". Also, if we were to find $f'(x)$ then would it simply taking each derivative in each of the case? Or do we need to consider something else?

Best Answer

As you say, $f \,:\, A \to \mathbb{R}$ with $A \subset \mathbb{R}$ means that for every $x \in A$, the derivative $f'(x)$ exists. In other words, for every $x \in A$, the limit $$ f'(x) = \lim_{y \to x} \frac{f(y) - f(x)}{y-x} $$ exists. Note that, due to the way limits works, whether or not $f'(x)$ exists depends only on the behaviour of $f$ in the immediate vicinity of $x$. More formally, if you have two functions $f$ and $g$, and some $\epsilon$ such that $f(y) = g(y)$ for all $y \in (x-\epsilon,x+\epsilon)$, then $f'(x) = g'(x)$.

Since you probably already know that the derivatives of $x \to x^2$ and $x \to -x^2$ exist on the whole real line, you therefore know that the derivative of $$ f(x) = \begin{cases} x^2 &\text{if $x\geq 0$} \\ -x^2 &\text{if $x < 0$} \end{cases} $$ exists everywhere except at $x=0$. Because if $x \neq 0$, then $f(x) = x^2$ or $f(x) = -x^2$ on some small interval around $x$.

So all you have to do is to decide whether or not the derivate at $x=0$ exists or not. The first step is to check that $f$ is continuous at $x=0$. Since both $x^2$ and $-x^2$ are continuous $0$, it suffices to check that they take the same value at $x=0$ - and they do, $0^2 = -0^2$ after all. Note that being continuous at a point is a necessary (but not sufficient!) condition for being differentiable at that point. So had the continuity check failed, you could have immediately concluded that $f$ is not differentiable at $0$.

Since $f$ is continuous at $x=0$, and since the derivative of both $x^2$ and $-x^2$ also exists at $x=0$, it's sufficient for the derivative of $x^2$ and $-x^2$ to also take the same value at $x=0$ for $f$ to be differentiable there. And, indeed, they do - $\frac{d}{dx}(x^2) = 2x$ and $\frac{d}{dx}(-x^2) = -2x$, which at zero both take the value $0$. Thus, your $f$ is indeed differentiable everywhere.

Related Question