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, 10 Oct 2021 11:47:44 +0200The meaning of arguments of is_primitivehttps://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/ Say we have
R.<x> = PolynomialRing( GF(5) )
f = x^2 + 2*x +3
then we can use f.is_primitive() to tell if f is primitive. But is_primitive has two argument n and n_prime_divs. The document say
"n" (default: "None") - if provided, should equal q-1 where
"self.parent()" is the field with q elements; otherwise it
will be computed.
But this is whose 'self'? Is it the self of polynomial f? so n=4? I think here the n shall be 5^2-1. The following code will result in error.
f.is_primitive(4, [2])
but
f.is_primitive(5^2-1, prime_divisors(5^2-1))
will give the correct answer.Mon, 04 Oct 2021 13:48:48 +0200https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/Answer by John Palmieri for <p>Say we have </p>
<pre><code>R.<x> = PolynomialRing( GF(5) )
f = x^2 + 2*x +3
</code></pre>
<p>then we can use f.is_primitive() to tell if f is primitive. But is_primitive has two argument n and n_prime_divs. The document say </p>
<pre><code>"n" (default: "None") - if provided, should equal q-1 where
"self.parent()" is the field with q elements; otherwise it
will be computed.
</code></pre>
<p>But this is whose 'self'? Is it the self of polynomial f? so n=4? I think here the n shall be 5^2-1. The following code will result in error.</p>
<pre><code>f.is_primitive(4, [2])
</code></pre>
<p>but </p>
<pre><code>f.is_primitive(5^2-1, prime_divisors(5^2-1))
</code></pre>
<p>will give the correct answer.</p>
https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?answer=59292#post-id-59292According to the `source code`, it looks like `n` should be `q^d-1` where `q` is the cardinality of the field and `d` is the degree of the polynomial. So the documentation seems to be wrong.Fri, 08 Oct 2021 19:48:51 +0200https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?answer=59292#post-id-59292Comment by zxl for <p>According to the <code>source code</code>, it looks like <code>n</code> should be <code>q^d-1</code> where <code>q</code> is the cardinality of the field and <code>d</code> is the degree of the polynomial. So the documentation seems to be wrong.</p>
https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?comment=59313#post-id-59313Thank you!Sun, 10 Oct 2021 11:47:44 +0200https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?comment=59313#post-id-59313Comment by John Palmieri for <p>According to the <code>source code</code>, it looks like <code>n</code> should be <code>q^d-1</code> where <code>q</code> is the cardinality of the field and <code>d</code> is the degree of the polynomial. So the documentation seems to be wrong.</p>
https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?comment=59299#post-id-59299I think providing its prime divisors will speed up calculation even more.Sat, 09 Oct 2021 03:30:27 +0200https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?comment=59299#post-id-59299Comment by Max Alekseyev for <p>According to the <code>source code</code>, it looks like <code>n</code> should be <code>q^d-1</code> where <code>q</code> is the cardinality of the field and <code>d</code> is the degree of the polynomial. So the documentation seems to be wrong.</p>
https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?comment=59295#post-id-59295I assume the meaning of $n$ is to provide a multiple of the order of $x$ modulo $f$ - in some cases (when it's known and smaller than $q^d-1$) it may speed up computation.Fri, 08 Oct 2021 23:21:10 +0200https://ask.sagemath.org/question/59234/the-meaning-of-arguments-of-is_primitive/?comment=59295#post-id-59295