Skip to main content
`Ctrl`+`K`

# scipy.special.erf

scipy.special.erf(z, out=None) = <ufunc 'erf'>

  Error function of real or complex argument.

  \[\operatorname{erf}(z) = \frac{2}{\sqrt{\pi}} \int_0^z e^{-t^2} dt\]
  Parameters:
    z ndarray

      Input array.

    out ndarray, optional

      Optional output array for the function values.

  Returns:
    res scalar or ndarray

      The values of the error function at the given points z.

  See also

  `erfc`, `erfcx`, `erfi`, `erfinv`, `erfcinv`, `wofz`

  Notes

  The cumulative distribution function (CDF) of the standard normal distribution can be expressed in terms of the error function as

  \[\Phi(z) = \frac{1}{2} \left[1 + \operatorname{erf} \left(\frac{z}{\sqrt{2}}\right)\right]\]

  Array API Standard Support

  `erf` has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable `SCIPY_ARRAY_API=1` and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

  Library | CPU | GPU
  --- | --- | ---
  NumPy | ✅ | n/a
  CuPy | n/a | ✅
  PyTorch | ✅ | ✅
  JAX | ✅ | ✅
  Dask | ✅ | n/a

  See Support for the array API standard for more information.

  References

  [1]

  https://en.wikipedia.org/wiki/Error_function

  [2]

  Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.

  [3]

  Steven G. Johnson, Faddeeva W function implementation. http://ab-initio.mit.edu/Faddeeva

  Examples

      >>> import numpy as np
      >>> from scipy import special
      >>> import matplotlib.pyplot as plt
      >>> z = np.linspace(-3, 3)
      >>> plt.plot(z, special.erf(z))
      >>> plt.xlabel('$z$')
      >>> plt.ylabel('$erf(z)$')
      >>> plt.show()