-1

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 = 2*a15*a16 + 2*a13*a17 + 2*a13*a18 +1849

etc

I have

print(a)

a.subs(L)

print(a)

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.

Thanks.

Edit: Example code

I will write out some of my code + outputs:

print L

while k <= i[0].degree(t):

a = i[0].coefficient({t:k})
print a
b = a.subs(L)
print b

Don't understand why there is an extra box, but hopefully this makes sense.

An example of Outputs:

[a13 == a10, a13 == a11, a15 == a12, a16 == a7, a17 == a8, a18 == a9]

1

1

1

1

2*a15*16 + 2*a14*a17+2*a13*a13 + 1849

2*a15*16 + 2*a14*a17+2*a13*a13 + 1849

Hope this helps

Anom
  • 1
  • 1
  • Please review this for best results using this site. [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve) – Neo Feb 27 '17 at 18:31
  • Cross-posted at https://ask.sagemath.org/question/36748/issues-with-substitution/ – kcrisman Feb 27 '17 at 19:10

1 Answers1

0

I think that what you are missing is that a.subs(input) is not intended to modify a - presumably so that one may do it many times. Why not try this:

b = a.subs(L)
print b
kcrisman
  • 4,374
  • 20
  • 41
  • Thanks, I just modified it to a = a.subs(L). But still had no luck. From a rudimentary check doing a = var('a') b = var('b') L = a+b L.substitute(a == 5) print L This does the substitution for L. Edit: I ran this and I take it back - I ran it and got different results from what I expected. In my example s.subs you are right does not change s. – Anom Feb 27 '17 at 21:32
  • I will write out some of my code + outputs: print L while k <= i[0].degree(t): a = i[0].coefficient({t:k}) – Anom Feb 27 '17 at 21:44