Machine-precision Exp[] function
- To: mathgroup at smc.vnet.net
- Subject: [mg93572] Machine-precision Exp[] function
- From: Roman <rschmied at gmail.com>
- 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] = 3.296831478088558578968907969112477365`9.954589770191001*^-434295 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], 0.] but I'm looking for efficient, built-in, machine-precision procedures since my code is supposed to be blazing fast at the end. Roman.
- Follow-Ups:
- Re: Machine-precision Exp[] function
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Machine-precision Exp[] function