Re: On Arnold's challenge & Paul's Observation...
> Subject: RE: On Arnold's challenge & Paul's Observation...
> Date: Thu, 27 Nov 2008 16:58:14 -0700
> From: "Kreinovich, Vladik" <vladik@xxxxxxxx>
> To: "Dan Zuras Intervals" <intervals08@xxxxxxxxxxxxxx>,
> <stds-1788@xxxxxxxxxxxxxxxxx>
>
> Can you clarify this example? We are replacing an expression with an
> equal Single-Use expression -- for which (modulo rounding errors)
> straightforward interval computations produce the exact range, what is
> wrong with this transformation?
>
> > -----Original Message-----
> > From: stds-1788@xxxxxxxx [mailto:stds-1788@xxxxxxxx] On Behalf Of Dan
> Zuras Intervals
>
> > (3) There are other, perhaps more powerful re-arrangements
> > (mostly algebraic in nature) that help even more but should
> > be forbidden to compilers on the grounds that they change
> > the calculation. These appear to be equivalent to the so-
> > called 'value changing optimizations' in 754.
>
> > Then, those things in point (3), say replacing an expression
> > like (x^2 - y^2)/x^2 with 1 - (y/x)^2, should also be listed
> > but, as they are value changing, reserved to the programmer
> > to use or not, as the problem warrents.
Vladik,
I apologise. This is something I have dealt with for so
many years that I forget that others have not seen such
things.
There are many things wrong, or perhaps, right with this
transformation. At least, when evaluated as floating-
point expressions.
Suppose the programmer knows that |y| < |x|. Then if
x^2 overflows, (x^2 - y^2)/x^2 would be oo/oo but
1 - (y/x)^2 would just get the right answer. If x^2
underflows, (x^2 - y^2)/x^2 would be 0/0 but 1 - (y/x)^2
would still get the right answer. In other cases, one
expression might be inexact while the other is exact.
There are other algebraically equivalent expressions,
(x + y)*(x - y)/x^2 or ((x + y)/x)*((x - y)/x) that
have their own advantages & problems but this is not
the point.
The point is that such transformations CHANGE the behavior
of expressions in ways that the programmer did not intend.
Therefore, these are things that should be done by the
programmer & not the compiler.
If the purpose of 1788 is to create portable programs
using intervals that assure users of their results, we
must create an environment in which those results are
good, understandable, & what was asked for.
If we permit such transformations to be automatically
done by one compiler & not another (or one level of
optimization & not another) then, in this example, if
x = [10^200,oo] & y = [-10,10] we might be left with
the situation that (x^2 - y^2)/x^2 returns [0,oo] (or
[1-ULP,oo], depending on that evaluation rule mentioned
before) and 1 - (y/x)^2 returns [1-ULP,1].
If we do it for them, they will be justifiably confused.
If they do it for themselves, they will be justifiably
pleased with their cleverness.
That's the world we're trying to create.
IMHO, of course.
Dan