Ask Your Question

Issues with substitution

asked 2017-02-27 11:42:00 -0500

Anom gravatar image

I have a list L = [a13 == a10, a14 == a11, a15 == a12, a16 == a7, a17 == a8, a18 == a9]

I then have a running through a loop giving it these values

a = 1

a = 2a15a16 + 2a13a17 + 2a13a18 +1849


I have




and it indicates no change, but I would of thought/ expected substitution to of taken place. Maybe I am being idiot, but please tell me where. I also posted this on stack overflow, sorry if I am not meant to post on both.


edit retag flag offensive close merge delete


Cross-posted at (which is fine, by the way).

kcrisman gravatar imagekcrisman ( 2017-02-27 13:10:37 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-02-28 03:03:25 -0500

ndomes gravatar image

This works as expected:

V = [var("a{}".format(k)) for k in [7..18]]
L = [a13 == a10, a14 == a11, a15 == a12, a16 == a7, a17 == a8, a18 == a9]
a = 2*a15*a16 + 2*a13*a17 + 2*a13*a18 + 1849 
print a
b = a.subs(L)
print b

Please note: a.subs(L) does not change a in place.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2017-02-27 11:33:19 -0500

Seen: 51 times

Last updated: Feb 28