Question: Is there a way to easily compute [the erf function](https://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution) (or the cumulative distribution function of the normal law) in LaTeX?

Currently, I use `pgf` to make computation, but I did not find a way to compute erf using `pgf`.

I would be happy to use any package that is available to compute erf, or any custom solution to compute that function.

Answer: 
A little late, but here's a solution using the `sagetex` package, which gives you the power of the (free) computer algebra system known as [Sage](http://sagemath.org/index.html). Sage has an error function command which, [according to the documentation](http://www.sagemath.org/doc/reference/functions/sage/functions/special.html) is 1-erf. This code

```
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\pagestyle{empty}
Sage has an error function command that's equal to $1-\mbox{erf}$. Here's     $\sage{error_fcn(2)}$ and 
$\sage{1-error_fcn(2)}$. There is an erf command but it doesn't seem to be   working properly 
in my older version of Sage. The formatting in Sage goes like this:   $\sage{n(error_fcn(2),digits=6)}$ 
and $\sage{n((1-error_fcn(2)),digits=11)}$. 
\begin{sagesilent}
g(x)=erf(x)
q=plot(g,x,-3,3,color='red')
\end{sagesilent}

This is a plot of $\mbox{erf}(x)$.
\begin{center}
\sageplot[scale=.35]{q}
\end{center}
\end{document}

```

creates this output:
![enter image description here](https://i.stack.imgur.com/anw7Q.jpg)
You can also use the FFI in LuaJITTeX (and LuaTeX ≥ 1.0.3) to access the `erf` function in `libm` directly. The performance and accuracy are simply amazing!

```
\documentclass{article}

\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\directlua{
local ffi = require("ffi")
ffi.cdef[[
double erf(double arg);
]]
}

\pgfmathdeclarefunction{erf}{1}{%
  \edef\pgfmathresult{%
    \directlua{tex.print(ffi.C.erf(\pgfmathfloatvalueof{#1}))}%
  }%
}

\DeclareMathOperator\erf{erf}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[
    no marks, samples=101,
    xlabel={$x$},
    ylabel={$\erf(x)$},
    ]
    \addplot {erf(x)};
  \end{axis}
\end{tikzpicture}

\end{document}

```

[![enter image description here](https://i.stack.imgur.com/GLYdM.png)](https://i.stack.imgur.com/GLYdM.png)