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.Sun, 31 Jan 2016 11:35:22 +0100Where is information passed on to var() stored?https://ask.sagemath.org/question/32357/where-is-information-passed-on-to-var-stored/ We can link additional information to expressions defined by var(), such as the domain or latex expression, e.g.
> sage: var('xt1',domain = real,latex_name = 'x_{t1}')
Where is this information stored and is there a way to modify it, e.g. change the domain or latex_name without having to redefine the expression?Thu, 28 Jan 2016 15:38:07 +0100https://ask.sagemath.org/question/32357/where-is-information-passed-on-to-var-stored/Answer by Volker Braun for <p>We can link additional information to expressions defined by var(), such as the domain or latex expression, e.g.</p>
<blockquote>
<p>sage: var('xt1',domain = real,latex_name = 'x_{t1}')</p>
</blockquote>
<p>Where is this information stored and is there a way to modify it, e.g. change the domain or latex_name without having to redefine the expression?</p>
https://ask.sagemath.org/question/32357/where-is-information-passed-on-to-var-stored/?answer=32388#post-id-32388Pynac/ginac tracks latex_name, so its a bit tricky to get at it.
The assumptions (like domain="real") are tracked in Sage:
sage: var('xt1', domain='real')
xt1
sage: assumptions(xt1)
[xt1 is real]
sage: forget(xt1, 'real')
sage: assumptions(xt1)
[]
sage: assume(xt1 > 0)
Sat, 30 Jan 2016 22:31:43 +0100https://ask.sagemath.org/question/32357/where-is-information-passed-on-to-var-stored/?answer=32388#post-id-32388Answer by ndomes for <p>We can link additional information to expressions defined by var(), such as the domain or latex expression, e.g.</p>
<blockquote>
<p>sage: var('xt1',domain = real,latex_name = 'x_{t1}')</p>
</blockquote>
<p>Where is this information stored and is there a way to modify it, e.g. change the domain or latex_name without having to redefine the expression?</p>
https://ask.sagemath.org/question/32357/where-is-information-passed-on-to-var-stored/?answer=32399#post-id-32399 var('xt1',latex_name='x_{t1}')
pretty_print(xt1)
f = xt1^2 + 4
print f._latex_(); pretty_print(f) # defining f creates a latex_name of f
var('xt1',latex_name='{xt}_1')
pretty_print(xt1)
print f._latex_(); pretty_print(f) # redefining xt1 does not change the latex_name of f
f = f.subs(xt1=xt1)
print f._latex_(); pretty_print(f) # the substitution rewrites the latex_name of f Sun, 31 Jan 2016 11:35:22 +0100https://ask.sagemath.org/question/32357/where-is-information-passed-on-to-var-stored/?answer=32399#post-id-32399