MathGroup Archive 2000

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

Search the Archive

Re: Division still cost more than multiplication?

  • To: mathgroup at
  • Subject: [mg24390] Re: Division still cost more than multiplication?
  • From: Richard Fateman <fateman at>
  • Date: Wed, 12 Jul 2000 23:13:31 -0400 (EDT)
  • Organization: University of California, Berkeley
  • References: <8k0tc4$> <8k3o2q$>
  • Sender: owner-wri-mathgroup at

I don't know why you are particularly optimizing the time for a
numeric calculation in Mathematica, since if you were concerned
about the time, you should be using something like Fortran.

In high-end computer systems, the time to do a multiply or
a divide is essentially irrelevant, since the time to get the
data from memory and back to memory is much greater.  Some systems
may several arithmetic units and are quite happy to do several
operations (adds, multiplies, divides, square roots) at the same

The observation regarding Mathematica is undoubtedly unrelated to the
time taken to do a floating-point division.  It is probably related to
processing, maybe having to do with simplification, or error checking
(checking for division by zero, perhaps?)

AES wrote:
> In article <8k0tc4$q2o at>, AES <siegman at> wrote:
> > Old-time FORTRAN programmers (like me) were taught (at least in early
> > days) that division cost a lot more machine cycles than multiplication.
> > So, if you had an expression like  y = x/c  that was going to be called
> > many times inside a loop, where x and y were variables and c a constant,
> > you'd code this as:
>    [snip]
> > Does this still make any sense in Mathematica?  Or is it a primitive
> > relic of long-gone days?
> +++++++++++++++++++++++++++++++++++++++++++++
> Anticipating replies to my query that I believe are coming from P. J.
> Hinton and Daniel Lichtbau ((thanks to both), here is the same test as
> P. J. Hintons, performed on a 1998-model 400 MHz Mac PowerBook G3,
> giving very similar results:
>    In[7]:= {num, den} = {Random[], Random[]}
>    Out[7]= {0.0991313, 0.0559147}
>    In[8]:= recip = 1.0 / den
>    Out[8]= 17.8844
>    In[9]:= Timing[Do[num/den, {2000000}]]
>    Out[9]= {28.8 Second, Null}
>    In[10]:= {num, den} = {Random[], Random[]}
>    Out[10]= {0.132828, 0.28853}
>    In[11]:= recip = 1.0 / den
>    Out[11]= 3.46585
>    In[12]:= Timing[Do[num * recip, {2000000}]]
>    Out[12]= {14.6833 Second, Null}

  • Prev by Date: Re: With[{software=Mathematica}, Frustration]
  • Next by Date: Re: A strange bug in Solve
  • Previous by thread: Re: Division still cost more than multiplication?
  • Next by thread: Re: Re: Division still cost more than multiplication?