Gaussian Integral Error Function Approximation

integrationnumerical methods

I was just wondering is there a way to approximate the error function arising from the indefinite Gaussian Integral:

$$\int e^{-x^2}dx={\frac{\sqrt\pi}{2}}\text{erf}(x)$$

For instance, like I get the proofs to solving this integral with limits from $[0.\infty)$, however I just want to numerically approximate this integral when our limits are any arbitrary $[a,b]$ for $a$ and $b$ are integers. How would I approximate numerically for this integral when the limits are say $[1, 2]$? What value to we plug in to the error function? Would it be like this?
$$\int_1^2 e^{-x^2}dx=\frac{\sqrt{\pi}}{2}\bigg(\text{erf}(2)-\text{erf}(1)\bigg)$$

All in all my question is basically this:

Question 1: How do we numerically approximate the error function?

Question 2: How do we find the definite integral of the Gaussian integral?

I would appreciate the help.

EDIT: From related posts I have seen, I see that the error function can be expressed as this power series:

$$\frac{\sqrt\pi}{2}\text{erf}(z)=\sum_{n=0}^\infty\frac{(-1)^nt^{2n+1}}{(2n+1)n!}$$

through integration term by term, but I am just not sure how to approximate this function between arbitrary integer limits $[a,b]$.

Best Answer

Beside series expansions, there are some approximations of the function.

For example, one I proposed a while ago (based on purely mathematical considerations) is $$\text{erf}(x)\approx \sqrt{1-\exp\Big(-\frac 4 {\pi}\,\frac{1+\alpha\, x^2}{1+\beta \,x^2}\,x^2 \Big)}$$ where $$\alpha=\frac{10-\pi ^2}{5 (\pi -3) \pi } \qquad \text{and} \qquad \beta=\frac{120-60 \pi +7 \pi ^2}{15 (\pi -3) \pi }$$

For $x=1$ this would give $0.842654$ while the "exact" value would be $0.842701$.

For $x=2$ this would give $0.995165$ while the "exact" value would be $0.995322$.

Then $\text{erf}(2)-\text{erf}(1)\approx 0.152511$ while the "exact" value would be $0.152621$.

Edit

I tried to improve the approximation using $$\text{erf}(x)\approx \sqrt{1-\exp\Big(-\frac 4 {\pi}\,\frac{1+\alpha\, x^2+\gamma\,x^4}{1+\beta \,x^2+\delta\,x^4}\,x^2 \Big)}$$ but the formulae become quite messy. However, after going the calculations, what can be observed is that $$\frac \gamma \alpha \approx 0.10454 \qquad \text{and} \qquad \frac \delta \beta \approx 0.09735$$ So, to get simpler formulae, I forced $\gamma=\frac \alpha {10}$ and $\delta=\frac \beta {10}$. Then, the results are $$\alpha=\frac{20-3 \pi -\pi ^2}{10 (\pi -3) \pi } \qquad \text{and} \qquad \beta=\frac{240-129 \pi +17 \pi ^2}{30 (\pi -3) \pi }$$

For the worked values, the results are now $0.842704$ and $0.995332$ which are much better. For the difference, $0.152629$.

Related Question