Skip to content
Ubiquev1.0.4
functionerfinv
erfinv(y: number): number

Inverse error function.

Computes the inverse of the error function.

The inverse error function satisfies y = erf(x), for -1 ≤ y ≤ 1 and -∞ ≤ x ≤ ∞.

Examples

Compute the inverse error function for a positive value

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

assertAlmostEquals(erfinv(0.1), 0.08885599049425769, 4.442799524712884e-14);

Compute the inverse error function for a negative value

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

assertAlmostEquals(erfinv(-0.5), -0.4769362762044699, 2.384681381022349e-13);

Compute the inverse error function for 0 (should return 0)

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

assertAlmostEquals(erfinv(0), 0.0, 1e-14);

Compute the inverse error function for 1 (should return positive infinity)

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

assertEquals(erfinv(1), Infinity);

Compute the inverse error function for -1 (should return negative infinity)

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

assertEquals(erfinv(-1), -Infinity);

Parameters

y: number

A real value in the range [-1, 1]

Return Type

number

The value of the inverse error function

Throws

If the input is out of range