You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sage: x = QQbar(sqrt(8))
....: ceil(x-2*QQbar(sqrt(2)))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[41], line 2
1 x = QQbar(sqrt(Integer(8)))
----> 2 ceil(x-Integer(2)*QQbar(sqrt(Integer(2))))
File /mnt/opt/Sage/sage-clang/src/sage/functions/other.py:433, in Function_ceil.__call__(self, x, **kwds)
416 def __call__(self, x, **kwds):
417 """
418 Allow an object of this class to behave like a function. If
419 ``ceil`` is an instance of this class, we can do ``ceil(n)`` to get
(...)
431 -2
432 """
--> 433 return _eval_floor_ceil(self, x, "ceil", **kwds)
File /mnt/opt/Sage/sage-clang/src/sage/functions/other.py:297, in _eval_floor_ceil(self, x, method, bits, **kwds)
293 continue
295 bits *= 2
--> 297 raise ValueError("cannot compute {}({!r}) using {} bits of precision".format(method, x, RIF.precision()))
ValueError: cannot compute ceil(0.?e-307) using 512 bits of precision
Documentation of ceil() says:
3. If none of the above work, Sage returns a "Expression" object.
This is contradicting next pieces of the docs:
Small numbers which are extremely close to an integer are hard to
deal with:
sage: ceil((33^100 + 1)^(1/100))
Traceback (most recent call last):
...
ValueError: cannot compute ceil(...) using 256 bits of precision
The latter is not an Expression.
Worse, increasing the precision does not seem to have an effect:
ValueError: cannot compute ceil(0.?e-157825) using 262144 bits of precision
Note that there is already some code written to handle algebraic numbers that appear almost indistinguishable from 0 - namely the functions bool(self) and sign(self) in the QQbar module ( https://github.com/sagemath/sage/blob/develop/src/sage/rings/qqbar.py ). So ceil() should maybe call one of these two functions.
Steps To Reproduce
Documentation of
ceil()
says:This is contradicting next pieces of the docs:
The latter is not an
Expression
.Worse, increasing the precision does not seem to have an effect:
Is this a bug in
RIF
?This was reported to me by @Ilia-Smilga
Expected Behavior
it should work
Actual Behavior
it doesn't
Additional Information
Note that in this case, one can immediately see that we're computing
ceil
of an algebraic number0
:The latter can be used as follows:
Environment
current Sage beta
Checklist
The text was updated successfully, but these errors were encountered: