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, 11 Jun 2013 03:39:19 +0200Polynomial Ring bug?https://ask.sagemath.org/question/10213/polynomial-ring-bug/I would like to ask, why following code ends with error:
---------------------------------------------
R = PolynomialRing(GF(3),'x3,x5,x4,x7,x6')
U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x0, x6')
f = U.gens()[1] + U.gens()[2]
g = R(f)
------------------------------------------------------
because when I remove x0 from the generators, it works fine.
---------------------------------------------------------
R = PolynomialRing(GF(3),'x3,x5,x4,x7,x6')
U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x6')
f = U.gens()[1] + U.gens()[2]
g = R(f)
----------------------------------------------------
Thanks for the answer, but there is still an open question. I have been working with this for a few days, and up untill this case, I had no trouble getting the same polynomial in a ring with fewer genarators, if the original polynomial contained only those. I tried and the followng code works fine, and it also fits your last case which according to you should raise an error, because U has more generators than R.
---------------------------------------------------
R = PolynomialRing(GF(3),'x5,x4,x7,x6')
U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x6')
f = U.gens()[1] + U.gens()[2]
g = R(f)Sun, 09 Jun 2013 12:14:51 +0200https://ask.sagemath.org/question/10213/polynomial-ring-bug/Answer by John Palmieri for <p>I would like to ask, why following code ends with error:</p>
<hr/>
<p>R = PolynomialRing(GF(3),'x3,x5,x4,x7,x6')</p>
<p>U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x0, x6')</p>
<p>f = U.gens()[1] + U.gens()[2]</p>
<p>g = R(f)</p>
<hr/>
<p>because when I remove x0 from the generators, it works fine.</p>
<hr/>
<p>R = PolynomialRing(GF(3),'x3,x5,x4,x7,x6')</p>
<p>U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x6')</p>
<p>f = U.gens()[1] + U.gens()[2]</p>
<p>g = R(f)</p>
<hr/>
<p>Thanks for the answer, but there is still an open question. I have been working with this for a few days, and up untill this case, I had no trouble getting the same polynomial in a ring with fewer genarators, if the original polynomial contained only those. I tried and the followng code works fine, and it also fits your last case which according to you should raise an error, because U has more generators than R.</p>
<hr/>
<p>R = PolynomialRing(GF(3),'x5,x4,x7,x6')</p>
<p>U = PolynomialRing(GF(3), 'x2, x5, x4, x1, x6')</p>
<p>f = U.gens()[1] + U.gens()[2]</p>
<p>g = R(f)</p>
https://ask.sagemath.org/question/10213/polynomial-ring-bug/?answer=15049#post-id-15049Executing `g=R(f)` calls the `__call__` method for the ring `R`. You should read the documentation for this (by executing `R.__call__?`). In summary: given two polynomial rings `U` and `R`, if every generator of `U` is a generator for `R`, then `R(f)` does the obvious thing, mapping each generator of `U` to the generator of `R` with the same name. Otherwise, if `U` has at most as many generators as `R`, then map the `i`th generator of `U` to the `i`th generator of `R`. Otherwise, `U` must have more generators, so raise an error. Your case fits into this last situation.Sun, 09 Jun 2013 22:31:09 +0200https://ask.sagemath.org/question/10213/polynomial-ring-bug/?answer=15049#post-id-15049Comment by blishko for <p>Executing <code>g=R(f)</code> calls the <code>__call__</code> method for the ring <code>R</code>. You should read the documentation for this (by executing <code>R.__call__?</code>). In summary: given two polynomial rings <code>U</code> and <code>R</code>, if every generator of <code>U</code> is a generator for <code>R</code>, then <code>R(f)</code> does the obvious thing, mapping each generator of <code>U</code> to the generator of <code>R</code> with the same name. Otherwise, if <code>U</code> has at most as many generators as <code>R</code>, then map the <code>i</code>th generator of <code>U</code> to the <code>i</code>th generator of <code>R</code>. Otherwise, <code>U</code> must have more generators, so raise an error. Your case fits into this last situation.</p>
https://ask.sagemath.org/question/10213/polynomial-ring-bug/?comment=17533#post-id-17533I edited the question. There is a case that fits your last situation, and it does not raise an error. I would like to know the difference.Mon, 10 Jun 2013 03:57:57 +0200https://ask.sagemath.org/question/10213/polynomial-ring-bug/?comment=17533#post-id-17533Comment by blishko for <p>Executing <code>g=R(f)</code> calls the <code>__call__</code> method for the ring <code>R</code>. You should read the documentation for this (by executing <code>R.__call__?</code>). In summary: given two polynomial rings <code>U</code> and <code>R</code>, if every generator of <code>U</code> is a generator for <code>R</code>, then <code>R(f)</code> does the obvious thing, mapping each generator of <code>U</code> to the generator of <code>R</code> with the same name. Otherwise, if <code>U</code> has at most as many generators as <code>R</code>, then map the <code>i</code>th generator of <code>U</code> to the <code>i</code>th generator of <code>R</code>. Otherwise, <code>U</code> must have more generators, so raise an error. Your case fits into this last situation.</p>
https://ask.sagemath.org/question/10213/polynomial-ring-bug/?comment=17531#post-id-17531I did, but I don't see it. Could you point me to the sentence that answers my question?Tue, 11 Jun 2013 03:39:19 +0200https://ask.sagemath.org/question/10213/polynomial-ring-bug/?comment=17531#post-id-17531Comment by Volker Braun for <p>Executing <code>g=R(f)</code> calls the <code>__call__</code> method for the ring <code>R</code>. You should read the documentation for this (by executing <code>R.__call__?</code>). In summary: given two polynomial rings <code>U</code> and <code>R</code>, if every generator of <code>U</code> is a generator for <code>R</code>, then <code>R(f)</code> does the obvious thing, mapping each generator of <code>U</code> to the generator of <code>R</code> with the same name. Otherwise, if <code>U</code> has at most as many generators as <code>R</code>, then map the <code>i</code>th generator of <code>U</code> to the <code>i</code>th generator of <code>R</code>. Otherwise, <code>U</code> must have more generators, so raise an error. Your case fits into this last situation.</p>
https://ask.sagemath.org/question/10213/polynomial-ring-bug/?comment=17532#post-id-17532Your question is answered in R.__call__? docstring, did you read it?Mon, 10 Jun 2013 11:37:43 +0200https://ask.sagemath.org/question/10213/polynomial-ring-bug/?comment=17532#post-id-17532