Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Incorrect results for comparison expression

Consider this:

sage: x = -5564456128*e + 15125759978
sage: x.n(digits=20)
0.000020943072740919888020
sage: (1/47749).n(digits=20)
0.000020942846970617185700
sage: bool(1/47749 <= x)
False

What is going on? Why does the last boolean evaluate to False? This results in the failure of the assertion that 1/ceil(1/x) <= x, which should be true mathematically.

A one-line description of the bug(?) is that Sage evaluates bool(1/47749 <= -5564456128*e + 15125759978) to False. Is there a way to increase the precision, either explicitly or automatically?

Incorrect results for comparison expression

Consider Sage incorrectly evaluates bool(1/47749 <= -5564456128*e + 15125759978) as False.

In more detail, consider this:

sage: x = -5564456128*e + 15125759978
sage: x.n(digits=20)
0.000020943072740919888020
sage: (1/47749).n(digits=20)
0.000020942846970617185700
sage: bool(1/47749 <= x)
False

What is going on? Why does the last boolean evaluate to False? This results in the failure of the assertion that 1/ceil(1/x) <= x, which should be true mathematically.

A one-line description of the bug(?) is that Sage evaluates bool(1/47749 <= -5564456128*e + 15125759978) to False. Is there a way to increase the precision, either explicitly or automatically?compare two quantities that will result in a correct answer, using as much precision as necessary?

Incorrect results for comparison expression

Sage incorrectly evaluates bool(1/47749 <= -5564456128*e + 15125759978) as False.

In more detail, consider this:

sage: x = -5564456128*e + 15125759978
sage: (1/47749).n(digits=6)
0.0000209428
sage: x.n(digits=20)
0.000020943072740919888020
sage: (1/47749).n(digits=20)
0.000020942846970617185700
sage: bool(1/47749 <= x)
False

What is going on? Why does the last boolean evaluate to False? This results in the failure of the assertion that 1/ceil(1/x) <= x, which should be true mathematically.

Is there a way to compare two quantities that will result in a correct answer, using as much precision as necessary?