1 | initial version |
In Python (which is the base language of Sage), the call of a == b
is supposed to return the boolean True
whenever a
is equal to b
, and False
otherwise.
In mathematics, when $x$ is a symbol or an un determinate, you want to be able to deal with expressions such as $2x+4 = 3*x+3$ or $2x+4 < 42$ (e.g. in order to solve them as equations, or to simplify them, etc).
To be able to construct such expressions in Sage, we break the promise that a == b
will return a boolean, so that 2*x+4 == 3x+3
and 2*x+4 < 42
will return symbolic expressions.
For this, the __eq__
method that is called when testing for equality between 2 objects is overriden so that instead of returning a boolean, it returns an expression. Hence, if a
and b
are symbolic expressions, then a == b
is a symbolic expression as well, not a boolean as it should be [1].
If you want to test whether the symbolic expression a
is equal to the symbolic expression b
, you have to type bool(a == b)
.
Note however that, since a boolean is either True
or False
, but not Unknown
, when Sage is not able to prove that a
is equal to b
, it will return False
even if the two expressions are equal.
Note [1] : i omit the coercion layer to make the answer understandable.
2 | No.2 Revision |
In Python (which is the base language of Sage), the call of a == b
is supposed to return the boolean True
whenever a
is equal to b
, and False
otherwise.
In mathematics, when $x$ is a symbol or an un determinate, indeterminate, you want to be able to deal with expressions such as $2x+4 = 3*x+3$ or $2x+4 < 42$ (e.g. in order to solve them as equations, or to simplify them, etc).
To be able to construct such expressions in Sage, we break the promise that a == b
will return a boolean, so that 2*x+4 == 3x+3
and 2*x+4 < 42
will return symbolic expressions.
For this, the __eq__
method that is called when testing for equality between 2 objects is overriden so that instead of returning a boolean, it returns an expression. Hence, if a
and b
are symbolic expressions, then a == b
is a symbolic expression as well, not a boolean as it should be [1].
If you want to test whether the symbolic expression a
is equal to the symbolic expression b
, you have to type bool(a == b)
.
Note however that, since a boolean is either True
or False
, but not Unknown
, when Sage is not able to prove that a
is equal to b
, it will return False
even if the two expressions are equal.
Note [1] : i omit the coercion layer to make the answer understandable.
3 | No.3 Revision |
In Python (which is the base programmng language on top of Sage), which Sage is built), the call of a == b
is supposed to return the boolean True
whenever a
is equal to b
, and False
otherwise.
In mathematics, when $x$ is a symbol or an indeterminate, you want to be able to deal with expressions such as $2x+4 = 3*x+3$ or $2x+4 < 42$ (e.g. in order to solve them as equations, or to simplify them, etc).
To be able to construct such expressions in Sage, we break the promise that a == b
will return a boolean, so that 2*x+4 == 3x+3
and 2*x+4 < 42
will return symbolic expressions.
For this, the __eq__
method that is called when testing for equality between 2 objects is overriden so that instead of returning a boolean, it returns an expression. Hence, if a
and b
are symbolic expressions, then a == b
is a symbolic expression as well, not a boolean as it should be [1].
If you want to test whether the symbolic expression a
is equal to the symbolic expression b
, you have to type bool(a == b)
.
Note however that, since a boolean is either True
or False
, but not Unknown
, when Sage is not able to prove that a
is equal to b
, it will return False
even if the two expressions are equal.
Note [1] : i omit the coercion layer to make the answer understandable.
4 | No.4 Revision |
In Python (which is the programmng language on top of which Sage is built), the call of a == b
is supposed to return the boolean True
whenever a
is equal to b
, and False
otherwise.
In mathematics, when $x$ is a symbol or an indeterminate, you want to be able to deal with expressions such as $2x+4 = 3*x+3$ 3x+3$ or $2x+4 < 42$ (e.g. in order to solve them as equations, or to simplify them, etc).
To be able to construct such expressions in Sage, we break the promise that a == b
will return a boolean, so that 2*x+4 ==
and 3x+33*x+32*x+4 < 42
will return symbolic expressions.
For this, the __eq__
method that is called when testing for equality between 2 objects is overriden so that instead of returning a boolean, it returns an expression. Hence, if a
and b
are symbolic expressions, then a == b
is a symbolic expression as well, not a boolean as it should be [1].
If you want to test whether the symbolic expression a
is equal to the symbolic expression b
, you have to type bool(a == b)
.
Note however that, since a boolean is either True
or False
, but not Unknown
, when Sage is not able to prove that a
is equal to b
, it will return False
even if the two expressions are equal.
Note [1] : i omit the coercion layer to make the answer understandable.