# Examples of functions $f$ and $g$ such that one of them is not differentiable but $f+g$ is differentiable

I'm searching for counterexamples of functions $f$ and $g$ such that one of them is not differentiable but $f+g$ is differentiable. I've already found counterexamples of the product case ($f(x)=|x|$ and $g(x)=-|x|$) but I couldn't find examples of the sum case.

-
$f+(-f)$?${}{}{}{}{}$ – David Mitra Feb 25 '13 at 12:23
@DavidMitra thanks – user42912 Feb 25 '13 at 12:25

## 4 Answers

Choose your favourite non-derivable function $f$, and let $g = h - f$, where $h$ is your favourite derivable function.

$g$ cannot be derivable, either, otherwise $f = h - g$ would.

-

Let $f:\mathbb R\to \mathbb R$, $f(x)=1$ if $x\in \mathbb Q$ and $f(x)=0$ if $x\not\in \mathbb Q$.

Let $g:\mathbb R\to \mathbb R$, $g(x)=0$ if $x\in \mathbb Q$ and $g(x)=1$ if $x\not\in \mathbb Q$.

Then $f$ and $g$ are continuous nowhere but $f+g=1$ and $f\times g=0$ are differentiable everywhere.

-
The strongest example, thanks! – user42912 Feb 25 '13 at 12:36

Have you tried the same example as in multiplication? In general $f+(-f)$ is derivable.

-
you're right, thanks – user42912 Feb 25 '13 at 12:28

For a little less trivial example you can take the functions

$$f(x)=|x|\;\;,\;\;g(x)=\begin{cases}x&,\;\;\;x\le 0\\{}\\x^2-x&,\;\;\;x>0\end{cases}\Longrightarrow (f+g)(x)=f(x)+g(x)=\begin{cases}0&,\;\;\;x\le 0\\{}\\x^2&,\;\;\;x>0\end{cases}$$

Check that none is derivable at $\,x=0\,$ , yet their sum is.

-