#### 6.2 \(\frac {a}{b}\) and \(a b^{-1}\) sometimes diﬀer (26.9.97)

I was intrigued to discover that Maple evaluates

5/6.0 and 5*6.0^(-1)

to ﬂoating-point numbers that diﬀer by 2 units in the last decimal place. The on-line help for
arithmetic operations states that

`a/b`

is of type ‘*‘ with operands a and `b^(-1)`

but evidently this does not tell the whole story.

I am guessing that Maple evaluates `5/6.0`

by invoking some built-in algorithm
for ﬂoating-point division, while Maple evaluates `5*6.0^(-1)`

by ﬁrst ﬁnding a
ﬂoating-point approximation to `1/6`

, and then multiplying by 5. Is this a correct
conjecture?

An amusing corollary of this phenomenon is that Maple’s ﬂoating-point evaluation is
"non-commutative": for example, Maple evaluates

5/6.0 and 5.0/6

to diﬀerent results.

What are the precise circumstances under which Maple does treat `a/b`

and `a*b^(-1)`

as
equal?

Looks right to me. Actually this is happening during the preliminary "simpliﬁcation" which is
performed on all Maple input before any evaluation takes place. Thus if you do this with
variables, there is no diﬀerence:

a:= 5; b:= 6.0;
a/b = a*b^(-1);
.8333333333 = .8333333333

In general ﬂoating-point computation is non-commutative. The simplest example is that A +
B - A returns 0 when A is much larger than B. Mind you, that _won’t_ necessarily be true
if the automatic simpliﬁer is allowed to do its magic:

> 1.0e17 + 1 - 1.0e17;
0

but

a:= 1.0e17: b:= 1:
a + b - a; # this will be simplified to b before the arithmetic is performed.
1