Hi! On 2013-06-04, Sam math <hes...@gmail.com> wrote: > 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 guess it depends on your application. If you *absolutely* need O(...), and if your *really* want to bound only the x-degree and keep y untouched, then you could define f as a *univariate* polynomial in x over a polynomial ring in y: sage: f = x^3*y^3 + x^2 * y^4 + x*y + x + y + 1 sage: f y^3*x^3 + y^4*x^2 + (y + 1)*x + y + 1 sage: f + O(x^2) y + 1 + (y + 1)*x + O(x^2) Be warned, however, that arithmetic in a polynomial ring over a polynomial ring will be dramatically slower than in a multi-variate polynomial ring: sage: R2.<x,y> = QQ[] sage: g = x^3*y^3 + x^2 * y^4 + x*y + x + y + 1 sage: type(f) sage.rings.polynomial.polynomial_element.Polynomial_generic_dense sage: type(g) sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular sage: %timeit f*f 10000 loops, best of 3: 128 us per loop sage: %timeit g*g 100000 loops, best of 3: 3.57 us per loop sage: %timeit f+f 100000 loops, best of 3: 3.15 us per loop sage: %timeit g+g 1000000 loops, best of 3: 1.47 us per loop Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.