| 1 | initial version |
If you matrices have polynomial entries, a possible approach is to define a polynomial ring in all variables but p, and the power series ring in p over that ring like:
R.<a11,a12,a13> = PolynomialRing(QQ)
P.<p> = PowerSeriesRing(R,default_prec=2)
Then to ignore the powers p^2 and higher, one can add O(p^2} and convert the result to polynomial if needed:
f = a11 + a12*p + a13*p^2
f += O(p^2)
print(f)
print(f.polynomial())
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.