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.Tue, 08 Oct 2013 12:33:02 +0200Difference Between Constants and Variableshttps://ask.sagemath.org/question/10583/difference-between-constants-and-variables/Hello all. I'm working with variational calculus in sage and working with
complicate expression `F` of a lot of variables declared with `var`.
I used `var` to declare both variables and constants. My problem is that I have
to know the exact number of variables which some generic expression depends. By
this reason the member function `variables` of an expression does not work, i.e.,
it returs both variables and constants because them was declared with `var` function.
I'm wondering if there is some type of variable in sage that can act as a variable to construct an expression and don't be returned by the `variables` member function.Rafael RojasTue, 08 Oct 2013 12:33:02 +0200https://ask.sagemath.org/question/10583/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/