Consider the following function: \begin{align} f(x)= \frac{1}{2} E\left[ \tanh \left( \frac{x+Z}{2} \right) \right]-\tanh(x)+\frac{x}{2}, \end{align} where $Z$ is standard normal.

Question: How to show that this function has only three zeros? Note, that we are not interested in the locations just the number of zeros.

By using that $\tanh(x)$ is an odd function, it is not difficult to show that $f(0)=0$. However, I am not sure how to show the existence of the other two zeros.

I know that two more zeros exist from the numerical simulation (see the attached figure). enter image description here

Edit: The current answer shows that there are at least 3 zeros. Now we need to show that there can be no more than 3 zeros.

Edit 2 Idea for a proof. Consider only positive $x$. I think if we can show the following:

  • $f(x)>0$ for all $x>x_1$,
  • $f(x)$ is convex for $x \in (0,x_2)$, and
  • $x_2>x_1$.

Then this will imply that the function is convex in the regime while it changes a sign. Therefore, it can only have at most one sign change.

  • $\begingroup$ Intriguing question. Is there any motivation of context as to why you consider this function? $\endgroup$ Jan 3, 2022 at 19:35
  • 1
    $\begingroup$ @SangchulLee Thanks. It's coming from estimation theory. $\tanh(x)$ is related to an estimator of $X \in \pm 1$ in Gaussian noise. The number of zeros is just an intermediate bound that I need. $\endgroup$
    – Boby
    Jan 3, 2022 at 19:45

3 Answers 3


Not a complete proof, but rather a sketch. First, observe that as $x\to +\infty$, than $\tanh (x) \to 1$, so $f(x)$ asymptotically asymptotically equivalent to $\frac{1}{2} E [1] - 1 + \frac{x}{2} = \frac{x-1}{2}$, so for some large enough positive value of $x$ one has $f(x) > 0$. After that, let's look at the graph of the function and notice that $f'(0)$ must be negative, which is not hard to prove: As $$ \frac{1}{2} E\left[ \tanh \left( \frac{x+Z}{2} \right) \right] = \frac{1}{2} \int_\mathbb{R} \tanh \left( \frac{x+z}{2} \right) \frac{1}{\sqrt{2\pi}} e^{-z^2/2}dz $$ So $$ f'(x) = \frac{1}{2} \int_\mathbb{R} \frac{\partial}{\partial x}\left[ \tanh \left( \frac{x+z}{2} \right)\right] \frac{1}{\sqrt{2\pi}} e^{-z^2/2}dz + \frac{d}{dx} \left[-\tanh (x) + \frac{x}{2}\right] = \\ = \frac{1}{4} \int_\mathbb{R} \frac{1}{\cosh^2 \left( \frac{x+z}{2} \right)} \frac{1}{\sqrt{2\pi}} e^{-z^2/2}dz - \frac{1}{\cosh^2 (x)} + \frac{1}{2} \\ f'(0) = \frac{1}{4} \int_\mathbb{R} \frac{1}{\cosh^2 \left( \frac{z}{2} \right)} \frac{1}{\sqrt{2\pi}} e^{-z^2/2}dz - 1 + \frac{1}{2} \leq \frac{1}{4} \int_\mathbb{R} \frac{1}{\sqrt{2\pi}} e^{-z^2/2}dz - \frac{1}{2} = \frac{1}{4} - \frac{1}{2} = -\frac{1}{4} $$ where the inequality is obtained from $\frac{1}{\cosh^2 \left( \frac{z}{2} \right)} \leq 1 \;\forall z \in \mathbb{R}$. So, it means that $f(x)$ is decreasing in some neighborhood of zero.

So, there exists some $x^+ > 0$ s.t. $f(x^*) > 0$ and some $x^- > 0$ s.t. $f(x^-) < f(0) = 0$. So, by intermediate value theorem (it's also an exercise to check the continuity of $f(x)$) there exists some $x^* \in [x^-, x^+]$ s.t. $f(x^*) = 0$. As $f(x)$ is an odd function, it means that $-x^*$ is also a root.

EDIT: as $\frac{1}{2} - \frac{1}{\cosh^2(x)} \leq f'(x) \leq \frac{3}{4} - \frac{1}{\cosh^2(x)}$ and $f'(0) = 0$, I suppose that with similar methods one can prove that $f$ also has a stationary point somewhere on positive axis, which can help in proving that there are no other roots.

  • $\begingroup$ This shows that there exist two more zeros. Thanks. Correct me if I am wrong, but this doesn't show that there are only three zeros, right? $\endgroup$
    – Boby
    Jan 3, 2022 at 22:45
  • 1
    $\begingroup$ @Boby yes, you're right. Currently I can't come up with proper proof on showing that there are only two more zeros, but I've included some thoughts in the edit. $\endgroup$ Jan 3, 2022 at 22:51
  • $\begingroup$ Thanks and thanks for the ideas. $\endgroup$
    – Boby
    Jan 3, 2022 at 22:52
  • $\begingroup$ @Boby by the way, the given plot is somewhat confusing, since $f(x)$ looks like cubic. $\endgroup$ Jan 3, 2022 at 23:08
  • $\begingroup$ I had to zoom in far enough to show that there were three zeros. I guess, I can try to fix it $\endgroup$
    – Boby
    Jan 3, 2022 at 23:09

Note: The proof below works, but I made it unnecessarily difficult. In equality $(1)$, I forgot about the normalising factor $1/\sqrt{2\pi}$ which made the upper bound unnecessarily large (it still works since $1/\sqrt{2\pi}<1$).

Claim. The real function $g(x)=x-2\tanh x+\Bbb E\tanh((x+Z)/2)$ has exactly three real zeros.

Proof: Since $\Bbb E\tanh((-x+Z)/2)=\Bbb E\tanh((-x-Z)/2)=-\Bbb E\tanh((x+Z)/2)$, we know that $g$ is odd. As $g(0)=0$, it suffices to show that $g$ has exactly one positive root.

Computing the first derivative, we have $g'(x)>1-2\operatorname{sech}^2x$ since $$\frac d{dx}\Bbb E\tanh\frac{x+Z}2=\frac12\Bbb E\operatorname{sech}^2\frac{x+Z}2>0.$$ Therefore, $g$ is strictly increasing for all $x>\operatorname{arccosh}\sqrt2$, so it suffices to show that $g'$ is strictly increasing on $(0,\operatorname{arccosh}\sqrt2)$; that is, a convexity argument on $g$.

Computing the second derivative, we obtain $g''(x)=4\tanh x\cdot\operatorname{sech}^2x-h(x)$ where \begin{align}h(x)&=-\frac d{dx}\Bbb E\operatorname{sech}^2\frac{x+Z}2\\&=\Bbb E\left[\tanh\frac{x+Z}2\cdot\operatorname{sech}^2\frac{x+Z}2\right]\\&=\int_{-\infty}^\infty\frac{e^{-(z-x)^2/2}\sinh(z/2)}{\cosh^3(z/2)}\,dz\tag1\\&=2e^{-x^2/2}\int_{-\infty}^\infty\frac{e^{-2z^2+2xz}\sinh z}{\cosh^3z}\,dz\\&=2e^{-x^2/2}\int_1^\infty\frac{e^{-2\operatorname{arccosh}^2t+2x\operatorname{arccosh}t}-e^{-2\operatorname{arccosh}^2t-2x\operatorname{arccosh}t}}{t^3}\,dt\tag2\\&=4e^{-x^2/2}\int_0^\infty\frac{e^{-2\operatorname{arccosh}^2(t+1)}\sinh(2x\operatorname{arccosh}(t+1))}{(t+1)^3}\,dt\\&<4e^{-x^2/2}\int_0^\infty\frac{\sinh(2x\operatorname{arccosh}(t+1))}{(t+1)^7}\,dt\tag3\end{align} where

  • in $(1)$, we use the law of the unconscious statistician;

  • in $(2)$, we split the integral into $(-\infty,0)\cup(0,\infty)$ and substitute $t=\cosh z$, and

  • in $(3)$, we use the inequality $\cosh x\le e^{x^2/2}$ for all real $x$ which rearranges to $\exp(-2\operatorname{arccosh}^2t)<1/t^4$ for all $t>1$.

Credits to @KStarGamer for help in the evaluation of this integral! We first exploit the Laplace transform integral identity $$\int_0^\infty\frac{\sinh(2x\operatorname{arccosh}(t+1))}{(t+1)^7}\,dt=\int_0^\infty\mathcal L\left[\sinh(2x\operatorname{arccosh}(t+1))\right](s)\cdot\mathcal L^{-1}[(t+1)^{-7}](s)\,ds.$$ Since $\mathcal L^{-1}[(t+1)^{-7}](s)=s^6e^{-s}/6!$ and \begin{align}\int_0^\infty e^{-st}\sinh(2x\operatorname{arccosh}(t+1))\,dt&=e^s\int_1^\infty e^{-st}\sinh(2x\operatorname{arccosh}t)\,dt\\&=e^s\int_0^\infty\left(e^{-s\cosh u}\sinh u\right)\sinh2xu\,du\\&=e^s\int_0^\infty\frac{2x}se^{-s\cosh u}\cosh2xu\,du\\&=\frac{2x}se^sK_{2x}(s)\end{align} through integration by parts, we are left with $$\int_0^\infty\frac{\sinh(2x\operatorname{arccosh}(t+1))}{(t+1)^7}\,dt=\frac x{360}\int_0^\infty s^5K_{2x}(s)\,ds=\frac{2x}{45}\Gamma(3-x)\Gamma(3+x)$$ using Ramanujan's master theorem and that $K_{2x}$ is a linear combination of modified Bessel functions of the first kind. The reflection formula finally yields $$h(x)<\frac{8\pi x^2(x^4-5x^2+4)}{45e^{x^2/2}\sin\pi x},$$ so a sufficient condition for $g''(x)>0$ is $$\frac{\sinh x}{\cosh^3x}>\frac{2\pi x^2(x^4-5x^2+4)}{45e^{x^2/2}\sin\pi x}\iff p(x)=\frac{2\pi x(x^4-5x^2+4)e^{x^2}}{45\sin\pi x}<1$$ using $\cosh x\le e^{x^2/2}$ and $\sinh x\ge x$. It suffices to show that $(\log p(x))'>0$ since $p$ is positive and $p(\operatorname{arccosh}\sqrt2)<1$. This is equivalent to $$\frac{2x^6-5x^4-7x^2+4}{x(x^4-5x^2+4)}>\pi\cot\pi x$$ which can be written as $$2x+\frac1{x-2}+\frac1{x-1}+\frac1x+\frac1{x+1}+\frac1{x+2}>\sum_{n\in\Bbb Z}\frac1{x-n}$$ using the Mittag-Leffler expansion of $\cot$, which is true for all $0<x<3$ (more than what we need) since $$\sum_{n=-\infty}^{-3}\frac1{x-n}+\sum_{n=3}^\infty\frac1{x-n}=\sum_{n=3}^\infty\frac{2x}{x^2-n^2}<0.\tag*{$\square$}$$

  • 1
    $\begingroup$ Really nice solution combining a lot of ideas and theorems! (+1) $\endgroup$
    – KStarGamer
    Jan 8, 2022 at 22:06
  • $\begingroup$ Hi again. Thanks for you your answer. A colleague of mine and I are writing a paper and have a generation of this problem appear. I was wondering if you would be willing to participate or at least a look at the problem we are trying to solve? $\endgroup$
    – Boby
    Feb 22, 2022 at 19:24
  • $\begingroup$ @Boby I don't have much time for now but sure, I can look at the context behind this. $\endgroup$ Feb 22, 2022 at 20:59


with $E[]$ the standard normal of the $tanh$. Doing some experiments with the statistically distributed $Z$ can be visualized like this:

Plot of the given function with parameters between -5 and 5 for Z

This shows that the experimental functions with a standard normal distribution parameter $Z$ are restricted in between two limiting functions. They can not be anywhere other than between these two limiting curves. For $x/rightarrow \infty$ all function are divergent to $-\infty$ for negatives and $+\infty$ for positives.

As can be seen from the plot there is another limiting function in the set. For this function, there are three zeros. There is a range for which there are two zeros and around that is valid for the ones lying higher in the graph there is only one zero and for the lower, there is only one zero too.

The rest of the work is discussing the given function as a real values function.

The derivative has two zeros which can be calculated using numerical methods different from zero: $\{-0.5752778985889421`, 0, 0.5752778985889421`\}$. Evaluating these extremes in the given function gives $\{0.0916058, 0, -0.0916058\}$.

So these values for $Z$ are the boundaries for which only one zero remains in the range of $Z$. These functions cross only once the $x$-axis. In between the range with two and three zeros.

At $z=+/-0.46$ or very close are the limits for only one zero:

visual of the zone with more than one zero

Blue is the positive value, orange the negative.

Slightly values in the interval

This shows the range is very narrow in which two zeros occur. This depends on the representation. It appears that almost this limiting values are that where two zeros happen.

This shows the given problem as a contour plot with the regions under interest:

enter image description here

So far the general discussion of the problem.

Mathematica provides a function that might help further: Expectation. But this does at present and for my license not with $tanh$.

This works as I mentioned earlier for sampling. Generate by a stochastic process under the regime of the normal standard the $Z$ and calculate and expectation value:

$12𝐸[tanh(𝑥+𝑍2)]\approx 1/10 (1/2 tanh[1/2 (-1.2738 + x)] + 1/2 tanh[1/2 (-0.951708 + x)] + 1/2 tanh[1/2 (-0.376436 + x)] + 1/2 tanh[1/2 (-0.194455 + x)] + 1/2 tanh[1/2 (-0.0016944 + x)] + 1/2 tanh[1/2 (0.131413 + x)] + 1/2 tanh[1/2 (0.325943 + x)] + 1/2 tanh[1/2 (0.684325 + x)] + 1/2 tanh[1/2 (1.01493 + x)] + 1/2 tanh[1/2 (2.91656 + x)])$

The more $Z$ sample in $E$ the better but the more complex the root term is going to be.

With this in mind I concducted numerical experiments with my system here is the result for an intermediate many sample for $E$ around $50000$:

numerical experiments for the standard normal

The orange curve is the function given without $Z$ and expectation. The broader blue graph is a set of samples for $E[0.5 tanh(\frac{x+Z}{2}]$ between 10000 to 100000 in steps of 10000. The standard normal noise is already reduced and a clear position of the curves is visible.

Around $0$ the effect is not present. For bigger $Z$ the influence becomes a deviation. The noise is to broad to name a tendence. For sure this is lifting the curve for negatives up and down for positives. The zeros move to more negatives and more positives. It is like a $x$-dependent correction that is asymptotically constant. It is like accumulating the noise where the bending changes of the curve. And only where bending changes noise is still present.

This looks pretty much like being still off convergence for larger $x$. The expectation will cancel out in the limit and the function without the expectation value will be the limit taken with a modified factor in the $tanh$. This is close to $0.39$ instead of $0.5$. It is expected that there is an explanation and a calculation method for that statistical damping.

here the fit with 0.3935

This shows for a proof how well the standard normal is reproduced in the sampling:

standard normal

So this statistics standard normal shows little effect as long as it is centered around $Z=0$ and the plain standard normal and little happens. The broad discussion seems overpaced. But the standard normal may be everything. It is normal restricted.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .