1 | initial version |
What's going on is that non-symbolic equalities and inequalities are immediately evaluated but symbolic ones aren't. For example:
sage: 2 == 2
True
sage: 2 == 2.0
True
sage: 2 == SR(2)
2 == 2
And in this case, exp(log(n)) is symbolic:
sage: parent(2)
Integer Ring
sage: parent(log(2))
Symbolic Ring
sage: parent(exp(log(2)))
Symbolic Ring
The solution is to call bool explicitly when you want a boolean output:
sage: 2 == exp(log(2))
2 == 2
sage: bool(2 == exp(log(2)))
True
2 | No.2 Revision |
What's going on is that many non-symbolic equalities and inequalities are immediately evaluated but symbolic ones aren't. aren't, so that we can have equations. [Otherwise symbolic equations would always be being evaluated, and you could never write "x==2", because it'd be false.] For example:
sage: 2 == 2
True
sage: 2 == 2.0
True
sage: 2 == SR(2)
2 == 2
And in this case, exp(log(n)) is symbolic:
sage: parent(2)
Integer Ring
sage: parent(log(2))
Symbolic Ring
sage: parent(exp(log(2)))
Symbolic Ring
The solution is to call bool explicitly when you want a boolean output:
sage: 2 == exp(log(2))
2 == 2
sage: bool(2 == exp(log(2)))
True
3 | No.3 Revision |
What's going on is that many non-symbolic equalities and inequalities are immediately evaluated but symbolic ones aren't, so that we can have equations. [Otherwise symbolic equations would always be being evaluated, and you could never write "x==2", because it'd be false.] For example:
sage: 2 == 2
True
sage: 2 == 2.0
True
sage: 2 == SR(2)
2 == 2
And in this case, exp(log(n)) is symbolic:
sage: parent(2)
Integer Ring
sage: parent(log(2))
Symbolic Ring
sage: parent(exp(log(2)))
Symbolic Ring
The solution is to call bool explicitly when you want a boolean output:
sage: 2 == exp(log(2))
2 == 2
sage: bool(2 == exp(log(2)))
True
I should also give the standard warning, which is that Sage inherits its definitions of True and False for equations from Maxima: "False" doesn't necessarily mean false, it might only mean "Sage couldn't figure out how to prove it was true."