0
$\begingroup$

This question already has an answer here:

The function erfcx(x) = exp(x^2)erfc(x) is sometimes provided in numerical packages to avoid numerical underflow for large values of x. But Mathematica does not provide a native implementation of this function.

Any suggestions as to what can I use to compute $\exp(x^2)\mathrm{erfc}(x)$ accurately for large values of $x$?

Edit: I just realized this is a duplicate of Numerical underflow for a scaled error function, which contains very detailed answers. So I'm closing this one.

$\endgroup$

marked as duplicate by becko, Community Jul 18 at 19:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Underflow rather than Overflow? $\endgroup$ – mikado Jul 18 at 18:01
  • 1
    $\begingroup$ What do you consider large values of $x$? N[Exp[x^2] Erfc[x] /. x -> 1000000, 500] works fine. $\endgroup$ – JimB Jul 18 at 18:01
  • $\begingroup$ you can also use 2 HermiteH[-1, x]/Sqrt[Pi]. $\endgroup$ – AccidentalFourierTransform Jul 18 at 18:07
  • $\begingroup$ @JimB - extreme precision isn't necessary. Even low arbitrary-precision works fine, e.g., N[Exp[x^2] Erfc[x] /. x -> 1000000, 15] $\endgroup$ – Bob Hanlon Jul 18 at 18:18
  • $\begingroup$ Do those numerical packages just use the approximation $\frac{1}{\sqrt{\pi } x}$ for $x>10^6$ ? $\endgroup$ – JimB Jul 18 at 18:18
2
$\begingroup$

Using the approximation $\frac{1}{\sqrt{\pi } x}$ when $x>5*10^6$:

erfcx[x_] := If[x > 5*10^7, 1/(x Sqrt[π]), Exp[x^2] Erfc[x]]
erfcx[10^50] // N
(* 5.6419*10^-51 *)

One potential reference is Closed‐form approximations to the error and complementary error functions and their applications in atmospheric science.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.