# Integral of erf(x)

Here I talked about special functions, and at the end of the post I said I would explain how to integrate these special functions. So here I am, showing you how to integrate the error function erf(x). If you gave it a try, let me know in the comments if you used this approach!

$\int&space;\text{erf}(x)$

The only technique that is going to work is integration by parts. We know that erf(x) is equal to the integral of e^(-x^2), so the derivative of erf(x) is e^(-x^2).

$u=\text{erf}(x)\;&space;\;&space;\;&space;\;&space;\;&space;dv=dx$ $du=e^{-x^2}dx\;&space;\;&space;\;&space;\;&space;\;&space;v=x$ $x\,&space;\text{erf}(x)-\int&space;xe^{-x^2}dx$

We can solve this integral using u-substitution.

$u=-x^2\;&space;\;&space;\;&space;\;&space;\;&space;du=-2x\,&space;dx\rightarrow&space;dx=-\frac{1}{2x}du$ $\int&space;-xe^u\frac{1}{2x}du=-\frac{1}{2}\int&space;e^udu=-\frac{1}{2}e^u\overset{x}{\rightarrow}-\frac{1}{2}e^{-x^2}$

Overall:

$\int&space;\text{erf}(x)dx=x\,\text{erf}(x)+\frac{1}{2}e^{-x^2}+C$

And that’s it!