Documentation

erfcx

Scaled complementary error function

Syntax

erfcx(x)

Description

example

erfcx(x)returns the value of theScaled Complementary Error Functionfor each element ofx. Use theerfcxfunction to replace expressions containingexp(x^2)*erfc(x)to avoid underflow or overflow errors.

Examples

collapse all

erfcx(5)
ans = 0.1107

找到了误差函数的互补e elements of a vector.

V = [-Inf -1 0 1 10 Inf]; erfcx(V)
ans =Inf 5.0090 1.0000 0.4276 0.0561 0

找到了误差函数的互补e elements of a matrix.

M = [-0.5 15; 3.2 1]; erfcx(M)
ans =1.9524 0.0375 0.1687 0.4276

You can use the scaled complementary error functionerfcxin place ofexp(x^2)*erfc(x)to avoid underflow or overflow errors.

Show how to avoid roundoff errors by calculatingexp(35^2)*erfc(35)usingerfcx(35). The original calculation returnsNaNwhileerfcx(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.xcannot be sparse.

Data Types:single|double

More About

collapse all

Scaled Complementary Error Function

The scaled complementary error functionerfcx(x)is defined as

erfcx ( x ) = e x 2 erfc ( x ) .

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

Tips

  • For expressions of the formexp(-x^2)*erfcx(x), use the complementary error functionerfcinstead. This substitution maintains accuracy by avoiding roundoff errors for large values ofx.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

|||

Introduced before R2006a

Was this topic helpful?