Calculate $$ \int\frac{dx}{1+\mathrm{erf}(x)}\,\mathrm{d}x, $$ where $\mathrm{erf}$ is the error function. It is known that $\int \mathrm{erf}(x)\,\mathrm{d}x=x\,\mathrm{erf}(x)+\frac{e^{-x^2}}{\sqrt{\pi }}$ and $\frac{d}{dx}\mathrm{erf}(x)=\frac{2 e^{-x^2}}{\sqrt{\pi }}.$
How to integrate the following function
248 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 2 best solutions below
On
I do not think that $$I=\int \frac{dx}{1+\text{erf}(x)}$$ could be expressed in terms of any function (even special functions) and more than likely, numerical integration would be required.
Computing $$F(t)=\int_0^t \frac{dx}{1+\text{erf}(x)}$$ reveals a trend very close to linear as shown in the table below $$\left( \begin{array}{cc} t & F(t) \\ 1 & 0.69402 \\ 2 & 1.20690 \\ 3 & 1.70714 \\ 4 & 2.20715 \\ 5 & 2.70715 \\ 6 & 3.20715 \\ 7 & 3.70715 \\ 8 & 4.20715 \\ 9 & 4.70715 \\ 10 & 5.20715 \end{array} \right)$$ where you see that to a $\Delta t=1$ corresponds a $\Delta F(t)=\frac12$.
If $t$ as to be small (say $0\leq t \leq 1$) you could use Taylor series built, for the integrand, around $x=0$ $$\frac{1}{1+\text{erf}(x)}=1-\frac{2 x}{\sqrt{\pi }}+\frac{4 x^2}{\pi }+\frac{2 (\pi -12) x^3}{3 \pi ^{3/2}}-\frac{8 (\pi -6) x^4}{3 \pi ^2}+\frac{\left(-160+40 \pi -\pi ^2\right) x^5}{5 \pi ^{5/2}}+\frac{8 \left(360-120 \pi +7 \pi ^2\right) x^6}{45 \pi ^3}+\frac{\left(-13440+5600 \pi -532 \pi ^2+5 \pi ^3\right) x^7}{105 \pi ^{7/2}}+O\left(x^8\right)$$ which will give, as an approximation, $$F(t)=t-\frac{t^2}{\sqrt{\pi }}+\frac{4 t^3}{3 \pi }+\frac{(\pi -12) t^4}{6 \pi ^{3/2}}-\frac{8 (\pi -6) t^5}{15 \pi ^2}+\frac{\left(-160+40 \pi -\pi ^2\right) t^6}{30 \pi ^{5/2}}+\frac{8 \left(360-120 \pi +7 \pi ^2\right) t^7}{315 \pi ^3}+\frac{\left(-13440+5600 \pi -532 \pi ^2+5 \pi ^3\right) t^8}{840 \pi ^{7/2}}+O\left(t^9\right)$$
$$\left( \begin{array}{ccc} t & \text{exact} & \text{approximation} \\ 0.0 & 0.000000 & 0.000000 \\ 0.1 & 0.094758 & 0.094758 \\ 0.2 & 0.180448 & 0.180448 \\ 0.3 & 0.258857 & 0.258856 \\ 0.4 & 0.331400 & 0.331398 \\ 0.5 & 0.399212 & 0.399197 \\ 0.6 & 0.463209 & 0.463135 \\ 0.7 & 0.524135 & 0.523848 \\ 0.8 & 0.582595 & 0.581672 \\ 0.9 & 0.639088 & 0.636506 \\ 1.0 & 0.694020 & 0.687561 \end{array} \right)$$
If you need to resuse mutliple times, what I would suggest is to generate a table of $F(t)$ for the range of interest, build a cubic spline (or nay interpolating function).
Edit
As shown above, using Taylor series, even for the range $0\leq t \leq 1$, the results are not very good in spite of the large number of terms used. I think that we can do better consider instead a very limited Padé approximant which is $$\frac{1}{1+\text{erf}(x)}=\frac{\frac{x^2}{3}+1}{\frac{x^2}{3}+\frac{2 x}{\sqrt{\pi }}+1}$$ which would lead to $$F(t)=x+6 \sqrt{\frac{3}{(\pi -3) \pi }} \tan ^{-1}\left(\frac{\sqrt{\pi } x+3}{\sqrt{3 (\pi -3)}}\right)-\frac{3 \log \left(\sqrt{\pi } \left(x^2+3\right)+6 x\right)}{\sqrt{\pi }}-C$$ where $$C=6 \sqrt{\frac{3}{(\pi -3) \pi }} \tan ^{-1}\left(\sqrt{\frac{3}{\pi -3}}\right)-\frac{3 \log \left(3 \sqrt{\pi }\right)}{\sqrt{\pi }}$$
This would give $$\left( \begin{array}{cc} t & \text{exact} & \text{Padé} \\ 0.0 & 0.000000 & 0.000000 \\ 0.1 & 0.094758 & 0.094758 \\ 0.2 & 0.180448 & 0.180448 \\ 0.3 & 0.258857 & 0.258856 \\ 0.4 & 0.331400 & 0.331396 \\ 0.5 & 0.399212 & 0.399200 \\ 0.6 & 0.463209 & 0.463179 \\ 0.7 & 0.524135 & 0.524071 \\ 0.8 & 0.582595 & 0.582481 \\ 0.9 & 0.639088 & 0.638900 \\ 1.0 & 0.694020 & 0.693737 \end{array} \right)$$ which looks to be much better.
Hint:
Let $u=\mathrm{erf}(x)$ ,
Then $x=\mathrm{erf}^{-1}(u)$
$dx=\dfrac{\sqrt\pi}{2}e^{(\mathrm{erf}^{-1}(u))^2}~du$ (according to http://mathworld.wolfram.com/InverseErf.html)
$\therefore\int\dfrac{dx}{1+\mathrm{erf}(x)}=\dfrac{\sqrt\pi}{2}\int\dfrac{e^{(\mathrm{erf}^{-1}(u))^2}}{u+1}~du$