# Associativity in floating point arithmetic failing by two values

Assume all numbers and operations below are in floating-point arithmetic with finite precision, bounded exponent, and rounding to the nearest integer.

Are there $$x,y$$ positive such that \begin{align}(x+y)-x&>y\\(x+y)-s(x)&>y\end{align} where $$s(x)$$ denotes the successor of $$x$$?

This question appeared while designing a test for a software.

It is easy to write a program that searches for such an example, but it is unfeasible to test all possibilities and show that the example doesn't exist. So far my code hasn't got any example.

Example: In case seeing an example of $$(x+y)-x>y$$ helps somehow, take \begin{align} x&=1.1234567891234568\\ y&=1e-5\text{ ( denoting }10^{-5}) \end{align} Then $$(x+y)-x=1.0000000000065512e-05 > y$$. There are many examples of the first inequality.

Link to scicomp.stackexchange's copy of this post in case a solution appears there first. There is already a solution there.

• I don't see this question as being about mathematics. – 5xum Oct 3 '17 at 12:10
• @5xum There is a field of mathematics called Numerical Analysis that studies floating point arithmetic. The question explores the magnitude of the failure of asociativity in floating point arithmetic. – EEE Oct 3 '17 at 12:14
• @5xum And not only mathematics, it belongs to the far narrower scope that this website handles. Observe how the tag (floating-point) exists here. – EEE Oct 3 '17 at 12:28
• Try also scicomp.stackexchange.com – lhf Oct 3 '17 at 14:04
• I guess you want to work with rounding-to-nearest mode. For round-up mode there are examples for both. – gammatester Oct 3 '17 at 14:46