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.Wed, 05 Jun 2013 16:45:40 +0200How can I find out the name of some variable?https://ask.sagemath.org/question/10183/how-can-i-find-out-the-name-of-some-variable/Hello!
For example I have variable p in sage notebook. I need my class can find out the name of variable:
sage: p = 3
sage: my_class(p)
ans: 'p'
How to implement this feature? Thanks.
P.S.: sorry if my english isn't good.AndreWinWed, 05 Jun 2013 16:45:40 +0200https://ask.sagemath.org/question/10183/Is there a way to update an expression with new variable values?https://ask.sagemath.org/question/10087/is-there-a-way-to-update-an-expression-with-new-variable-values/Is there a way to update an expression if the symbolic variables that it contains have been overwritten? For example,
sage: var('beta')
beta
sage: eq = x == beta
sage: beta = 1
sage: eq
x == beta
Is there a way for it to change to `x == 1`? I wrote the following function to do this, but I wanted to know if something similar existed already.
def update(expr):
return expr.subs(dict(zip(expr.variables(), map(lambda v:eval(str(v)), expr.variables()))))Eviatar BachFri, 03 May 2013 20:02:11 +0200https://ask.sagemath.org/question/10087/Variable not foundhttps://ask.sagemath.org/question/9009/variable-not-found/Hi, why does this snippet produces "variable 'a' not found"?
I looked all over and I just can't figure it out.
var('a');
var('x y z');
x = cos(a)^3;
y = sin(a)^3;
z = cos(2*a);
pl1=parametric_plot3d( (cos(t)^3, sin(t)^3, cos(2*t)), (t, 0, 2*pi));
a = pi/4;
pl2=parametric_plot3d( (x + t*(derivative(x)), y + t * (derivative(y)), z + t * (derivative(z))), (t,0,1), texture="red");dnizeticMon, 28 May 2012 03:36:57 +0200https://ask.sagemath.org/question/9009/