erfcx
Scaled complementary error function
Syntax
Description
erfcx(
returns the
value of the Scaled Complementary Error Function for each element of x
)x
.
Use the erfcx
function to replace expressions
containing exp(x^2)*erfc(x)
to avoid underflow
or overflow errors.
Examples
Find Scaled Complementary Error Function
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
Avoid Round-off Errors Using Scaled Complementary Error Function
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 round-off 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
x
— Input
real number | vector of real numbers | matrix of real numbers | multidimensional array of real numbers
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
Scaled Complementary Error Function
The scaled complementary error function erfcx(x)
is
defined as
For large X
, erfcx(X)
is
approximately
Tips
For expressions of the form
exp(-x^2)*erfcx(x)
, use the complementary error functionerfc
instead. This substitution maintains accuracy by avoiding roundoff errors for large values ofx
.
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
The
erfcx
function fully supports tall arrays. For more information,
see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Strict single-precision calculations are not supported. In the generated code, single-precision inputs produce single-precision outputs. However, variables inside the function might be double-precision.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The erfcx
function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray
(Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)