Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Division still cost more than multiplication?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24304] Re: Division still cost more than multiplication?
  • From: AES <siegman at stanford.edu>
  • Date: Fri, 7 Jul 2000 00:11:46 -0400 (EDT)
  • Organization: Stanford University
  • References: <8k0tc4$q2o@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <8k0tc4$q2o at smc.vnet.net>, AES <siegman at stanford.edu> 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: Plotting multiple functions using Map
  • Next by Date: RE: How to use BestFitParameters?
  • Previous by thread: Re: Division still cost more than multiplication?
  • Next by thread: Re: Division still cost more than multiplication?