0

Suppose a, x, and y are positive IEEE floating point numbers with x < y. Prove that a×x < a×y where × denotes floating-point multiplication rounding to nearest.

Naively, you might suppose that for some a and for x close to y, you would get a×x = a×y. It turns out that this can't happen (as long as denormalized numbers, infinities, and NaNs are excluded).

I'm interested in an elegant proof and, if possible, a book or paper where this is given.

TAKE 2: As the reply by Pascal Cuoq shows, the statement above is false. How about the restricted version with y = 1? Here is the statement to be proved:

Suppose a and x are positive IEEE floating point numbers with x < 1. Prove that a×x < a where × denotes floating-point multiplication rounding to nearest.

cffk
  • 1,839
  • 1
  • 12
  • 17
  • Since infinity can be positive in IEEE I'm not sure such a proof is possible. Did you mean to exclude infinity? https://en.wikipedia.org/wiki/IEEE_754-1985 – candied_orange Jul 22 '15 at 03:10
  • Yes, thanks for pointing this out. I edited the question to exclude infinities and NaNs as well as denormalized numbers. – cffk Jul 22 '15 at 03:22
  • 1
    If you want to change your question, the general advice would be to ask a new one. PS: I believe the new property you are interested in is true. – Pascal Cuoq Jul 22 '15 at 14:03
  • @PascalCuoq: yes, it is true under reasonable assumptions. – Stephen Canon Jul 22 '15 at 20:14

2 Answers2

7

The property is false, as shown by the following C99 program when compiled with a compiler providing IEEE binary64 for double and FLT_EVAL_METHOD=0:

#include <stdio.h>
#include <math.h>
#include <float.h>

int main(void) {
  double z = 1.0;
  double y = nextafter(z, 0.0);
  double x = nextafter(y, 0.0);
  double a = 1.0 + 2 * DBL_EPSILON;

  printf("%a %a\n", a*x, a*y);
}

Result:

0x1.0000000000001p+0 0x1.0000000000001p+0

That's y the predecessor of 1.0, x the predecessor of y, and a the successor of the successor of 1.0. The values of x and y are at the top of their binade, where relative precision is best, and the values of a*x and a*y are at the bottom of theirs, where relative precision is worst. This is how a*x and a*y get rounded to the same value.

The property in the question looks true because a counter-example can only happen with x and y separated by a single ULP and the multiplication by a sending them relatively lower in the destination binade than they were in the origin binade.

Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
1

To put a formal proof to your revised question (with slightly altered language):

Suppose a and x are positive IEEE floating point numbers with x < 1. Prove that [ax] < a where [] denotes default floating-point rounding.

WLOG, let a be in [1, 2). The statement is trivially true if a is 1, so we actually only need to consider a in (1,2). x < 1 implies that x <= 1 - u/2, where u = ulp(1) = ulp(a). We have:

ax <= a - au/2

We also have a > 1, so au/2 > u/2, so:

ax <= a - au/2 < a - u/2

Because ax is more than half an ulp below a, [ax] < a.

Stephen Canon
  • 103,815
  • 19
  • 183
  • 269
  • Thanks. A corollary of this result is that successively multiplying a number by (1 - u/2) marches downwards through all floating point numbers (until the minimum normalized number is reached). Furthermore (?) dividing by (1 - u/2) marches in the opposite direction. – cffk Jul 23 '15 at 03:07
  • 1
    @cffk “through all” no. – Pascal Cuoq Jul 23 '15 at 07:55
  • Addressing just the issue of multipling by x = (1 - u/2). We know that ax < a. Indeed we have ax = nextafter(a, 0); so repeatedly executing a *= x, we march down through successive floating point numbers. (Assume numbers are positive; exclude denormalized numbers, etc.) – cffk Jul 23 '15 at 14:28
  • @cffk: Yes. a - u < ax < a - u/2, hence [ax] = nextDown(a). (The analysis at binade crossings is different, but trivial). – Stephen Canon Jul 23 '15 at 14:32