| 1 | initial version |
The difference you noticed comes from the fact that 5 and 3^(1/3) are different objects
sage: parent(5)
Integer Ring
sage: parent(3^(1/3))
Symbolic Ring
Comparisons between integers (and more generally rationals) is very different from comparisons between symbolic elements. In order to test x^y == s^t you would better assume that bot y and t are integers (that you can always do by taken appropriate powers). Assuming that you only care about positive numbers you can use
def test_equality(x, y, s, t):
m = lcm(y.denominator(), t.denominator())
return x^(y*m) == s^(t*m)
| 2 | No.2 Revision |
The difference you noticed comes from the fact that 5 and 3^(1/3) are have different objectsnatures
sage: parent(5)
Integer Ring
sage: parent(3^(1/3))
Symbolic Ring
Comparisons between integers (and more generally rationals) is very different from comparisons between symbolic elements. In order to test x^y == s^t you would better assume that bot y and t are integers (that you can always do by taken appropriate powers). Assuming that you only care about positive numbers you can use
def test_equality(x, y, s, t):
m = lcm(y.denominator(), t.denominator())
return x^(y*m) == s^(t*m)
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.