skip to content
Aymen Hafeez

Deriving an expression for pi from the error function

/ 1 min read

In my third year at university I was introduced to the error function during a ‘Transport Phenomena’ class. It came up in the context of deriving expressions to describe heat and mass transfer through various geometries. While revising for the exam I derived an expression for π\pi. Starting with the error function:

erf(z)=2π0zex2dx\text{erf}(z)=\frac{2}{\sqrt{\pi}}\int_{0}^{z}e^{-x^2}dx

Recall that the Maclaurin series of the exponential function, exe^x, is given by

ex=n=0xnn!e^x=\sum_{n=0}^{\infty}\frac{x^n}{n!}

And so, we can write the error function as

erf(z)=2π0zn=0(x2)nn!dx=2π0z(1x2+x42!x63!+. . .)dx \begin{aligned} \text{erf}(z)&=\frac{2}{\sqrt{\pi}}\int_{0}^{z}\sum_{n=0}^{\infty}\frac{(-x^2)^n}{n!}dx \\ &=\frac{2}{\sqrt{\pi}}\int_{0}^{z}\left(1-x^2+\frac{x^4}{2!}-\frac{x^6}{3!}+.\ .\ .\right)dx \end{aligned}

Taking the integral and applying the limits of integration gives

erf(z)=2π[xx33+x552!x773!+...]0z=2π(zz33+z552!z773!+...)=2πn=0(1)nz2n+1n!(2n+1) \begin{aligned} \text{erf}(z)&=\frac{2}{\sqrt{\pi}}\left[x-\frac{x^3}{3}+\frac{x^5}{5\cdot2!}-\frac{x^7}{7\cdot3!}+.\: .\: .\right]_0^z \\ &=\frac{2}{\sqrt{\pi}}\left(z-\frac{z^3}{3}+\frac{z^5}{5\cdot2!}-\frac{z^7}{7\cdot3!}+.\: .\: .\right) \\ &=\frac{2}{\sqrt{\pi}}\sum_{n=0}^{\infty}\frac{(-1)^nz^{2n+1}}{n!(2n+1)} \end{aligned}

Next, we consider the value of the error function at various values of zz:

  • erf(1)0.8427008\text{erf}(1)\approx0.8427008
  • erf(2)0.9953223\text{erf}(2)\approx0.9953223
  • erf(3)0.9999779\text{erf}(3)\approx0.9999779
  • erf(4)0.9999999\text{erf}(4)\approx0.9999999

We essentially see that as zz increases erf(z)\text{erf}(z) get closer and closer to 1. And so, we can say that

limzerf(z)=limz2πn=0(1)nz2n+1n!(2n+1)=1π2=limzn=0(1)nz2n+1n!(2n+1)\begin{aligned} \lim_{z\to\infty} \text{erf}(z) &= \lim_{z\to\infty} \frac{2}{\sqrt{\pi}} \sum_{n=0}^{\infty}\frac{(-1)^nz^{2n+1}}{n!(2n+1)} = 1 \\ \frac{\sqrt{\pi}}{2} &= \lim_{z\to\infty}\sum_{n=0}^{\infty}\frac{(-1)^nz^{2n+1}}{n!(2n+1)} \end{aligned}

Plotting the convergence of the expression for z=4z = 4, as well the expression rearranged for π\pi:

Convergence of sqrt(pi)/2 Convergence at z=4