Ask Your Question

Revision history [back]

At startup, Sage import some things into the namespace. For example, the python name I points to the symbolic imaginary number. Here, the python name x points to the symbol "x":

sage: I
I
sage: I^2
-1
sage: I.parent()
Symbolic Ring
sage: x
x
sage: x^2
x^2
sage: x.parent()
Symbolic Ring

But the python variable is not defined. You can define it as:

sage: y = SR.var('y')
sage: y
y
sage: y^2
y^2

If you want to have this defined at Sage startup, you can add y = SR.var('y') in your ~/.sageinit.sage.

If you want Sage to do this by default, then the question will be "where to stop ?", should we also define z,s,t?

Note the following trick, which only works on the Sage notebook (soon deprecated), will define the undefined Python variables on the fly to point to the symbol with the same name:

sage: automatic_names(True)
sage: x + y + z
x + y + z

At startup, Sage import imports some things into the namespace. For example, the python name I points to the symbolic imaginary number. Here, the python name x points to the symbol "x":

sage: I
I
sage: I^2
-1
sage: I.parent()
Symbolic Ring
sage: x
x
sage: x^2
x^2
sage: x.parent()
Symbolic Ring

But the python variable is not defined. You can define it as:

sage: y = SR.var('y')
sage: y
y
sage: y^2
y^2

If you want to have this defined at Sage startup, you can add y = SR.var('y') in your ~/.sageinit.sage.

If you want Sage to do this by default, then the question will be "where to stop ?", should we also define z,s,t?

Note the following trick, which only works on the Sage notebook (soon deprecated), will define the undefined Python variables on the fly to point to the symbol with the same name:

sage: automatic_names(True)
sage: x + y + z
x + y + z

At To complement @kcrisman anser, tt startup, Sage imports some things into the namespace. For example, the python name I points to the symbolic imaginary number. Here, the python name x points to the symbol "x":

sage: I
I
sage: I^2
-1
sage: I.parent()
Symbolic Ring
sage: x
x
sage: x^2
x^2
sage: x.parent()
Symbolic Ring

But the python variable is not defined. You can define it as:

sage: y = SR.var('y')
sage: y
y
sage: y^2
y^2

If you want to have this defined at Sage startup, you can add y = SR.var('y') in your ~/.sageinit.sage.

If you want Sage to do this by default, then the question will be "where to stop ?", should we also define z,s,t?

Note the following trick, which only works on the Sage notebook (soon deprecated), will define the undefined Python variables on the fly to point to the symbol with the same name:

sage: automatic_names(True)
sage: x + y + z
x + y + z

To complement @kcrisman anser, answer, tt startup, Sage imports some things into the namespace. For example, the python name I points to the symbolic imaginary number. Here, the python name x points to the symbol "x":

sage: I
I
sage: I^2
-1
sage: I.parent()
Symbolic Ring
sage: x
x
sage: x^2
x^2
sage: x.parent()
Symbolic Ring

But the python variable is not defined. You can define it as:

sage: y = SR.var('y')
sage: y
y
sage: y^2
y^2

If you want to have this defined at Sage startup, you can add y = SR.var('y') in your ~/.sageinit.sage.

If you want Sage to do this by default, then the question will be "where to stop ?", should we also define z,s,t?

Note the following trick, which only works on the Sage notebook (soon deprecated), will define the undefined Python variables on the fly to point to the symbol with the same name:

sage: automatic_names(True)
sage: x + y + z
x + y + z