Ask Your Question

Is the R interface identical to R in a R.<x> assignment?

asked 2015-06-19 20:48:51 +0200

candide gravatar image

updated 2015-06-19 20:49:18 +0200

R is a builtin identifier in Sage and refers to the r interface :

sage: R
sage: r
R Interpreter

Now I was wondering if the later R is related to the R letter used in a left hand side assignment for instance :

R.<x> = ZZ[]
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-19 21:29:27 +0200

kcrisman gravatar image

There is absolutely no connection whatsoever. It's coincidence that "rings" starts with "R" and so do the names of the original two developers of the R language (if you believe CRAN's FAQ, though Ihaka's musings on the history of R lend it credence).

In fact, using R.<x> will automatically reassign R to that ring, rather than to the R interface, so you won't have both at the same time (though it is easy to get the interface back).

edit flag offensive delete link more


It would be worth learning a bit of Python syntax if you are going to use Sage - in particular, identifiers belong to whatever you assign them to, which can change any time you assign them to something else.

kcrisman gravatar imagekcrisman ( 2015-06-19 21:31:01 +0200 )edit

Thanks, I didn't realize that the R.<x> assignment rebinds R to a polynomial ring. But, as you can check, the docs misleadingly build polynomial ring generator with the syntax R.<some_id>, (nearly) always with the R name in such a way I thought that the letter R was mandatory. This is not true since S.<x> is valid and create a new binding from S to a polynomial ring. In fact, what your response just explains is the non-negligible difference between Python syntax and Sage syntax (I imagine, due to the Sage preprocessor). In Python, R.<x> raises a syntax error. And worse, in Python R.attr always refers to an R attribute (not the case here with Sage) and doesn't bind or rebind R. I consider the R.<x> as an unfortunate choice (the is no attribute setting) and R<x> would have been clearer.

candide gravatar imagecandide ( 2015-06-19 23:05:09 +0200 )edit

The rationale is that some other programs offered this syntax, so it was enabled (long, long ago) to make it easy to migrate. Most users of Magma are unlikely to be also needing R :)

kcrisman gravatar imagekcrisman ( 2015-06-20 15:36:35 +0200 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2015-06-19 20:48:51 +0200

Seen: 281 times

Last updated: Jun 19 '15