1 | initial version |

Your attempt to use interval arithmetics was on the right way. However, you should know that `RIF(a) < RIF(b)`

returns `False`

when both intervals intersect. So what you have to do is to test first whether the two intervals intersect. If yes, then you have to improve the precision, otherwise you can compare them. Here is a possible implementation:

```
def smaller(a,b):
prec = 53
while True:
R = RealIntervalField(prec)
try:
R(a).intersection(R(b))
except ValueError:
return R(a) < R(b)
else:
print '{} bits of precision is not enough'.format(prec)
prec += 1
```

Note that i had to use the `try...except`

statement since `A.intersection(B)`

raises a `ValueError`

when both interval are disjoint.

Now, you can do:

```
sage: a = log(10) * 248510777753
sage: b = log(1024) * 82553493450
sage: smaller(a,b)
53 bits of precision is not enough
54 bits of precision is not enough
55 bits of precision is not enough
56 bits of precision is not enough
57 bits of precision is not enough
58 bits of precision is not enough
59 bits of precision is not enough
60 bits of precision is not enough
61 bits of precision is not enough
62 bits of precision is not enough
63 bits of precision is not enough
64 bits of precision is not enough
65 bits of precision is not enough
66 bits of precision is not enough
67 bits of precision is not enough
68 bits of precision is not enough
69 bits of precision is not enough
70 bits of precision is not enough
71 bits of precision is not enough
72 bits of precision is not enough
73 bits of precision is not enough
74 bits of precision is not enough
75 bits of precision is not enough
76 bits of precision is not enough
77 bits of precision is not enough
True
```

Of course, you can multiply the precision by two instead of incrementing to be faster. Also, you can add an symbolic equality test, and define an upper bound on the precision in case both number are equal but cannot be proven equal, and so on.

2 | No.2 Revision |

Your attempt to use interval arithmetics was on the right way. However, you should know that `RIF(a) < RIF(b)`

returns `False`

when both intervals intersect. So what you have to do is to test first whether the two intervals intersect. If yes, then you have to improve the precision, otherwise you can compare them. Here is a possible implementation:

```
def smaller(a,b):
prec = 53
while True:
R = RealIntervalField(prec)
try:
R(a).intersection(R(b))
except ValueError:
return R(a) < R(b)
else:
print '{} bits of precision is not enough'.format(prec)
prec += 1
```

Note that i had to use the `try...except`

statement since `A.intersection(B)`

raises a `ValueError`

when both interval are disjoint.

Now, you can do:

```
sage: a = log(10) * 248510777753
sage: b = log(1024) * 82553493450
sage: smaller(a,b)
53 bits of precision is not enough
54 bits of precision is not enough
55 bits of precision is not enough
56 bits of precision is not enough
57 bits of precision is not enough
58 bits of precision is not enough
59 bits of precision is not enough
60 bits of precision is not enough
61 bits of precision is not enough
62 bits of precision is not enough
63 bits of precision is not enough
64 bits of precision is not enough
65 bits of precision is not enough
66 bits of precision is not enough
67 bits of precision is not enough
68 bits of precision is not enough
69 bits of precision is not enough
70 bits of precision is not enough
71 bits of precision is not enough
72 bits of precision is not enough
73 bits of precision is not enough
74 bits of precision is not enough
75 bits of precision is not enough
76 bits of precision is not enough
77 bits of precision is not enough
True
```

Of course, you can multiply the precision by two instead of incrementing to be faster. Also, you can add ~~an ~~a symbolic equality test, and define an upper bound on the precision in case both ~~number ~~numbers are equal but cannot be proven equal, and so on.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.