1 | initial version |

`P.subs()`

should work only for the variables of the polynomials, ie. `x`

and `y`

.
`a`

is a not a polynomial variable but rather a parameter, which polynomial coefficients depend on. Hence, you need to perform symbolic substitution in each of the coefficients. For example, this will do the job:

```
R.<x, y> = SR[]
a = SR.var('a')
P = a*x
print( sum(map(lambda t: t[0].subs({a:1})*t[1], P)) )
```

2 | No.2 Revision |

`P.subs()`

should work only for the variables of the polynomials, ie. `x`

and `y`

.
`a`

is a not a polynomial variable but rather a parameter, which polynomial coefficients depend on. Hence, you need to perform symbolic substitution in each of the coefficients. For example, this will do the job:

```
R.<x, y> = SR[]
a = SR.var('a')
P = a*x
print( sum(map(lambda t: t[0].subs({a:1})*t[1], P)) )
```

or (as suggested by @achrzesz):

```
print( P.map_coefficients(lambda t: t.subs({a:1})) )
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.