Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions content/pytorch/concepts/tensor-operations/terms/erfc/erfc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
Title: '.erfc()'
Description: 'Computes the complementary error function of input.'
Subjects:
- 'Computer Science'
- 'Machine Learning'
Tags:
- 'Functions'
- 'Machine Learning'
- 'Python'
- 'Tensor'
CatalogContent:
- 'intro-to-py-torch-and-neural-networks'
- 'paths/computer-science'
---

In PyTorch, the **`torch.erfc()`** function returns the complementary error function of of each element in the input [tensor](https://www.codecademy.com/resources/docs/pytorch/tensors). The complementary error function is defined as follows:

$$erfc(x)= 1 - \frac{2}{\sqrt{\pi}}\int_0^1 e^{-t^2} dt$$

## Syntax

```pseudo
torch.erfc(input, *, out=None) → Tensor
```

Or,

```pseudo
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 `torch.erfc()`:

```py
import torch

# Define a tensor
x = torch.tensor([0, -1., 10.])

result = torch.erfc(x)

print(result)
```

The output of this code is:

```shell
tensor([1.0000e+00, 1.8427e+00, 1.4013e-45])
```