| 1 |
# erfc(x): Complementary Error |
| 2 |
|
| 3 |
Complementary error function. |
| 4 |
|
| 5 |
## Declaration |
| 6 |
|
| 7 |
### Syntax |
| 8 |
|
| 9 |
```fortran |
| 10 |
retval = erfc(x) |
| 11 |
elemental real function erfc(x) |
| 12 |
``` |
| 13 |
|
| 14 |
### Arguments |
| 15 |
|
| 16 |
`x` the input value must be of type real. |
| 17 |
|
| 18 |
### Return values |
| 19 |
|
| 20 |
The return value is of type real and of the same kind as of the input parameter |
| 21 |
`x`. `erfc(x)` returns $1 - erf(x)$. |
| 22 |
|
| 23 |
## Description |
| 24 |
|
| 25 |
**erf(x)** computes the error function of `x`. The result lies in the range: |
| 26 |
|
| 27 |
$0 \leq erf (x) \leq 2$ |
| 28 |
|
| 29 |
It is calculated using: |
| 30 |
|
| 31 |
$\frac{2}{\sqrt\pi}\int_{x}^{\infty}e^{-t^2}dt$ |
| 32 |
|
| 33 |
It is used in instances when the large loss of relative accuracy occurs if |
| 34 |
`erf(x)` is called for large `x` and the result is subtracted from 1. |
| 35 |
|
| 36 |
## Types |
| 37 |
|
| 38 |
Supported argument types is real. |
| 39 |
|
| 40 |
```fortran |
| 41 |
interface erfc |
| 42 |
module procedure serfc, derfc |
| 43 |
end interface |
| 44 |
|
| 45 |
contains |
| 46 |
|
| 47 |
elemental real(sp) function serfc(x) |
| 48 |
real(sp), intent(in) :: x |
| 49 |
end function |
| 50 |
|
| 51 |
elemental real(dp) function derfc(x) |
| 52 |
real(dp), intent(in) :: x |
| 53 |
end function |
| 54 |
``` |
| 55 |
|
| 56 |
## Examples |
| 57 |
|
| 58 |
```fortran |
| 59 |
program intrinsics_erfc |
| 60 |
print *, erfc(1.0) |
| 61 |
end program |
| 62 |
``` |
| 63 |
|
| 64 |
**Result:** |
| 65 |
|
| 66 |
``` |
| 67 |
0.1572992057 |
| 68 |
``` |
| 69 |
|
| 70 |
## See Also |
| 71 |
|
| 72 |
[erf](erf.md). |