| 1 | initial version |
For a symbolic approach you can use a substitution with a wildcard:
sage: var('p,a')
sage: f = (a*p+1)^2
sage: w0 = SR.wild()
sage: f.expand().subs({p^w0 : 0})
2*a*p + 1
This makes use of the fact that p^1 does not appear in an expanded symbolic expression.
Using a different ring would probably be more efficient, though.
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.