This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Scaled complementary error function





erfcx(x) returns the value of the Scaled Complementary Error Function for each element of x. Use the erfcx function to replace expressions containing exp(x^2)*erfc(x) to avoid underflow or overflow errors.


collapse all

ans = 0.1107

Find the scaled complementary error function of the elements of a vector.

V = [-Inf -1 0 1 10 Inf];
ans = 1×6

       Inf    5.0090    1.0000    0.4276    0.0561         0

Find the scaled complementary error function of the elements of a matrix.

M = [-0.5 15; 3.2 1];
ans = 2×2

    1.9524    0.0375
    0.1687    0.4276

You can use the scaled complementary error function erfcx in place of exp(x^2)*erfc(x) to avoid underflow or overflow errors.

Show how to avoid roundoff errors by calculating exp(35^2)*erfc(35) using erfcx(35). The original calculation returns NaN while erfcx(35) returns the correct result.

x = 35;
ans = NaN
ans = 0.0161

Input Arguments

collapse all

Input, specified as a real number, or a vector, matrix, or multidimensional array of real numbers. x cannot be sparse.

Data Types: single | double

More About

collapse all

Scaled Complementary Error Function

The scaled complementary error function erfcx(x) is defined as


For large X, erfcx(X) is approximately (1π)1x.


  • For expressions of the form exp(-x^2)*erfcx(x), use the complementary error function erfc instead. This substitution maintains accuracy by avoiding roundoff errors for large values of x.

Extended Capabilities

See Also

| | |

Introduced before R2006a

Was this topic helpful?