Skip to content
Ubiquev1.0.4
functionerfc
erfc(x: number): number

Complementary error function.

Calculates the complementary error function, which is widely used in probability, statistics, and partial differential equations.

The complementary error function is defined as:

           2     ∞
erfc(x) = ───  ∫  e^(-t²) dt  =  1 - erf(x)
          √π    x

This implementation provides an approximation with a high degree of accuracy.

Examples

Compute the complementary error function for a single value

import { assertEquals, assertAlmostEquals } from "jsr:@std/assert";

assertAlmostEquals(erfc(0.5), 0.4795001221869535, 2.3975006109347676e-13);

Compute the complementary error function for a negative value

import { assertEquals, assertAlmostEquals } from "jsr:@std/assert";

assertAlmostEquals(erfc(-1), 1.8427007929497148, 9.213503964748575e-13);

Compute the complementary error function for zero

import { assertEquals, assertAlmostEquals } from "jsr:@std/assert";

assertAlmostEquals(erfc(0), 1.0, 5e-13);

Compute the complementary error function for a large positive value

import { assertEquals, assertAlmostEquals } from "jsr:@std/assert";

assertAlmostEquals(erfc(2), 0.004677734981047266, 1e-14);

Compute the complementary error function for a large negative value

import { assertEquals, assertAlmostEquals } from "jsr:@std/assert";

assertAlmostEquals(erfc(-2), 1.9953222650189528, 9.976611325094764e-13);

Parameters

x: number

A real value

Return Type

number

The value of the complementary error function for the input x

Throws

If no arguments are provided