Processing math: 100%
Ask Your Question
2

Diamond brackets <> and square brackets [] notations

asked 5 years ago

petRUShka gravatar image

updated 5 years ago

Are there some documentation on diamond bracket notation:

R.<w> = PolynomialRing(QQ)

and square bracket notation:

R.<y> = QQ['y'];

There is some documentation in Constructors for polynomial rings docs but it looks superficial on this topic.

Are there some complete explanation with all the details behind the scene?

Is it only for polynomial rings or for some other objects? Is it SageMath addition?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 5 years ago

Sébastien gravatar image

updated 5 years ago

Indeed, this is not Python syntax, it is SageMath syntax only. Sage preparses this notation and turns it into Python code:

sage: preparse('R.<w> = PolynomialRing(QQ)')
"R = PolynomialRing(QQ, names=('w',)); (w,) = R._first_ngens(1)"

Other examples include:

sage: preparse('2/3')
'Integer(2)/Integer(3)'
sage: preparse('2./3')
"RealNumber('2.')/Integer(3)"
sage: preparse('x^x')
'x**x'

Also, this turns off/on the preparser:

sage: preparser(False)
sage: preparser(True)
Preview: (hide)
link

Comments

1

Note that this does not exactly answers the question which started with "Are there some documentation ..."

vdelecroix gravatar imagevdelecroix ( 5 years ago )

The relevant documentation is for the function preparse_generators: http://doc.sagemath.org/html/en/refer.... There are more examples (labeled as "TESTS") which are in the code but not the reference manual.

John Palmieri gravatar imageJohn Palmieri ( 5 years ago )
3

Some documentation on that syntax can also be found in the section on A Guided tour on Polynomial of the Tutorial of SageMath at http://doc.sagemath.org/html/en/tutor... But it is true that some clearer documentation on this syntax could be explained on its own chapter somewhere.

Sébastien gravatar imageSébastien ( 5 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 5 years ago

Seen: 3,425 times

Last updated: Apr 06 '20