erf
Error function
📝Syntax
R = erf(X)
📥Input Arguments
Parameter Description
X a real single or real double scalar, vector, matrix, or multidimensional array. Sparse and complex inputs are not supported.
📤Output Arguments
Parameter Description
R error function values, returned with the same size and floating-point class as X.
📄Description

erf computes the error function element by element.

The error function is defined as:

$$erf(x) = \frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}\,dt$$

It is related to the complementary error function by:

$$erfc(x) = 1 - erf(x)$$

For better numerical accuracy when the result is close to zero, use erfc instead of evaluating 1 - erf(x).

💡Examples
Find the error function of a scalar.
R = erf(0.76)
Find the error function of the elements of a vector.
V = [-0.5 0 1 0.72];
R = erf(V)
Find the error function of the elements of a matrix.
M = [0.29 -0.11; 3.1 -2.9];
R = erf(M)
Compute the cumulative distribution function of the standard normal distribution.
x = -3:0.1:3;
y = 0.5 * (1 + erf(x / sqrt(2)));
🔗See Also
erfcerfinverfcinverfcx
🕔Version History
Version Description
1.17.0 initial version
Edit this page on GitHub