# Proving approximation of $\text{erf}$ with Taylor expansion

I am asked to show that

$$\text{erf}(x) \approx 1 - \frac{1}{\sqrt{\pi}}\frac{1}{x}e^{-x^2}$$

in a computational project. Numerically it is really easy to show that this approximation makes sense. I want, however, to look for the process that allowed someone to come up with this approximation.

For that matter, I assumed maybe one could do something like a Taylor expansion "around infinity".

I typed

Series[Erf[x], {x, Infinity, 1}]

in mathematica and it gave me this exact approximation. I browsed online for how to "expand a function around $$\infty$$" and assuming everything works (i.e. without worrying about the details that let me write a given expression and whatnot)

I defined $$f(x) = \text{erf}\left(\frac{1}{x}\right) = \frac{2}{\sqrt{\pi}}\int_0^{\frac{1}{x}} e^{-\xi^2}d\xi$$

and then decided to expand $$f$$ around $$\epsilon$$ where we would have

$$f(\epsilon) \approx f(x) + (\epsilon - x)f'(x)$$

and then I computed $$f'(x)$$:

$$f'(x) = \frac{2}{\sqrt{\pi}} \left(\int_0^{\frac{1}{x}} e^{-\xi^2}d\xi \right)' = \frac{2}{\sqrt{\pi}}\left(\frac{1}{x} \right)' e^{-\frac{1}{x^2}} = -\frac{2}{\sqrt{\pi}}\frac{1}{x^2}e^{-\frac{1}{x^2}}$$

plugging that in the first expression and letting $$\epsilon \to 0$$ gives

$$1 \approx \text{erf}\left(\frac{1}{x}\right) + \frac{2}{\sqrt{\pi}}\frac{1}{x}e^{-\frac{1}{x^2}}$$

then writing $$y = 1/x$$ gives $$\text{erf}(y) \approx 1 - \frac{2}{\sqrt{\pi}}ye^{-y^2}$$ which is close, but not quite what I am looking for... Where did I make a mistake??

The reason for expecting such approximation is pretty simple: the derivative of $$\text{erfc}(x)=\frac{2}{\sqrt{\pi}}\int_{x}^{+\infty}e^{-t^2}\,dt$$ is $$-\frac{2}{\sqrt{\pi}}e^{-x^2}$$, hence by De l'Hopital rule

$$\lim_{x\to +\infty}\frac{\text{erfc}(x)}{\frac{1}{x\sqrt{\pi}}e^{-x^2}}=\lim_{x\to +\infty}\frac{-\frac{2}{\sqrt{\pi}}e^{-x^2}}{-\frac{2}{\sqrt{\pi}}e^{-x^2}+\frac{1}{x^2\sqrt{\pi}}e^{-x^2}}=\lim_{x\to +\infty}\frac{1}{1-\frac{\sqrt{\pi}}{2x^2}}=1$$ and $$\text{erfc}(x)\sim \frac{1}{x\sqrt{\pi}}e^{-x^2}$$ as $$x\to \infty$$. Actually we have

$$\text{erfc}(x)=\frac{e^{-x^2}}{\sqrt{\pi}}\cdot\frac{1}{x+\frac{1/2}{x+\frac{1}{x+\frac{3/2}{x+\ldots}}}}$$ for any $$x\gg 0$$.

• I do enjoy this nice trick. As for the continued fraction, from the point of view of my question, it is "useless" as I would have to come up with it. Even so, is there any mistake in my calculations? – RGS Oct 11 '18 at 8:13

We can write:

$$\operatorname{erfc}(x) = \frac{2}{\sqrt{\pi}}\int_x^\infty\exp\left(-t^2\right)dt = \frac{1}{\sqrt{\pi}}\int_{x^2}^\infty\frac{\exp\left(-u\right)}{\sqrt{u}}du$$

Partial integration yields:

$$\operatorname{erfc}(x) = \frac{1}{\sqrt{\pi}}\frac{\exp\left(-x^2\right)}{x}-\frac{1}{2\sqrt{\pi}}\int_{x^2}^\infty\frac{\exp\left(-u\right)}{u^{3/2}}du$$

And we can go on to repeatedly perform partial integrations to get to an asymptotic series:

$$\operatorname{erfc}(x) = \frac{\exp\left(-x^2\right)}{\sqrt{\pi}}\left(\frac{1}{x}-\frac{1}{2 x^3}+\frac{3}{4 x^5}-\frac{15}{8 x^7}+\cdots\right)$$

• I enjoyed your answer, even though I have no clue as to why on Earth one would think of that change of variables prior to partial integration... Can you add anything to that? Even so, did you find anything wrong with my calculations? – RGS Oct 11 '18 at 8:13

From the initial formula

$$(\text{erf}(x))'\approx\frac2{\sqrt\pi}e^{-x^2}+\frac1{\sqrt\pi x^2}e^{-x^2}.$$

The second term is tiny in front of the first.

• I don't understand what I am supposed to get from this answer, sorry... – RGS Oct 10 '18 at 17:00

An alternative approach: You might find this inequality handy: $$\frac{x^{2}}{1+x^{2}}\frac{1}{x}\exp \left( \frac{-x^{2}}{2}\right)\leqslant \int_{x}^{\infty}e^{-t^{2}/2}dt\leqslant \frac{1}{x}\exp\left(\frac{-x^{2}}{2}\right)$$ To apply this to your exercise you'll need to get rid of that division by 2.