PyTorch .erfc()

Anonymous contributor's avatar
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$$

  • 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

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 tensor
x = 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

Contribute to 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