views:

47

answers:

1

for predefined equations,assigning new values to variables do not changes value of equation. how can i assign new values to variables so that i will get appropriate value of equation and not the previous one

a,b,c,d,e,f=sympy.symbols('abcdef')
a,b=c,d

e=a+b #equation 
print e
c+d #value of eqn
a,b=d,f
print e
c+d  #not d+f
+1  A: 

Perhaps use substitution instead of equality:

import sympy
a,b,c,d,e,f=sympy.symbols('abcdef')
e=a+b #equation 
print e.subs([(a,c),(b,d)])
# c + d
print e.subs([(a,d),(b,f)])
# d + f
unutbu
getting thisTypeError: 'instancemethod' object is not subscriptable
The code above works fine on my end: sympy 0.6.5, python 2.5
ars
thanx! it was not working due to my syntax mistake