In C++, the erfc() function is defined in the <cmath> or <math.h> header file and is used to calculate the complementary error function value of a given number. The complementary error function is mathematically defined as:
erfc(x)=1−erf(x)\operatorname{erfc}(x)=1-\operatorname{erf}(x)erfc(x)=1−erf(x)
The erfc() function supports float, double, long double, and integer values.
It has the following syntax.
x: It is a floating point value.
It returns the complementary error function value of x.
| Parameter | Return value |
|---|---|
| x=+∞ | +0 |
| x= -∞ | 2 |
| x=nan | nan |
Here, we are going to discuss several examples to demonstrate the erfc() Function.
This example demonstrates how the erfc() function behaves when the input value is positive infinity.
Output:
Value of x is : inf erfc(x) : 0
Explanation:
In the above example, the value of x is positive infinite. Therefore, the function erfc() returns 0 value.
This example demonstrates how the erfc() function behaves when the input value is negative infinity.
Output:
Value of x is : -inf erfc(x) : 2
Explanation:
In the above example, the value of x is negative infinite. Therefore, the function erfc() returns 2.
This example demonstrates how the erfc() function behaves when the input value is NaN (Not a Number).
Output:
Value of x is : -nan erfc(x) : -nan
Explanation:
In the above example, the value of x is nan. Therefore, the function erfc() returns nan.
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India