Kernel: SageMath 6.10
Sage Days 74
Introduction
Sage comes with a lot of rings and fields that are at the basis of mathematical structures:
In [1]:
(Integer Ring,
Rational Field,
Real Double Field,
Real Field with 53 bits of precision,
Complex Double Field,
Complex Field with 53 bits of precision,
Algebraic Real Field,
Finite Field in z2 of size 5^2,
5-adic Ring with capped relative precision 20,
5-adic Field with capped relative precision 20,
Universal Cyclotomic Field,
Univariate Polynomial Ring in x over Rational Field,
Power Series Ring in x over Rational Field,
Symbolic Ring)
We say that the ring is the parent of the ring elements. In interactive use you use the parent to construct elements:
In [45]:
(1, 0)
In [35]:
(1, Integer Ring)
How do these work together?
First, explicit conversion:
In [43]:
1.0
In [2]:
The preparser uses explicit conversion for Python -> Sage types:
In [73]:
"Integer(1), Integer(2), RealNumber('3.0')"
Ok for computer programming, but interactively we want to be able to write
In [47]:
3/2
In [46]:
Rational Field
Coercion
This is called coercion in Sage. It only depends on the operation and the parents of the operands:
In [48]:
Coercion on left operand via
Natural morphism:
From: Integer Ring
To: Rational Field
Arithmetic performed after coercions.
Result lives in Rational Field
Rational Field
In [56]:
Natural morphism:
From: Integer Ring
To: Rational Field
Even though coercion doesn't depend on the element, they can be used as arguments instead of their parent:
In [65]:
Coercion on left operand via
Conversion map:
From: Integer Ring
To: The Infinity Ring
Arithmetic performed after coercions.
Result lives in The Infinity Ring
The Infinity Ring
In [66]:
(A positive finite number, +Infinity)
In [ ]:
In [ ]:
Further topics
Attach
Git log
Development workflow