Is this function twice differentiable at $0$?

I have a function $f(x)$:

$$f(x)=\frac{\exp(-|x|)}{1-0.5|\tanh(2x)|}$$

If I try differentiating it in Mathematica (taking $|x|=(2\theta(x)-1)x$ where $\theta(x)$ is Heaviside step function), I get answer in terms of Heaviside functions. But looking at the derivative I can't really see any jump there, which is why I start thinking that it has a second derivative too. But differentiating once more, I get answer with Dirac functions, which don't disappear when evaluating the result at $x=0$.

If I instead represent $|x|=\sqrt{x^2}$, then for the first derivative I get an expression which has $0$ as its limit as $x\to0$, and for second derivative the limit appears to be 1. So from this I could make the conclusion that $f(x)$ is twice differentiable at $x=0$.

So the question: is this function differentiable at $x=0$? Is it twice differentiable?

-

Since we are dealing with real $x$ (we are, aren't we?), we can write

$$\lvert \tanh (2x)\rvert = \tanh (2\lvert x\rvert).$$

We have $\frac12\tanh (2\lvert x\rvert) = \lvert x\rvert + O(\lvert x\rvert^3)$, so we can calculate

\begin{align} \frac{e^{-\lvert x\rvert}}{1 - \frac12\tanh(2\lvert x\rvert)} &= \left(1 - \lvert x\rvert + \frac{\lvert x\rvert^2}{2} + O(\lvert x\rvert^3)\right)\left(1 + \lvert x\rvert + \lvert x\rvert^2 + O(\lvert x\rvert^3)\right)\\ &= 1 + \frac{\lvert x\rvert^2}{2} + O(\lvert x\rvert^3). \end{align}

Since the two halves of the function are analytic, it follows that the function is twice continuously differentiable.

Generally, if we have a function of the form

$$f(x) = \begin{cases}g(x) &, x \geqslant 0\\ h(x) &, x \leqslant 0 \end{cases}$$

where $g$ and $h$ are continuously differentiable functions with $g(0) = h(0)$ - so that the definition of $f$ has no conflict - then $f$ is differentiable in $0$ if and only if $g'(0) = h'(0)$, and then $f$ is continuously differentiable with $f'(0) = g'(0) = h'(0)$.

If $g$ and $h$ are analytic, i.e. we have power series representations

$$g(x) = \sum_{n=0}^\infty a_n x^n,\qquad h(x) = \sum_{n=0}^\infty b_n x^n,$$

then $f$ is $k$ times (continuously) differentiable if and only if $a_n = b_n$ for $0 \leqslant n \leqslant k$. The computation above shows that the two functions

$$g(x) = \frac{e^{-x}}{1-\frac12\tanh(2x)}\quad\text{and}\quad h(x) = \frac{e^x}{1+\frac12\tanh(2x)}$$

both have power series expansions starting with $1 + \frac12 x^2$, so $f$ is twice continuously differentiable.

-
Nope. $\tanh$ is an odd function, and $\tanh x > 0$ for $x > 0$, so $\lvert \tanh x\rvert = \tanh \lvert x\rvert$. – Daniel Fischer Oct 28 '13 at 20:21
That's true. My typo$\ldots$ Thanks. – Felix Marin Oct 28 '13 at 20:43
Since a second-order Taylor approximation does not imply that the function is twice differentiable (unlike order one is equivalent to differentiability), maybe a few more details would be needed ;-) – 1015 Oct 28 '13 at 21:02
@julien Would you consider merely referring to the analyticity of both halves sufficient, or would you advise elaborating more? – Daniel Fischer Oct 28 '13 at 21:10
I might be blind but I can't see why this is clearly analytic. But for all $x$ non zero (doing $x$ positive and negative separately), we have $f'(x)=\frac{\exp(-|x|)(2 \tanh(2|x|)+4\sech^2(2|x|)-4) }{(2-\tanh(2|x|))^2}$ and we can easily look at the limit of $(f'(x)-f'(0))/(x-0)=f'(x)/x$ from there. Which is indeed $1$. – 1015 Oct 28 '13 at 21:33

$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\dd}{{\rm d}}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\ic}{{\rm i}}% \newcommand{\imp}{\Longrightarrow}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert #1 \right\vert}% \newcommand{\yy}{\Longleftrightarrow}$ $\large\tt Hint:$ \begin{align} \verts{\tanh\pars{2x}} &= \tanh\pars{2\verts{x}} \\[3mm] \verts{\tanh\pars{2x}}\,' &= \sech^{2}\pars{2\verts{x}} \bracks{2\sgn\pars{x}} = 2\sgn\pars{x}\sech^{2}\pars{2x} \\[5mm] \verts{\tanh\pars{2x}}\,'' &= 2\delta\pars{x}\sech^{2}\pars{2x} + 2\sgn\pars{x} \bracks{-4\tanh\pars{2x}\sech^{2}\pars{2x}} \\[3mm]&= 2\delta\pars{x} - 8\tanh\pars{2\verts{x}}\sech^{2}\pars{2x} \\[5mm] \pars{\expo{-\verts{x}}}' &= -\sgn\pars{x}\expo{-\verts{x}} \\[3mm] \pars{\expo{-\verts{x}}}'' &= -2\delta\pars{x}\expo{-\verts{x}} - \sgn\pars{x}\expo{-\verts{x}}\bracks{-\sgn\pars{x}} = -2\delta\pars{x} + \expo{-\verts{x}} \end{align}

-
Sorry but this is not mathematics, even as hints. – Did Oct 28 '13 at 20:49