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.Mon, 02 May 2022 07:47:41 +0200Find expansion of polynomial in an idealhttps://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/ I have a polynomial `p` and some other polynomials `p_1,...,p_k` which are elements of a multivariate polynomial ring. Say something like `P = PolynomialRing(QQ,'a,b,c,d,e,f,g')` . I know that `p` belongs to the ideal generated by `p_1,..,p_k` because when I ask for a groebner basis of `I` I can see explicitly `p` there. How do I find the expression of `p` as a linear combination of the `p_i`'s with coefficients in `P`?Wed, 29 Apr 2020 21:54:09 +0200https://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/Answer by rburing for <p>I have a polynomial <code>p</code> and some other polynomials <code>p_1,...,p_k</code> which are elements of a multivariate polynomial ring. Say something like <code>P = PolynomialRing(QQ,'a,b,c,d,e,f,g')</code> . I know that <code>p</code> belongs to the ideal generated by <code>p_1,..,p_k</code> because when I ask for a groebner basis of <code>I</code> I can see explicitly <code>p</code> there. How do I find the expression of <code>p</code> as a linear combination of the <code>p_i</code>'s with coefficients in <code>P</code>?</p>
https://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/?answer=51160#post-id-51160You can do this with the `lift` method of `p`, passing the ideal `I` as the argument:
sage: R.<x,y> = QQ[]
sage: I = R.ideal([x-1,y-1])
sage: p = x^2 - y^2 - 2*x + 2*y
sage: c = p.lift(I); c
[x - 1, -y + 1]
sage: sum(c_k*p_k for (c_k,p_k) in zip(c,I.gens()))
x^2 - y^2 - 2*x + 2*yThu, 30 Apr 2020 13:45:05 +0200https://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/?answer=51160#post-id-51160Comment by rburing for <p>You can do this with the <code>lift</code> method of <code>p</code>, passing the ideal <code>I</code> as the argument:</p>
<pre><code>sage: R.<x,y> = QQ[]
sage: I = R.ideal([x-1,y-1])
sage: p = x^2 - y^2 - 2*x + 2*y
sage: c = p.lift(I); c
[x - 1, -y + 1]
sage: sum(c_k*p_k for (c_k,p_k) in zip(c,I.gens()))
x^2 - y^2 - 2*x + 2*y
</code></pre>
https://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/?comment=62262#post-id-62262That `p` does not belong to that `I`, so no valid choice of `c` exists in that case. Did you make a typing mistake somewhere in your input?Mon, 02 May 2022 07:47:41 +0200https://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/?comment=62262#post-id-62262Comment by tunekamae for <p>You can do this with the <code>lift</code> method of <code>p</code>, passing the ideal <code>I</code> as the argument:</p>
<pre><code>sage: R.<x,y> = QQ[]
sage: I = R.ideal([x-1,y-1])
sage: p = x^2 - y^2 - 2*x + 2*y
sage: c = p.lift(I); c
[x - 1, -y + 1]
sage: sum(c_k*p_k for (c_k,p_k) in zip(c,I.gens()))
x^2 - y^2 - 2*x + 2*y
</code></pre>
https://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/?comment=62260#post-id-62260I tried in 3d but failed. Why？
R.<x,y,z> = QQ[]
I=R.ideal([x^2+z^2-1,x^2+z^2+(z^2-1)^2])
p=x^2+(1/2)*y^2*z-z-1
c=p.lift(I);c
ValueError: polynomial is not in the idealMon, 02 May 2022 06:01:14 +0200https://ask.sagemath.org/question/51149/find-expansion-of-polynomial-in-an-ideal/?comment=62260#post-id-62260