ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 07 May 2017 11:02:10 -0500remove values from variables but keep variableshttp://ask.sagemath.org/question/37534/remove-values-from-variables-but-keep-variables/ How do I remove the values from variables but keep the variables. i.e. if x is defined and equal to 5, and I reset() I just get x as undefined if I try to use it in a symbolic equation. I just want to remove the 5 but keep the x.Sun, 07 May 2017 09:27:33 -0500http://ask.sagemath.org/question/37534/remove-values-from-variables-but-keep-variables/Answer by tmonteil for <p>How do I remove the values from variables but keep the variables. i.e. if x is defined and equal to 5, and I reset() I just get x as undefined if I try to use it in a symbolic equation. I just want to remove the 5 but keep the x.</p>
http://ask.sagemath.org/question/37534/remove-values-from-variables-but-keep-variables/?answer=37535#post-id-37535You 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](https://ask.sagemath.org/questions/scope:all/sort:activity-desc/tags:variable_issue/page:1/), [this question](https://ask.sagemath.org/question/37057/evaluating-symbolic-expression-when-some-variables-are-finally-fixed/?answer=37061#post-id-37061) or [that question](https://ask.sagemath.org/question/37158/why-can-you-expand-with-one-unknown-but-not-more/).Sun, 07 May 2017 11:02:10 -0500http://ask.sagemath.org/question/37534/remove-values-from-variables-but-keep-variables/?answer=37535#post-id-37535