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, 09 Sep 2018 05:08:52 -0500Printing _sage_var_x instead of xhttp://ask.sagemath.org/question/43616/printing-_sage_var_x-instead-of-x/Following the section "symbolic maths" in the quickstar of sagemath's web page
I put
sage: f=1-sin(x)^2
If I write Print(f) it works fine, but when I do the "pretty printing" :
sage: print(maxima(f))
I get
1-sin²(_SAGE_VAR_x)
instead of $$1-sin²(x)$$
which the quickstart says I should get. Why I am printing "_sage_var_x" and how can I replace it by just $x$?Fri, 07 Sep 2018 18:53:34 -0500http://ask.sagemath.org/question/43616/printing-_sage_var_x-instead-of-x/Answer by eric_g for <p>Following the section "symbolic maths" in the quickstar of sagemath's web page
I put </p>
<p>sage: f=1-sin(x)^2</p>
<p>If I write Print(f) it works fine, but when I do the "pretty printing" :</p>
<p>sage: print(maxima(f))</p>
<p>I get </p>
<p>1-sin²(_SAGE_VAR_x)</p>
<p>instead of $$1-sin²(x)$$</p>
<p>which the quickstart says I should get. Why I am printing "_sage_var_x" and how can I replace it by just $x$?</p>
http://ask.sagemath.org/question/43616/printing-_sage_var_x-instead-of-x/?answer=43623#post-id-43623Thanks for reporting this! Indeed the documentation at http://www.sagemath.org/tour-quickstart.html is obsolete and should be fixed (I've opened [issue #151](https://github.com/sagemath/website/issues/151) for it). As for the reason why you get `_SAGE_VAR_x` now, see the explanation in @nbruin 's answer.
To get the pretty printing in console mode, simply use the magic command `%display ascii_art`:
sage: %display ascii_art
sage: f = 1 - sin(x)^2
sage: f
2
- sin (x) + 1
Note that you can use LaTeX typeset display by `%display latex`:
sage: %display latex
sage: f
\newcommand{\Bold}[1]{\mathbf{#1}}-\sin\left(x\right)^{2} + 1
However, this display mode is more adapted to the Jupyter notebook: there you really get the typeset display (see e.g. [here](http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM_Euclidean_plane.ipynb) for some example), not the raw LaTeX code.
NB: for an up-to-date quick start guide, see the Chapter *First Steps* of the recent free book [Computational Mathematics with SageMath](http://sagebook.gforge.inria.fr/english.html).Sun, 09 Sep 2018 05:08:52 -0500http://ask.sagemath.org/question/43616/printing-_sage_var_x-instead-of-x/?answer=43623#post-id-43623Answer by nbruin for <p>Following the section "symbolic maths" in the quickstar of sagemath's web page
I put </p>
<p>sage: f=1-sin(x)^2</p>
<p>If I write Print(f) it works fine, but when I do the "pretty printing" :</p>
<p>sage: print(maxima(f))</p>
<p>I get </p>
<p>1-sin²(_SAGE_VAR_x)</p>
<p>instead of $$1-sin²(x)$$</p>
<p>which the quickstart says I should get. Why I am printing "_sage_var_x" and how can I replace it by just $x$?</p>
http://ask.sagemath.org/question/43616/printing-_sage_var_x-instead-of-x/?answer=43621#post-id-43621This is because in sage the following is legal (but probably ill-advised): `sin(SR.symbol('sin'))`. With the `_SAGE_VAR_` prefix, this translates into an expression in maxima that roughly captures the same meaning. Without it, you get a maxima expression that means something else.
You can create expressions like `sin(maxima('x'))`, but if you want expressions to go back and forth between maxima and sage, it's better to stick with the prefixes that sage uses.Sat, 08 Sep 2018 11:39:33 -0500http://ask.sagemath.org/question/43616/printing-_sage_var_x-instead-of-x/?answer=43621#post-id-43621