MathGroup Archive 2011

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

Search the Archive

avoiding non-machine numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115541] avoiding non-machine numbers
  • From: wpb <wicher.bergsma at gmail.com>
  • Date: Fri, 14 Jan 2011 06:17:04 -0500 (EST)

By default, Mathematica switches to non-machine numbers when needed,
eg,

In[4334]:= Exp[-50.^2]

Out[4334]= 1.835672669162*10^-1086

But this has a severe possible drawback in terms of computational
speed. For example, the following is very quick

In[4420]:= t = RandomReal[NormalDistribution[0, .1], 400000];
Exp[-t^2]; // Timing

Out[4421]= {0., Null}

but in the following computation non-machine numbers are generated,
and we get an enormous decrease in speed:

In[4422]:= t = RandomReal[NormalDistribution[0, 20], 400000];
Exp[-t^2]; // Timing

Out[4423]= {1.25, Null}

So is it possible to get a computation such as Exp[-50.^2] to evaluate
to zero in a very fast way? That is, that small numbers outside
machine-precision range evaluate to zero automatically?

Thanks, Wicher


  • Prev by Date: clip
  • Next by Date: Re: DesignerUnits 2011-01-08 for Mathematica 8, 7, 6
  • Previous by thread: Re: clip
  • Next by thread: Re: avoiding non-machine numbers