# Why the error function is so similar to the hyperbolic tangent?

If you plot the functions $$\text{erf}(x)=\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}\mathrm{d}t$$ and $$\frac{2}{\sqrt{\pi}}\tanh(x)=\frac{2}{\sqrt{\pi}}\frac{e^x-e^{-x}}{e^x+e^{-x}},$$ they look very similar and their numeric values are almost the same and a big part of their domain.

Is there a deep reason for this?

• I like this question. I'm not sure what answer you are expecting though. Try Taylor series around $x=0$, since the functions are close in value only for small $x$ Aug 15, 2016 at 3:07
• – dian
Aug 15, 2016 at 3:09
• At $x=0$ they have the same function value, as well as the same first, second, third, and fourth derivatives. So the @YuriyS explanation works. Aug 15, 2016 at 3:27
• math.stackexchange.com/a/321592/333612 Aug 15, 2016 at 3:41
• Checking the plots on Wolfram|Alpha shows that the approximation is only any good for something like $\lvert x \rvert < 0.5.$ Beyond that, the approximation gets bad fast. This leads me to believe the explanation by @YuriyS based on Taylor series. Compare this .gif. Aug 15, 2016 at 3:54

Concerning Taylor series, we have $$\text{erf}(x)=\frac{2 x}{\sqrt{\pi }}-\frac{2 x^3}{3 \sqrt{\pi }}+\frac{x^5}{5 \sqrt{\pi }}-\frac{x^7}{21 \sqrt{\pi }}+\frac{x^9}{108 \sqrt{\pi }}+O\left(x^{10}\right)$$
$$\frac{2}{\sqrt{\pi}}\tanh(x)=\frac{2 x}{\sqrt{\pi }}-\frac{2 x^3}{3 \sqrt{\pi }}+\frac{4 x^5}{15 \sqrt{\pi }}-\frac{34 x^7}{315 \sqrt{\pi }}+\frac{124 x^9}{2835 \sqrt{\pi }}+O\left(x^{10}\right)$$ $$\text{erf}(x)-\frac{2}{\sqrt{\pi}}\tanh(x)=-\frac{x^5}{15 \sqrt{\pi }}+\frac{19 x^7}{315 \sqrt{\pi }}-\frac{391 x^9}{11340 \sqrt{\pi }}+O\left(x^{10}\right)$$ On the other hand, $$\lim_{x\to\infty}\text{erf}(x)=1$$ while $$\lim_{x\to\infty}\frac{2}{\sqrt{\pi}}\tanh(x)=\frac{2}{\sqrt{\pi }}$$ On another hand $$2\frac{ \left(\frac{2 \tanh (x)}{\sqrt{\pi }}-\text{erf}(x)\right)}{\text{erf}(x)+\frac{2 \tanh (x)}{\sqrt{\pi }}}<0.01$$ if $x<0.809$.