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.Fri, 23 Feb 2024 15:40:37 +0100Possible bug with product of matrices over GF with modulushttps://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/Below is a minimal example, where the product of two matrices over a finite field (with a pre-described modulus) is not computed correctly. I am looking forward to explanations about this unexpected behavior:
# adjoing a 16th root of unity to GF(3) gives a field extension of degree 4, explicitly:
F.<xi> = GF(3^4,modulus=x^4-x^2-1)
# now xi is a primitive 16th root of unity
print(xi^8==1,xi^16==1)
# matrix multiplication over F doesn't seem to work with Sage Kernel 10.0
a1=2*xi^2+2
a2=xi^2
A1=matrix(F,[a1])
A2=matrix(F,[a2])
# Sage does not compute the product of the two 1x1-matrices correctly:
print(A1*A2)
# this does not agree with the product of the underlying elements
print(a1*a2)
The output produced by Sage (Kernel 10.0) is:
False True
[2*xi^3 + 2*xi^2 + 2]
xi^2 + 2
Update: The problem persists even after updating to SageMath 10.2 on my desktop computer. The error is also reproducible on CoCalc.Thu, 22 Feb 2024 17:58:22 +0100https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/Comment by Max Alekseyev for <p>Below is a minimal example, where the product of two matrices over a finite field (with a pre-described modulus) is not computed correctly. I am looking forward to explanations about this unexpected behavior:</p>
<pre><code># adjoing a 16th root of unity to GF(3) gives a field extension of degree 4, explicitly:
F.<xi> = GF(3^4,modulus=x^4-x^2-1)
# now xi is a primitive 16th root of unity
print(xi^8==1,xi^16==1)
# matrix multiplication over F doesn't seem to work with Sage Kernel 10.0
a1=2*xi^2+2
a2=xi^2
A1=matrix(F,[a1])
A2=matrix(F,[a2])
# Sage does not compute the product of the two 1x1-matrices correctly:
print(A1*A2)
# this does not agree with the product of the underlying elements
print(a1*a2)
</code></pre>
<p>The output produced by Sage (Kernel 10.0) is:</p>
<pre><code>False True
[2*xi^3 + 2*xi^2 + 2]
xi^2 + 2
</code></pre>
<p>Update: The problem persists even after updating to SageMath 10.2 on my desktop computer. The error is also reproducible on CoCalc.</p>
https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76200#post-id-76200I'm not sure if that's relevant, but CoCalc runs `venv-python3.11.1/bin/sage`, while SageCell runs `venv-python3.10/bin/sage`Fri, 23 Feb 2024 15:40:37 +0100https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76200#post-id-76200Comment by Johannes for <p>Below is a minimal example, where the product of two matrices over a finite field (with a pre-described modulus) is not computed correctly. I am looking forward to explanations about this unexpected behavior:</p>
<pre><code># adjoing a 16th root of unity to GF(3) gives a field extension of degree 4, explicitly:
F.<xi> = GF(3^4,modulus=x^4-x^2-1)
# now xi is a primitive 16th root of unity
print(xi^8==1,xi^16==1)
# matrix multiplication over F doesn't seem to work with Sage Kernel 10.0
a1=2*xi^2+2
a2=xi^2
A1=matrix(F,[a1])
A2=matrix(F,[a2])
# Sage does not compute the product of the two 1x1-matrices correctly:
print(A1*A2)
# this does not agree with the product of the underlying elements
print(a1*a2)
</code></pre>
<p>The output produced by Sage (Kernel 10.0) is:</p>
<pre><code>False True
[2*xi^3 + 2*xi^2 + 2]
xi^2 + 2
</code></pre>
<p>Update: The problem persists even after updating to SageMath 10.2 on my desktop computer. The error is also reproducible on CoCalc.</p>
https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76195#post-id-76195Strangely enough, @rburing's code runs correctly on SageMathCell, but neither on Cocalc nor on my Sage installation.Fri, 23 Feb 2024 13:54:01 +0100https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76195#post-id-76195Comment by Emmanuel Charpentier for <p>Below is a minimal example, where the product of two matrices over a finite field (with a pre-described modulus) is not computed correctly. I am looking forward to explanations about this unexpected behavior:</p>
<pre><code># adjoing a 16th root of unity to GF(3) gives a field extension of degree 4, explicitly:
F.<xi> = GF(3^4,modulus=x^4-x^2-1)
# now xi is a primitive 16th root of unity
print(xi^8==1,xi^16==1)
# matrix multiplication over F doesn't seem to work with Sage Kernel 10.0
a1=2*xi^2+2
a2=xi^2
A1=matrix(F,[a1])
A2=matrix(F,[a2])
# Sage does not compute the product of the two 1x1-matrices correctly:
print(A1*A2)
# this does not agree with the product of the underlying elements
print(a1*a2)
</code></pre>
<p>The output produced by Sage (Kernel 10.0) is:</p>
<pre><code>False True
[2*xi^3 + 2*xi^2 + 2]
xi^2 + 2
</code></pre>
<p>Update: The problem persists even after updating to SageMath 10.2 on my desktop computer. The error is also reproducible on CoCalc.</p>
https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76193#post-id-76193For me, this is correcly done on Sagemath 10.3.beta8.
> The problem persists even after updating to SageMath 10.2 on my desktop computer. The error is also reproducible on CoCalc.
Can you reproduce it on Sagecell and post the (permanent) link ?
What happens when you try to reproduce @rburing's code in Cocalc ? In your Sage installation ?Fri, 23 Feb 2024 13:48:00 +0100https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76193#post-id-76193Answer by rburing for <p>Below is a minimal example, where the product of two matrices over a finite field (with a pre-described modulus) is not computed correctly. I am looking forward to explanations about this unexpected behavior:</p>
<pre><code># adjoing a 16th root of unity to GF(3) gives a field extension of degree 4, explicitly:
F.<xi> = GF(3^4,modulus=x^4-x^2-1)
# now xi is a primitive 16th root of unity
print(xi^8==1,xi^16==1)
# matrix multiplication over F doesn't seem to work with Sage Kernel 10.0
a1=2*xi^2+2
a2=xi^2
A1=matrix(F,[a1])
A2=matrix(F,[a2])
# Sage does not compute the product of the two 1x1-matrices correctly:
print(A1*A2)
# this does not agree with the product of the underlying elements
print(a1*a2)
</code></pre>
<p>The output produced by Sage (Kernel 10.0) is:</p>
<pre><code>False True
[2*xi^3 + 2*xi^2 + 2]
xi^2 + 2
</code></pre>
<p>Update: The problem persists even after updating to SageMath 10.2 on my desktop computer. The error is also reproducible on CoCalc.</p>
https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?answer=76186#post-id-76186This is fixed in SageMath 10.2; [run in SageMathCell](https://sagecell.sagemath.org/?z=eJxtkTFrwzAQhXeD_8NBhtqpEyI1hFLqghd36NixxCDsi6NWloJ8jpV_X0mmpUMn6U7H9947rUB0n0bqHgSwA53BGkNgTjBpSTcgA6919pBDL684-pmTRNUBOkI9SqPDZIe9RYR94dsXJVtJ6vaUJvX22ckXKCOg2ReD6SY1jaVr9hvX8A3L02QF2szgJMjAvlg5SPJC_zhJE_-qKXOyeSxLVviTHfwlQgZBVjoYJkUyOBAUrV3RQg2dwVHfEYyIQ8gzG_sFs_QC76JHeEOrUQHbbXdpIljJ1x7N77kveBmuaVKxclHI6uJDsKPXrPjfFj9GG5EX5HwqgtYMl4kQ6Iw-mQ_fxjShpNkAc2wTEa2fb4212C57W3JWbF3xSKWzX84vVcRdR_v_gCfdoVW38J2ocEBN4w9QsLUIwKXyqwnfl-X5N82upnU=&lang=sage&interacts=eJyLjgUAARUAuQ==).
It would be nice to find the corresponding [issue](https://github.com/sagemath/sage/issues) and the [pull request](https://github.com/sagemath/sage/pulls) that fixed it, but I didn't find them in a cursory search.Fri, 23 Feb 2024 11:11:31 +0100https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?answer=76186#post-id-76186Comment by Johannes for <p>This is fixed in SageMath 10.2; <a href="https://sagecell.sagemath.org/?z=eJxtkTFrwzAQhXeD_8NBhtqpEyI1hFLqghd36NixxCDsi6NWloJ8jpV_X0mmpUMn6U7H9947rUB0n0bqHgSwA53BGkNgTjBpSTcgA6919pBDL684-pmTRNUBOkI9SqPDZIe9RYR94dsXJVtJ6vaUJvX22ckXKCOg2ReD6SY1jaVr9hvX8A3L02QF2szgJMjAvlg5SPJC_zhJE_-qKXOyeSxLVviTHfwlQgZBVjoYJkUyOBAUrV3RQg2dwVHfEYyIQ8gzG_sFs_QC76JHeEOrUQHbbXdpIljJ1x7N77kveBmuaVKxclHI6uJDsKPXrPjfFj9GG5EX5HwqgtYMl4kQ6Iw-mQ_fxjShpNkAc2wTEa2fb4212C57W3JWbF3xSKWzX84vVcRdR_v_gCfdoVW38J2ocEBN4w9QsLUIwKXyqwnfl-X5N82upnU=&lang=sage&interacts=eJyLjgUAARUAuQ==">run in SageMathCell</a>.</p>
<p>It would be nice to find the corresponding <a href="https://github.com/sagemath/sage/issues">issue</a> and the <a href="https://github.com/sagemath/sage/pulls">pull request</a> that fixed it, but I didn't find them in a cursory search.</p>
https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76192#post-id-76192Thank you for the quick reply, and for the link to SageMathCell. I have updated to SageMath 10.2, but the problem persists. I have also tried it on CoCalc (which runs with SageMath 10.2) and the same problem occurs.Fri, 23 Feb 2024 13:37:57 +0100https://ask.sagemath.org/question/76170/possible-bug-with-product-of-matrices-over-gf-with-modulus/?comment=76192#post-id-76192