ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 17 Jan 2019 23:02:07 -0600Recovering numbers from continued fractionhttps://ask.sagemath.org/question/45093/recovering-numbers-from-continued-fraction/Okay, not really, since we won't type in infinitely many numbers. But it would be nice to have a way to convert `[1,1,1,1,1,1,1,1,1]` to a rational approximation of the golden ratio. I couldn't find anything built-in, but maybe I didn't look hard enough? kcrismanThu, 17 Jan 2019 23:02:07 -0600https://ask.sagemath.org/question/45093/How to test an identity of rational numbers?https://ask.sagemath.org/question/38274/how-to-test-an-identity-of-rational-numbers/ Hi,
Why is there a difference in output between:
print 5-1 == 0
print 3^(1/3) - 3^(1/5) == 0
False
3^(1/3) - 3^(1/5) == 0
What can I do if $x,y,s,t \in \mathbb Q$, and I want to test $x^y == s^t$?
Thanks for your support!
RolandrolandSat, 15 Jul 2017 06:17:59 -0500https://ask.sagemath.org/question/38274/Why is sage behaving weird when rounding rational numbers?https://ask.sagemath.org/question/33490/why-is-sage-behaving-weird-when-rounding-rational-numbers/I might be doing something stupid, but Sage's `int()` and `round()` functions seem to be buggy to me.
I'm trying to use these with rational numbers to round towards zero. I'd expect `-7/4` to round to `-1` and `+7/4` to round to `1`. Instead I get different behavior for rationals and their decimal representation:
┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 7.1, Release Date: 2016-03-20 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: int(-1.75) # Correctly rounds towards zero
-1
sage: int(-7/4) # Does not round towards zero
-2
sage: (-7/4).round("toward") # Does not round towards zero (despite what the documentation claims!)
-2
sage: -7/4 + 0.0 # The numbers are in fact the same!
-1.75
How do I round rational numbers towards zero in Sage?con-f-useSat, 21 May 2016 07:34:27 -0500https://ask.sagemath.org/question/33490/Convert symbolic expressions like sqrt(2) or exp(1) to rational numbershttps://ask.sagemath.org/question/23583/convert-symbolic-expressions-like-sqrt2-or-exp1-to-rational-numbers/I have coefficents of a rational polynomial f(x) in terms of symbolic expressions like `sqrt(2)` and `exp(1)`.
How can I convert these coefficients to rational number approximations of them, so that I can work in a structure like a polynomial ring? jjackFri, 25 Jul 2014 12:35:04 -0500https://ask.sagemath.org/question/23583/