Accurate computation of $\exp(a x^2) Q(x)$ for big values of $x$?

225 Views Asked by At

I was wondering how one can accurately compute the value of $\exp(a x^2) Q(b x)$ for large values of

$$x \left(Q(x) \triangleq \frac{1}{\sqrt{2\pi}}\int_x^{\infty} e^{-\frac{u^2}{2}} du \right)?.$$

By Chernoff bound the value is upper-bounded by $\frac12 \exp((a - \frac{b^2}{2})x^2)$, hence whenver $a < \frac{b^2}{2}$ (which is the case I'm considering) the value must be close to zero (for large $x$). However, direct computation of the value (for example in a C code using the built-in functions of the standard math library) would evaluate to -nan values simply because we are multiplying a very big number by a very tiny one.

Does anyone have any ideas about how to rearrange the above to get precise results?

2

There are 2 best solutions below

5
On

See e.g. the Cephes library for the Exponentially scaled erfc function $\mathrm{erfce}(x) = \mathrm{erfc}(x)\exp x^2$ in the file ndtr.c. There is also an efficient asymptotic expansion for large x, i.e. for $x > 128$ the function can be computed with the expression ($y = 1/(2x^2)$: $$ \mathrm{erfce}(x) \sim \big(1 - y + 3 y^2 - 15 y^3 + 105 y^4 - 945 y^5 + O(y^6)\big)/(x\sqrt\pi) $$

1
On

Asymptotically, your integral behaves as

$$ e^{a x^2} (Q(x) \triangleq \frac{1}{\sqrt{2\pi}}\int_x^{\infty} e^{-\frac{u^2}{2}} du) \sim \frac{1}{\sqrt{2}}\frac{e^{\frac{1}{2}(2a-1)x^2}} {x} .$$