Skip to content
fn

erfcx

→Tensor
erfcx(input: Tensor)

Scaled complementary error function.

Computes erfcx(x)=ex2 erfc(x)\mathrm{erfcx}(x) = e^{x^2}\, \mathrm{erfc}(x), the Mills-ratio-friendly scaling of the complementary error function. Whereas erfc(x)\mathrm{erfc}(x) underflows to zero for moderately large xx, erfcx decays only as 1/(xπ)1/(x\sqrt\pi) and remains finite, which is essential for tail-probability evaluations of Gaussian-related distributions.

Parameters

inputTensor
Input tensor; any floating-point dtype.

Returns

Tensor

ex2 erfc(x)e^{x^2}\,\mathrm{erfc}(x) element-wise, same shape and dtype as input.

Notes

Mathematical definition:

erfcx(x)=ex2 erfc(x)=ex2⋅2π∫x∞e−t2 dt.\mathrm{erfcx}(x) = e^{x^2}\,\mathrm{erfc}(x) = e^{x^2} \cdot \frac{2}{\sqrt{\pi}} \int_x^\infty e^{-t^2}\, dt.

From x=2x = 2 the value is the continued fraction π−1/2/(x+12/(x+1/(x+32/(x+⋯ ))))\pi^{-1/2} / (x + \tfrac12 / (x + 1 / (x + \tfrac32 / (x + \cdots)))), never the product, whose factors hit opposite extremes. The derivative, 2x erfcx(x)−2/π2x\,\mathrm{erfcx}(x) - 2/\sqrt\pi, is read from the fraction's tail ff as −2πf/(x+f)-\tfrac{2}{\sqrt\pi} f / (x + f) from x=1.5x = 1.5.

Examples

>>> import lucid
>>> from lucid.special import erfcx
>>> erfcx(lucid.tensor([0.0, 1.0, 5.0]))
tensor([1., 0.4276, 0.1107])