The error function

import matplotlib.pyplot as plt from numpy import linspace import scipy.special as sp from sympy import Symbol, pi, exp, integrate, N # The N function executes and simplifies def erf(x): t = Symbol('t') return N((2/(pi**0.5))*integrate(exp(-t**2), (t, 0, x))) xs = linspace(-5,5,40) ys = [erf(x) for x in xs] sc_ys = [sp.erf(x) for x in xs] plt.plot(xs, ys, 'k-', label = 'erf') plt.plot(xs, sc_ys, 'r.', label='Scipy erf') plt.ylim(-1.2,1.2) plt.legend(loc='best', frameon=False) plt.tight_layout() plt.show() Plot of the erf function by two methods