C++ Standard Library C++ STL Library

C++ <cmath> - erfc() Function



The C++ <cmath> erfc() function returns the complementary error function of the argument. The complementary error function of x is defined as:

erfc function

Where, erf(x) is an error function. Error functions usually occur in probability, statistics and partial differential equation describing diffusion.

Complementary Error Function

Syntax

double erfc (double x);
float erfc (float x);
long double erfc (long double x);
double erfc (T x);                             

Parameters

x Specify the value.

Return Value

Returns the complementary error function of the argument.

Example:

In the example below, erfc() function returns the complementary error function of the given value.

#include <iostream>
#include <cmath>
using namespace std;
 
int main (){
  cout<<erfc(0)<<"\n";
  cout<<erfc(1)<<"\n";
  cout<<erfc(2)<<"\n";
  cout<<erfc(-1)<<"\n";
  cout<<erfc(-2)<<"\n";    
  return 0;
}

The output of the above code will be:

1
0.157299
0.00467773
1.8427
1.99532

❮ C++ <cmath> Library

5