Hi.

On Jul 17, 2010, at 8:42 AM, jay wrote:

> i'm new to sympy
> for predefined equation,assigning new values to variables(symbols) in
> equation,do not changes value of equation.
> how can i assign new values to variables and get appropriate value of
> equation and not the older one?

See 
http://docs.sympy.org/gotchas.html#variables-assignment-does-not-create-a-relation-between-expressions.

Basically, SymPy variables and expressions are immutable, so once you create 
them, they are frozen as you first created them, no matter what you then do to 
the objects you used to create them.  

If you just want to replace a variable in an expression, use .subs():

In [1]: a = x**2 + y

In [2]: a
Out[2]: 
     2
y + x 

In [3]: a.subs(x, 2*x)
Out[3]: 
       2
y + 4⋅x 

If you want the expression to change all the time, the easiest way to get 
around this is to define a Python function that returns the expression you 
want.  Then, call that function whenever you need the expression (see the page 
I linked to above for an example).

Aaron Meurer

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to