1 | initial version |
You should have a look at the documentation about coercion, for example, see http://doc.sagemath.org/html/en/reference/coercion/index.html and http://doc.sagemath.org/html/en/reference/coercion/index.html
When you multiply two elements that do not have the same parent, the coercion model first put both elements in a common parent and do the multiplication within this parent.
In your first case, you multiply an element of RealField(128)
with an element of ZZ
(which is exact), the common parent is RealField(128)
and the multiplication is done there.
In your second case, you multiply an element of RealField(128)
with an element of RR=RealField(53)
, the common parent is RealField(53)
since you can not increase the precision of a number. Imagine the extreme case RealField(2)(pi) = 3.0
to be multiplied with RR(pi) = 3.14159265358979
would you expect Sage to silently give you as result RR(pi)*RR(3.0) = 9.42477796076938
while RR(pi)^2 = 9.86960440108936
?
2 | No.2 Revision |
You should have a look at the documentation about coercion, for example, see http://doc.sagemath.org/html/en/reference/coercion/index.html http://www.sagemath.org/documentation/html/en/tutorial/tour_coercion.html and http://doc.sagemath.org/html/en/reference/coercion/index.html http://doc.sagemath.org/html/en/reference/coercion/index.html
When you multiply two elements that do not have the same parent, the coercion model first put both elements in a common parent and do the multiplication within this parent.
In your first case, you multiply an element of RealField(128)
with an element of ZZ
(which is exact), the common parent is RealField(128)
and the multiplication is done there.
In your second case, you multiply an element of RealField(128)
with an element of RR=RealField(53)
, the common parent is RealField(53)
since you can not increase the precision of a number. Imagine the extreme case RealField(2)(pi) = 3.0
to be multiplied with RR(pi) = 3.14159265358979
would you expect Sage to silently give you as result RR(pi)*RR(3.0) = 9.42477796076938
while RR(pi)^2 = 9.86960440108936
?
3 | No.3 Revision |
You should have a look at the documentation about coercion, for example, see http://www.sagemath.org/documentation/html/en/tutorial/tour_coercion.html http://doc.sagemath.org/html/en/tutorial/tour_coercion.html and http://doc.sagemath.org/html/en/reference/coercion/index.html
When you multiply two elements that do not have the same parent, the coercion model first put both elements in a common parent and do the multiplication within this parent.
In your first case, you multiply an element of RealField(128)
with an element of ZZ
(which is exact), the common parent is RealField(128)
and the multiplication is done there.
In your second case, you multiply an element of RealField(128)
with an element of RR=RealField(53)
, the common parent is RealField(53)
since you can not increase the precision of a number. Imagine the extreme case RealField(2)(pi) = 3.0
to be multiplied with RR(pi) = 3.14159265358979
would you expect Sage to silently give you as result RR(pi)*RR(3.0) = 9.42477796076938
while RR(pi)^2 = 9.86960440108936
?