Re: Division still cost more than multiplication?
- To: mathgroup at smc.vnet.net
- Subject: [mg24303] Re: Division still cost more than multiplication?
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 7 Jul 2000 00:11:45 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <8k0tc4$q2o@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
Timing[x = 1; c = N[\[Pi]]; cInverse = 1/c; Do[y = x*cInverse, {10000}]]
{0.26 Second, Null}
Timing[x = 1; c = N[\[Pi]]; cInverse = 1/c; Do[y = x/c, {10000}]]
{0.41 Second, Null}
The multipication/division algorithm has not changed since several
hundred years -- what are long-gone days for you ?
You can stopp the time by hand *you* need to multiply two
numbers and to divde the numbers.
Regards
Jens
AES 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:
>
> (Outside the loop)
>
> cInverse = 1/c;
>
> (Begin loop structure)
>
> y = cInverse * x
>
> Does this still make any sense in Mathematica? Or is it a primitive
> relic of long-gone days?