# Variables r and R are gobbled

If implicit multiplication is not active, something like 4y^2 should raise an error. This is what actually happens:

sage: var("y"); 4y^2
File "<ipython-input-22-25bcbc82148c>", line 1
var("y"); 4y**Integer(2)
^
SyntaxError: invalid syntax


If we replace y by a different variable or consider a similar expression, we also get an error... except if the variable is r or R. For example,

sage: var("r, R"); 4r^2, 3R + 5r + 2R^3
(16, 16)


Surprisingly, there is no error. Variables r and R seem to be gobbled, so that SageMath parses 4r^2 as 4**Integer(2) and 3R + 5r + 2R^3 as 3 + 5 + 2**Integer(3). Why? Is this a bug?

edit retag close merge delete

Sort by » oldest newest most voted

r means raw python integer

more

1

Many thanks. I now understand. This is a source of potential problems, as happened to some of my students. They inadvertently did a wrong computation, like integral(sqrt(1+4r^2), r, 0, 1), and so failed an exercise.

( 2020-06-23 11:49:40 +0200 )edit