I'm using Sagemath / Cocalc (feel free to run it in your browser, no sign-up no nothing required). As far as I understand, Sagemath is just a library on top of Python and the Sagemath notebook implicitly imports many things from the Sagemath library.
What puzzles me though is the following syntax:
R.<x,y> = AA[]
I = R.ideal(x^2 * y - 18,x * y^3 - 24, x * y - 6)
I.variety()
(This solves the system of polynomials x^2 * y - 18=0, x * y^3 - 24=, x * y - 6=0
, and returns x=2,y=3
, nice!)
Running type(AA)
, I see that it is
<class 'sage.rings.qqbar.AlgebraicRealField_with_category'>.
Running type(R)
, I see that it is
<class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain_with_category'>
Ok, b what does it mean in Python to use brackets []
at a class, i.e. AA[]
?
What does it mean, in Python's syntax, to do R.<x,y>
? Mind you, I haven't defined previously x
and y
as strings or anything, so this syntax seems very weird to me.
SageMath is built on top of Python, but it preparses input, and this is an example. Within SageMath:
sage: preparse('R.<x,y> = AA[]')
"R = AA['x, y']; (x, y,) = R._first_ngens(2)"
preparse
command tells you how Sage will convert the string before evaluating it as standard Python.__getitem__
method (which is what gets called when you do AA[args]
) for rings like AA
creates a polynomial ring with the named generators.R.<x,y> = AA[]
creates a polynomial ring, and also defines R
, x
, and y
as the ring and its two generators.You can achieve the same thing by R.<x,y> = PolynomialRing(AA)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With