Ask Your Question

# Revision history [back]

You are confusing two very different notions of "variable".

When you write:

sage: x = 5


The Python name points to the integer 5.

When you write:

 sage:  reset()


or just

 sage: del(x)


you remove the name x from the namespace.

In the symbolic expression cos(x), the x is not a Python name but a mathematical symbol, it is an object, like the integer 5 above.

The confusion might come from the fact that, at Sage startup, the Python name x points to the symbol x:

sage: x
x
sage: x.parent()
Symbolic Ring
sage: x.is_symbol()
True


But once you write x=5, the Python name x now points to the integer 5, and there is no way to let it remember that it used to point to the symbol x. If you want the Python x to point to the symbol x, you can do:

sage: x = SR.var("x")


See for example this question or that question.

You are confusing two very different notions of "variable".

When you write:

sage: x = 5


The Python name points to the integer 5.

When you write:

 sage:  reset()


or just

 sage: del(x)


you remove the name x from the namespace.

In the symbolic expression cos(x), the x is not a Python name but a mathematical symbol, it is an object, like the integer 5 above.

The confusion might come from the fact that, at Sage startup, the Python name x points to the symbol x:

sage: x
x
sage: x.parent()
Symbolic Ring
sage: x.is_symbol()
True


But once you write x=5, the Python name x now points to the integer 5, and there is no way to let it remember that it used to point to the symbol x. If you want the Python x to point to the symbol x, you can do:

sage: x = SR.var("x")


See for example This is a very common confusion, see the tag variable_issue, this question or that question.

You are confusing two very different notions of "variable".

When you write:

sage: x = 5


The Python name points to the integer 5.

When you write:

 sage:  reset()


or just

 sage: del(x)


you remove the name x from the global namespace.

In the symbolic expression cos(x), the x is not a Python name but a mathematical symbol, it is an object, like the integer 5 above.

The confusion might come from the fact that, at Sage startup, the Python name x points to the symbol x:

sage: x
x
sage: x.parent()
Symbolic Ring
sage: x.is_symbol()
True


But once you write x=5, the Python name x now points to the integer 5, and there is no way to let it remember that it used to point to the symbol x. If you want the Python x to point to the symbol x, again, you can do:

sage: x = SR.var("x")


This is a very common confusion, see the tag variable_issue, this question or that question.