# Showing a piece-wise function is differentiable everywhere/Clarification

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?

• where do you think your function is possibly not differentiable?? Is $f(x)=x^2$ differentiable in $(0,\infty)$ – user87543 Mar 31 '14 at 11:06
• See this answer: math.stackexchange.com/a/47978/7327 You have a criteria to verify when a function defined on branches is differentiable. – Beni Bogosel Mar 31 '14 at 11:34
• In addition to notes in answers below, you can show $f$ is differentiable at $0$ most directly by computing the limit of $(f(h) - f(0))/h$ as $h\rightarrow 0$. – Jason Zimba Mar 31 '14 at 13:03
• Sorry don't know latex when on comment box. So, for example if my piecewise function f was defined to be x^3 for x is larger than or equal to 0 and -x^3 for x is less than 0. Then f' would be 3x^2 for x > 0, -3x^2 for x < 0 and 0 for x = 0? – Bobby Mar 31 '14 at 14:36
• @Bobby That's right. – Jason Zimba Mar 31 '14 at 20:34

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.

Derivability is a local property, so:

In the open interval $(-\infty,0)$ $f$ is equal to the derivable function $x\mapsto -x^2$.

In the open interval $(0,\infty)$ $f$ is equal to the derivable function $x\mapsto x^2$.

Only need to check the derivability in $x=0$ using the definition of derivative.