I have a multivariate polynomial and want to keep only up to a certain degree. I already know how to do this for the univariate case.For 1 variable, I'd do:
R.<x> = PolynomialRing(QQ)
f = x^4 + x^2 + x^3 + x + 1
f = f + O(x^3)
print f
#output would be 1 + x + x^2... which is what I want.
How do I do this for a multivariate polynomial? It says O(.) is not defined...
R.<x,y> = PolynomialRing(QQ)
f = x^3*y^3 + x^2 * y^4 + x*y + x + y + 1
How can I chop this polynomial up to a certain degree of x and y? I.e. I want to keep up until the second degree of x only (regardless of y).
I know one way I could go about this is to just redefine the polynomial by looping through the first few coefficients, but I'm looking for a more efficient/easier way.
Thanks!