开发者

how to assign new values to variables in predefined equation?

开发者 https://www.devze.com 2023-01-07 12:59 出处:网络
for predefined equations,assigning new values 开发者_JS百科to variables do not changes value of equation.

for predefined equations,assigning new values 开发者_JS百科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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消