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.Sun, 23 Jan 2022 12:02:31 +0100A question about definition of a polynomial ring.https://ask.sagemath.org/question/60771/a-question-about-definition-of-a-polynomial-ring/ I am trying to define a polynomial ring as follows:
from sage.combinat import *
n=9
m=100
R = PolynomialRing(QQ,n*m,['x'+str(i)+str(j) for i in range(1,n+1) for j in range(1,m+1)])
It is ok with n=9, m=100. But when I change n, m to n=11, m=100. Then there is an error: ValueError: variable name 'x111' appears more than once
I would like to have n=100, m=1000. How to solve this problem? Thank you very much.Sun, 23 Jan 2022 10:29:07 +0100https://ask.sagemath.org/question/60771/a-question-about-definition-of-a-polynomial-ring/Answer by rburing for <p>I am trying to define a polynomial ring as follows:</p>
<pre><code>from sage.combinat import *
n=9
m=100
R = PolynomialRing(QQ,n*m,['x'+str(i)+str(j) for i in range(1,n+1) for j in range(1,m+1)])
</code></pre>
<p>It is ok with n=9, m=100. But when I change n, m to n=11, m=100. Then there is an error: ValueError: variable name 'x111' appears more than once</p>
<p>I would like to have n=100, m=1000. How to solve this problem? Thank you very much.</p>
https://ask.sagemath.org/question/60771/a-question-about-definition-of-a-polynomial-ring/?answer=60774#post-id-60774Sage is giving you a hint that your naming scheme is ambiguous. In particular, `'x111'` appears more than once, because it is both `'x'+'1'+'11'` and `'x'+'11'+'1'`. You can add a separator like an underscore to avoid this:
['x{}_{}'.format(i+1,j+1) for i in range(n) for j in range(m)]Sun, 23 Jan 2022 12:02:31 +0100https://ask.sagemath.org/question/60771/a-question-about-definition-of-a-polynomial-ring/?answer=60774#post-id-60774