Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

erfc

Complementary error function

Syntax

Description

example

erfc(x) returns the Complementary Error Function evaluated for each element of x. Use the erfc function to replace 1 - erf(x) for greater accuracy when erf(x) is close to 1.

Examples

collapse all

Find Complementary Error Function

Find the complementary error function of a value.

erfc(0.35)
ans =

    0.6206

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

V = [-0.5 0 1 0.72];
erfc(V)
ans =

    1.5205    1.0000    0.1573    0.3086

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

M = [0.29 -0.11; 3.1 -2.9];
erfc(M)
ans =

    0.6817    1.1236
    0.0000    2.0000

Find Bit Error Rate of Binary Phase-Shift Keying

The bit error rate (BER) of binary phase-shift keying (BPSK), assuming additive white gaussian noise (AWGN), is

$$ P_b = \frac{1}{2} \rm erfc\Biggl(\sqrt{\frac{E_b}{N_0}}\Biggr).$$

Plot the BER for BPSK for values of $E_b/N_0$ from 0dB to 10dB.

EbN0_dB = 0:0.1:10;
EbN0 = 10.^(EbN0_dB/10);
BER = 1/2.*erfc(sqrt(EbN0));
semilogy(EbN0_dB,BER)
grid on
ylabel('BER')
xlabel('E_b/N_0 (dB)')
title('Bit Error Rate for Binary Phase-Shift Keying')

Avoid Roundoff Errors Using Complementary Error Function

You can use the complementary error function erfc in place of 1 - erf(x) to avoid roundoff errors when erf(x) is close to 1.

Show how to avoid roundoff errors by calculating 1 - erf(10) using erfc(10). The original calculation returns 0 while erfc(10) returns the correct result.

1 - erf(10)
erfc(10)
ans =

     0


ans =

   2.0885e-45

Input Arguments

collapse all

x — Inputreal 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

collapse all

Complementary Error Function

The complementary error function of x is defined as

erfc(x)=2πxet2dt=1erf(x).

It is related to the error function as

erfc(x)=1erf(x).

Tips

  • You can also find the standard normal probability distribution using the Statistics and Machine Learning Toolbox™ function normcdf. The relationship between the error function erfc and normcdf is

    normcdf(x)=(12)×erfc(x2)

  • For expressions of the form 1 - erfc(x), use the error function erf instead. This substitution maintains accuracy. When erfc(x) is close to 1, then 1 - erfc(x) is a small number and might be rounded down to 0. Instead, replace 1 - erfc(x) with erf(x).

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

See Also

| | |

Introduced before R2006a

Was this topic helpful?