fn

erfcx

Tensor
erfcx(x: Tensor)
source

Scaled complementary error function.

Computes erfcx(x)=ex2erfc(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

xTensor
Input tensor; any floating-point dtype.

Returns

Tensor

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

Notes

Mathematical definition:

erfcx(x)=ex2erfc(x)=ex22πxet2dt.\mathrm{erfcx}(x) = e^{x^2}\,\mathrm{erfc}(x) = e^{x^2} \cdot \frac{2}{\sqrt{\pi}} \int_x^\infty e^{-t^2}\, dt.

The implementation forms the product of exp(x*x) and erfc(x) directly, which is accurate for x5|x| \lesssim 5. For very large positive x the two factors hit opposite floating-point extremes and accuracy degrades — use a dedicated continued-fraction expansion if extreme-value precision is required.

Examples

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