PyTorch .erfc()
Anonymous contributor
Published Aug 8, 2025
Contribute to Docs
In PyTorch, the .erfc() function returns the complementary error function of of each element in the input tensor. The complementary error function is written as:
$$erfc(x)= 1 - \frac{2}{\sqrt{\pi}}\int_0^1 e^{-t^2} dt$$
Syntax
torch.erfc(input, *, out=None) → Tensor
Or,
torch.special.erfc(input, *, out=None) → Tensor
Parameters:
input: The input tensor.out(Optional): A tensor to store the output. If provided, the result is written to this tensor.
Return value:
It returns a new tensor of the same shape as the input, containing the computed complementary error function values for each corresponding element.
Example
In this example, we compute the complementary error function values of each tensor using .erfc():
import torch# Define a tensorx = torch.tensor([0, -1., 10.])result = torch.erfc(x)print(result)
The output of this code is:
tensor([1.0000e+00, 1.8427e+00, 1.4013e-45])
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn PyTorch on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn how to use PyTorch to build, train, and test artificial neural networks in this course.
- Intermediate.3 hours