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.Wed, 19 Jan 2011 12:53:57 -0600Problem with supercriptshttp://ask.sagemath.org/question/7872/problem-with-supercripts/I've read that variables can be subscripted with underscore "_" and superscripted with caret "^". However supescripting doesn't seem to work. I think the caret is seen as a power operator. How to work around this?
Subscript example that works:
var('x,y,z_a')
eqn = x == y*z_a
solve(eqn, z_a)
Superscript example that fails:
var('x,y,z^a')
eqn = x == y*z^a
solve(eqn, z^a)
Wed, 19 Jan 2011 12:01:36 -0600http://ask.sagemath.org/question/7872/problem-with-supercripts/Comment by kcrisman for <p>I've read that variables can be subscripted with underscore "_" and superscripted with caret "^". However supescripting doesn't seem to work. I think the caret is seen as a power operator. How to work around this?</p>
<p>Subscript example that works:</p>
<pre><code>var('x,y,z_a')
eqn = x == y*z_a
solve(eqn, z_a)
</code></pre>
<p>Superscript example that fails:</p>
<pre><code>var('x,y,z^a')
eqn = x == y*z^a
solve(eqn, z^a)
</code></pre>
http://ask.sagemath.org/question/7872/problem-with-supercripts/?comment=22263#post-id-22263Can you let us know where you found that in documentation? That would help us answer this. Caret does indeed mean power, pretty much always in Sage (this is a custom preparsing of Python, where that has a different meaning).Wed, 19 Jan 2011 12:49:39 -0600http://ask.sagemath.org/question/7872/problem-with-supercripts/?comment=22263#post-id-22263Answer by cswiercz for <p>I've read that variables can be subscripted with underscore "_" and superscripted with caret "^". However supescripting doesn't seem to work. I think the caret is seen as a power operator. How to work around this?</p>
<p>Subscript example that works:</p>
<pre><code>var('x,y,z_a')
eqn = x == y*z_a
solve(eqn, z_a)
</code></pre>
<p>Superscript example that fails:</p>
<pre><code>var('x,y,z^a')
eqn = x == y*z^a
solve(eqn, z^a)
</code></pre>
http://ask.sagemath.org/question/7872/problem-with-supercripts/?answer=11997#post-id-11997Although underscores can be used to define new variables
sage: var('x,y,z_a')
(x, y, z_a)
sage: z_a
z_a
"carrots" cannot be used
sage: var('x,y,z^a')
(x, y, z^a)
sage: z^a
Traceback (click to the left of this block for traceback)
...
NameError: name 'z' is not defined
This is because in that last statement, `z^a`, Sage is looking for a variable called `z` and trying to exponentiate it with some other variable called `a`. Note that the symbol `^` is used in Sage for exponentiation. In short, you shouldn't use it to define a new variable.Wed, 19 Jan 2011 12:53:57 -0600http://ask.sagemath.org/question/7872/problem-with-supercripts/?answer=11997#post-id-11997