6

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?

Gabriel
  • 4,761
  • 5
    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$ – Yuriy S Aug 15 '16 at 03:07
  • 2
    Check this http://math.stackexchange.com/questions/321569/approximating-the-error-function-erf-by-analytical-functions –  Aug 15 '16 at 03: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. – Michael Aug 15 '16 at 03:27
  • 1
    http://math.stackexchange.com/a/321592/333612 – Biggs Aug 15 '16 at 03:41
  • 1
    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. – Will R Aug 15 '16 at 03:54
  • Being a nice monotonic function that goes through $(0,0)$ and having limits of $\pm 1$ at $\pm \infty$ is rather constraining. Adding in a slope of $1$ at $(0,0)$ is even more constraining. The eye is a rather forgiving device for finding similarity. – Ross Millikan Oct 28 '23 at 03:13

1 Answers1

8

Many things have already to told in comments.

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$.

So, a already said in comments, the functions are "close" to eachother over a quite limited range.