Skip to content

InverseErfc

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

InverseErfc[s]

gives the inverse complementary error function: the z solving s = Erfc[z].

InverseErfc[0] = Infinity, InverseErfc[1] = 0, InverseErfc[2] = -Infinity.

Notes Numerical values are given only for real s in \[0, 2\], at machine or arbitrary (MPFR) precision; D\[InverseErfc\[z\], z\] = -(Sqrt\[Pi\]/2) E^(InverseErfc\[z\]^2). Listable.

Examples (5)

Every input below was run against the current Mathilda build and its output recorded.

Applications (5)

In[1]:= InverseErfc[1]
Out[1]= 0

In[2]:= InverseErfc[2]
Out[2]= -Infinity

In[3]:= N[InverseErfc[1/1000000], 40]
Out[3]= 3.4589107372795000221509276359575695199155

In[4]:= D[InverseErfc[z], z]
Out[4]= -1/2 Sqrt[Pi] E^InverseErfc[z]^2

In[5]:= InverseErf[1 - 3/10] == InverseErfc[3/10]
Out[5]= True

Algorithm

Mathilda -- the inverse complementary error function.

  InverseErfc[s]   inverse of erfc: the z solving s = erfc(z)

Since erfc maps the real line onto (0, 2) (decreasing from 2 at -Infinity to 0 at +Infinity), explicit numerical values are produced only for real s in [0, 2]; out-of-domain (s < 0 or s > 2) and complex inputs stay symbolic. Evaluation mirrors InverseErf -- no complex machinery:

  exact special values   ->  InverseErfc[0]=Infinity, InverseErfc[1]=0,
                             InverseErfc[2]=-Infinity
  machine real (0<s<2)   ->  Winitzki seed + Newton polish on libm erfc
  arbitrary real (0<s<2) ->  Newton with precision doubling on mpfr_erfc
  everything else        ->  stays symbolic (return NULL)

Mathematically InverseErfc[s] = InverseErf[1 - s], but we do NOT route through InverseErf: for small s (large z) forming 1 - s and inverting erf near 1 loses all significance to cancellation. Instead Newton iterates on erfc directly -- both libm and MPFR ship cancellation-free erfc -- with

  f(z) = erfc(z) - s,  f'(z) = -(2/sqrt(pi)) e^{-z^2}, i.e.
  z <- z + (erfc(z) - s) (sqrt(pi)/2) e^{z^2}.

Newton converges quadratically; the MPFR path doubles the working precision each step so the final full-precision erfc dominates the cost.

The derivative D[InverseErfc[z], z] = -(sqrt(pi)/2) e^{InverseErfc[z]^2} lives in src/calculus/deriv.c; Series follows from it via the generic Taylor-via-D fallback. (erfc is not odd, so unlike InverseErf there is no auto-applied symmetry rewrite.)

Attributes: Listable, NumericFunction, Protected.

Implementation notes

Algorithm. builtin_inverfc solves s = erfc(z). Since erfc maps the real line onto (0, 2), explicit values are produced only for real s in [0, 2]; out-of-domain and complex inputs stay symbolic. Exact: 0 -> Infinity, 1 -> 0, 2 -> -Infinity. Machine real 0 < s < 2 uses inverfc_double: a Winitzki seed on w = 1 - s polished by four Newton steps directly on the libm erfc, z <- z + (erfc(z) - s)(sqrt(pi)/2) e^{z^2} — it deliberately does not route through InverseErf[1 - s], which would lose all significance to cancellation for small s. Arbitrary precision uses Newton with precision doubling on mpfr_erfc. The derivative -(sqrt(pi)/2) e^{InverseErfc[z]^2} lives in calculus/deriv.c; Series follows via Taylor-via-D. (erfc is not odd, so there is no auto-applied symmetry rewrite.)

Data structures. Expr; double (inverfc_double, exposed for ND and the Compile[] VM); mpfr_t for the arbitrary-precision Newton loop. ND: real-only unary kernel NDKU_InverseErfc = { NULL, ndk_InverseErfc_r, ... }, registered REG_U, so packed_aware. Attributes: Listable, NumericFunction, Protected.

Complexity / limits. Newton converges quadratically; the MPFR cost tracks the final full-precision erfc. Domain is the real interval [0, 2]; outside it (and for complex or exact-rational s) the call stays symbolic. Compile[] lowers at both scalar and rank-1 array shapes (Compiled -> True).

  • Exact special values: InverseErfc[0] = Infinity, InverseErfc[1] = 0, InverseErfc[2] = -Infinity (likewise the real 0./2.), plus Indeterminate passes through.
  • Numeric evaluation. Mathematically InverseErfc[s] = InverseErf[1 − s], but for small s (large z) that subtraction loses all significance to cancellation, so the kernel instead Newton-iterates directly on the cancellation-free erfc: f(z) = erfc(z) − s, z ← z + (erfc(z) − s)(Sqrt[Pi]/2) e^{z²}:
  • Machine-precision real → sf_inverse_erfc_r, the InverseErf kernel fed the exact complement q = min(s, 2 − s), so the tail (q down to the least normal double, z ≈ 26.5) is resolved from q itself, never from 1 − s; ≤ 2.2 ulp. A subnormal s (whose few bits the Halley residual cannot resolve) is solved at 53 bits in MPFR — it used to answer Indeterminate. E.g. InverseErfc[0.6] = 0.370807, InverseErfc[1/{2.,3.,4.,5.}] = {0.476936, 0.68407, 0.81342, 0.906194}, InverseErfc[1.*^-320] = 27.0732.
  • Arbitrary precision (MPFR) real → Newton with precision doubling on mpfr_erfc, output precision tracking the input, e.g. N[InverseErfc[33/100], 50] = 0.68880252811655645040250472890525783544948992349371 (≈0.002 s even at 500-digit precision).
  • erfc is not odd, so unlike InverseErf there is no auto-applied symmetry rewrite; the reflection InverseErfc[1.5] = -InverseErfc[0.5] is computed numerically rather than rewritten.
  • Derivative: D[InverseErfc[z], z] = -(Sqrt[Pi]/2) E^(InverseErfc[z]²) (chain rule applies), so higher derivatives and the Taylor series follow from the generic D-based fallback.
  • All other arguments (symbolic InverseErfc[x], exact InverseErfc[1/2], out-of-domain InverseErfc[2.3]) stay unevaluated.

Attributes: Listable, NumericFunction, Protected.

References

See also: InverseErf, D

Notes & additional examples

Notes

InverseErfc[s] returns the z solving Erfc[z] == s, with InverseErfc[0] = Infinity, InverseErfc[1] = 0, InverseErfc[2] = -Infinity. Numerical values are produced only for real s in [0, 2], at machine or arbitrary (MPFR) precision. It is the natural function for accurate evaluation of extreme normal-distribution quantiles, where 1 - Erf would lose all precision to cancellation.