# 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$?

edit retag close merge delete

Sort by » oldest newest most voted

This 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.

more

Thanks for reporting this! Indeed the documentation at http://www.sagemath.org/tour-quicksta... is obsolete and should be fixed (I've opened issue #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 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.

more