ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 03 Jan 2013 09:42:17 +0100Which variables are automagically defined in the sage shell?https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/I'm using the sage-5.5 command line and some variables are automatically declared. For instance I can do
f = x^2
but not
f = t^2
My question: How does this come about? Which variables are defined like this? Where is this documented?
Thu, 03 Jan 2013 08:21:01 +0100https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/Answer by kcrisman for <p>I'm using the sage-5.5 command line and some variables are automatically declared. For instance I can do </p>
<pre><code>f = x^2
</code></pre>
<p>but not </p>
<pre><code>f = t^2
</code></pre>
<p>My question: How does this come about? Which variables are defined like this? Where is this documented?</p>
https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?answer=14419#post-id-14419See [sage/all.py](http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all.py#l1) and [sage/all_cmdline.py](http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all_cmdline.py#l1) in the devel/sage directory. In addition to `x`, we define `oo` to be infinity, `e` to be the base of the natural log, `i` to be a certain root of $x^2-1=0$, `ZZ` to be the integers, and some other things - and of course lots and lots of functions.Thu, 03 Jan 2013 08:47:58 +0100https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?answer=14419#post-id-14419Comment by kcrisman for <p>See <a href="http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all.py#l1">sage/all.py</a> and <a href="http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all_cmdline.py#l1">sage/all_cmdline.py</a> in the devel/sage directory. In addition to <code>x</code>, we define <code>oo</code> to be infinity, <code>e</code> to be the base of the natural log, <code>i</code> to be a certain root of $x^2-1=0$, <code>ZZ</code> to be the integers, and some other things - and of course lots and lots of functions.</p>
https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?comment=18450#post-id-18450You could also do `globals()` to find everything at all, but I don't think that is what you meant.Thu, 03 Jan 2013 08:49:09 +0100https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?comment=18450#post-id-18450Comment by Thomas for <p>See <a href="http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all.py#l1">sage/all.py</a> and <a href="http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all_cmdline.py#l1">sage/all_cmdline.py</a> in the devel/sage directory. In addition to <code>x</code>, we define <code>oo</code> to be infinity, <code>e</code> to be the base of the natural log, <code>i</code> to be a certain root of $x^2-1=0$, <code>ZZ</code> to be the integers, and some other things - and of course lots and lots of functions.</p>
https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?comment=18448#post-id-18448First I was not convinced since in sage/all.py the line defining x is commented out (both, in your linked version and in the file on my disk), but then I saw that it comes from the line "from sage.calculus.predefined import x" in all_cmdline.py. Thanks.Thu, 03 Jan 2013 09:42:17 +0100https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?comment=18448#post-id-18448Comment by Thomas for <p>See <a href="http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all.py#l1">sage/all.py</a> and <a href="http://hg.sagemath.org/sage-main/file/9519a7bb2f42/sage/all_cmdline.py#l1">sage/all_cmdline.py</a> in the devel/sage directory. In addition to <code>x</code>, we define <code>oo</code> to be infinity, <code>e</code> to be the base of the natural log, <code>i</code> to be a certain root of $x^2-1=0$, <code>ZZ</code> to be the integers, and some other things - and of course lots and lots of functions.</p>
https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?comment=18449#post-id-18449Interesting effect: Type "globals()" in a session where you have done 'a few' plots before.Thu, 03 Jan 2013 09:37:50 +0100https://ask.sagemath.org/question/9665/which-variables-are-automagically-defined-in-the-sage-shell/?comment=18449#post-id-18449