MathGroup Archive 2006

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

Search the Archive

Re: How to tell Mathematica to use hardware floating point arithmetics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70011] Re: [mg69991] How to tell Mathematica to use hardware floating point arithmetics
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Sat, 30 Sep 2006 05:12:40 -0400 (EDT)
  • References: <200609291048.GAA22392@smc.vnet.net>

Nasser Abbasi wrote:
> Hello.
> 
> Suppose I want to just use hardware floating point operations.
> 
> Suppose my hardware uses IEEE754 standard for binary floating point 
> arithmetics, and I want all my numerical computation inside mathematica to 
> adhere to this only and not to any other in-between software based floating 
> point arithmetics (such as significant arithmetics).
> 
> Is it enough to wrap each result with N[x,16] ? Or is there a flag/option 
> somewhere that one can set once?
> 
> thanks,
> Nasser

Using N[x,16] will do (precisely...) what you do NOT want. It will 
attempt to attain a result to 16 digits using software arithmetic. 
Whether or how significance arithmetic is used would depend on details 
of what N[] is being asked to compute. If you use N[x] with no second 
argument, or N[x,MachinePrecision] (not $MachinePrecision, but rather 
the token-sans-dollar-sign) then hardware arithmetic and libraries 
specific to your OS will be used.

Note that there are situations, such as machine overflow or underflow, 
wherein Mathematica will change over to software arithmetic. Some of 
this is discussed in section 4.2 of the article:
M. Sofroniou and G. Spaletta. Precise numerical computation.
The Journal of Logic and Algebraic Programming 64:113-134. 2005.

I realize from some Usenet postings that you are aware of this article 
but wanted to draw attention to it because
(1) It is good, and others may not know about it.
(2) You may not be aware of this more recent version (you cite the older 
1999 conference version, I think).
(3) The part about machine arithmetic in Mathematica is not hard to miss 
on a quick reading.
(4) There is discussion of how to work in fixed precision using 
Mathematica software arithmetic. Depending on what one wishes to do, 
this might offer some advantage over default handling.


Daniel Lichtblau
Wolfram Research






  • Prev by Date: Re: Re: Performance comparison Mac OSX vs. Windows XP
  • Next by Date: HoldPattern question
  • Previous by thread: Re: [RESEND] How to tell Mathematica to use hardware floating point aithmetics
  • Next by thread: MOGC: Call for Mathematica Graphics