MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Machine-precision Exp[] function

  • To: mathgroup at
  • Subject: [mg93572] Machine-precision Exp[] function
  • From: Roman <rschmied at>
  • Date: Sat, 15 Nov 2008 06:03:08 -0500 (EST)

Hi all,

The built-in Exp[] function is a bit too smart for my purposes, since
it generates arbitrary-precision results if machine-precision numbers
cannot hold the result. For instance,
   In[1] := Exp[-1`*^6]
   Out[1] =
produces a number for which MachineNumberQ[] returns False. Such non-
machine-precision numbers massively slow down my program without
actually making any difference in accuracy at the end. So I need a
function, MachineNumberExp[], which *always* spits out a machine-
precision number; underflows would be replaced by zeroes:
   In[2] := MachinePrecisionExp[-1`*^6]
   Out[2] = 0.
Is such a function already built into Mathematica? I.e., is there a
way to switch off the underflow-treatment behavior of calculating
arbitrary-precision results?

I know I can define
MachinePrecisionExp[x_?MachineNumberQ] := If[Re[x] >= -708, Exp[x],
but I'm looking for efficient, built-in, machine-precision procedures
since my code is supposed to be blazing fast at the end.


  • Prev by Date: Basic programming
  • Next by Date: Re: Machine-precision Exp[] function
  • Previous by thread: RE: Basic programming
  • Next by thread: Re: Machine-precision Exp[] function