ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 27 Sep 2011 23:01:41 +0200Find polynomial in terms of idealhttps://ask.sagemath.org/question/8346/find-polynomial-in-terms-of-ideal/Hi,
I have been reading the tutorials and experimenting with the polynomial ring code but I have not been able to find out how to express a given polynomial in terms of the generators of an ideal. For instance, if I define a few polynomial generators of an ideal, say 'f=xyz-y^2' and 'g=x^3 + z', and have a polynomial p, I would like to express p as 'p = u*f + v*g', where I need to find the polynomials u,v. I tried a bunch of solve([],u,v) commands and such but I haven't found the magic solution. Thanks. Tue, 27 Sep 2011 02:24:55 +0200https://ask.sagemath.org/question/8346/find-polynomial-in-terms-of-ideal/Answer by Dirk Danckaert for <p>Hi,</p>
<p>I have been reading the tutorials and experimenting with the polynomial ring code but I have not been able to find out how to express a given polynomial in terms of the generators of an ideal. For instance, if I define a few polynomial generators of an ideal, say 'f=xyz-y^2' and 'g=x^3 + z', and have a polynomial p, I would like to express p as 'p = u<em>f + v</em>g', where I need to find the polynomials u,v. I tried a bunch of solve([],u,v) commands and such but I haven't found the magic solution. Thanks. </p>
https://ask.sagemath.org/question/8346/find-polynomial-in-terms-of-ideal/?answer=12696#post-id-12696I have a hunch that you need to specify the needed polynomials u, v better. Surely there's an infinity of solutions for them? Or am I missing something? I would be very surprised if a ***solve()*** algorithm could handle this infinity of solutions. In the case of polynomials with a single variable these coefficients are usually found with the help of Bezout's theorem. I guess the multivariate case is handled analogously.Tue, 27 Sep 2011 16:39:31 +0200https://ask.sagemath.org/question/8346/find-polynomial-in-terms-of-ideal/?answer=12696#post-id-12696Answer by Mike Hansen for <p>Hi,</p>
<p>I have been reading the tutorials and experimenting with the polynomial ring code but I have not been able to find out how to express a given polynomial in terms of the generators of an ideal. For instance, if I define a few polynomial generators of an ideal, say 'f=xyz-y^2' and 'g=x^3 + z', and have a polynomial p, I would like to express p as 'p = u<em>f + v</em>g', where I need to find the polynomials u,v. I tried a bunch of solve([],u,v) commands and such but I haven't found the magic solution. Thanks. </p>
https://ask.sagemath.org/question/8346/find-polynomial-in-terms-of-ideal/?answer=12698#post-id-12698You'll want to use the `lift` method on the polynomial `p`. For example,
sage: R.<x,y,z> = QQ[]
sage: f = x*y*z-y^2
sage: g = x^3 + z
sage: I = R.ideal([f,g])
sage: p = 3*f-x*g
sage: p.lift(I)
[3, -x]
That gives you the coefficients in front of each of the generators of the ideal. You'll want to make sure that `p` is actually in the ideal first; otherwise, you might get something like:
sage: x in I
False
sage: x.lift(I)
[0, 0]
Tue, 27 Sep 2011 23:01:41 +0200https://ask.sagemath.org/question/8346/find-polynomial-in-terms-of-ideal/?answer=12698#post-id-12698