# Python math.erfc() Method

The math.erfc() method is used to return complementary error function of a given number.

## Syntax

``````import math
math.erfc(num)``````

## Parameter

num(required): A numeric value, which can range between – inf and + inf.

## Return Value

Returns a float value between 0 and 2, representing the complementary error function of num

It throws TypeError if the num is not a number.

## Example 1: How to Use math.erfc() Method

``````import math

print(math.erfc(1))
print(math.erfc(5))
print(math.erfc(-5))
print(math.erfc(2.3))``````

Output

``````0.15729920705028516
1.537459794428035e-12
1.9999999999984626
0.0011431765973566523``````

## Example 2: Passing a non-numeric argument

``````import math

print(math.erfc('5'))``````

Output

``TypeError: must be real number, not str ``

## Example 3: Plotting

``````import math
import matplotlib.pyplot as plt
import numpy as np

# Create an array of x values from -3 to 3
x = np.linspace(-3, 3, 400)

# Compute the complementary error function of these values
y = [math.erfc(value) for value in x]

# Create a new figure
plt.figure()

# Plot x against the complementary error function of x
plt.plot(x, y)

# Set the title and labels for the plot
plt.title('Complementary Error Function')
plt.xlabel('x')
plt.ylabel('erfc(x)')

# Display the plot
plt.show()``````

Output

That’s it.

This site uses Akismet to reduce spam. Learn how your comment data is processed.