erfc() Function

The erfc() function computes the complementary error function, which is defined as the complement of the error function. Essentially, it gives the value of 1 minus the error function for a given input. This function is useful in probability, statistics, and partial differential equations where error functions are commonly encountered.


Syntax of erfc()

</>
Copy
double erfc(double x);
float  erfcf(float x);
long double erfcl(long double x);

Parameters

ParameterDescription
xInput value for which the complementary error function is computed.

Additional Information

The complementary error function is calculated as 1 minus the error function. It is important to note that if the input is too large, an underflow range error may occur. This function is particularly useful in fields that require the evaluation of probabilities and in solving differential equations.


Examples for erfc()

Example 1: Computing Complementary Error Function for a Positive Input

This example demonstrates how to compute the complementary error function for a positive input value using the erfc() function.

Program

</>
Copy
#include <stdio.h>
#include <math.h>

int main() {
    double value = 1.0;
    double result = erfc(value);
    
    printf("Complementary error function for %.2f is %.5f\n", value, result);
    return 0;
}

Explanation:

  1. The program initializes a variable with a positive value (1.0 in this case).
  2. The erfc() function is called with the value to compute its complementary error function.
  3. The result is then printed with a formatted output.

Program Output:

Complementary error function for 1.00 is 0.15730

Example 2: Handling a Negative Input with erfc()

This example demonstrates the computation of the complementary error function for a negative input value using the erfc() function.

Program

</>
Copy
#include <stdio.h>
#include <math.h>

int main() {
    double value = -1.0;
    double result = erfc(value);
    
    printf("Complementary error function for %.2f is %.5f\n", value, result);
    return 0;
}

Explanation:

  1. The program sets a negative input value (-1.0).
  2. The erfc() function computes the complementary error function for the negative value.
  3. The result is printed to the console.

Program Output:

Complementary error function for -1.00 is 1.84270