Some built-in functions (like Exp) give an arbitrary precision result, even when the argument is a machine precision number. Example:

Exp[-10.] // Precision


Exp[-1000.] // Precision


I can of course Clip and Chop the result to a machine precision number, but I would like to avoid the cost of arbitrary precision calculations (and unpacking, if the argument is a packed array) in the first place. For example here:

x = Range[-10.^6, 10.^6];
Timing[y = Exp[-x^2/2];]

The calculation takes 7s on my PC (machine precision calculation would take ~0.1s) and the result isn't a packed array.

  • $\begingroup$ The only thing I can think of at the moment is Compile, is it of interest? $\endgroup$
    – xzczd
    Jan 9, 2015 at 13:47
  • 1
    $\begingroup$ Thanks @OleksandrR., SystemSetSystemOptions["CatchMachineUnderflow" -> False];` works perfectly. I did look for similar questions, but didn't find the one you linked. It's obviously a duplicate. Should delete it myself or vote to close? $\endgroup$ Jan 9, 2015 at 13:59
  • 1
    $\begingroup$ We may as well VTC so that this can serve as another pointer to help other people search in the future. As @xzczd says, Compile can also work, and if you don't feel like setting a global option, the Compile option "RuntimeOptions" -> {"CatchMachineUnderflow" -> False} could be a good alternative. $\endgroup$ Jan 9, 2015 at 14:00


Browse other questions tagged or ask your own question.