Main Content

erfcx

Scaled complementary error function

Syntax

Description

example

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.

Examples

collapse all

erfcx(5)
ans = 0.1107

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

V = [-Inf -1 0 1 10 Inf];
erfcx(V)
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];
erfcx(M)
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;
exp(x^2)*erfc(x)
ans = NaN
erfcx(x)
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

erfcx(x)=ex2erfc(x).

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

Tips

  • 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

Version History

Introduced before R2006a

See Also

| | |