       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:= {num, den} = {Random[], Random[]}

Out= {0.0991313, 0.0559147}

In:= recip = 1.0 / den

Out= 17.8844

In:= Timing[Do[num/den, {2000000}]]

Out= {28.8 Second, Null}

In:= {num, den} = {Random[], Random[]}

Out= {0.132828, 0.28853}

In:= recip = 1.0 / den

Out= 3.46585

In:= Timing[Do[num * recip, {2000000}]]

Out= {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?