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, 25 Jul 2017 22:32:44 +0200Polynomials over number fieldshttps://ask.sagemath.org/question/38381/polynomials-over-number-fields/Below I define a polynomial ring K[s,t]. My goal is to compute the minors of a large matrix with entries in this ring.
var('x')
# K.<t> = NumberField(x^2-2)
K.<s,t> = NumberField([x^2-2,x^2-5])
R.<p0,p1,p2,p3,p4,p5> = K[]
M = Mat(R,10,10).random_element()
mins = M.minors(2)
This code works fine, but if I replace the last line with
mins = M.minors(7)
it fails with the error message
TypeError: no conversion to a Singular ring defined
Is it possible to avoid this error?Mon, 24 Jul 2017 18:09:25 +0200https://ask.sagemath.org/question/38381/polynomials-over-number-fields/Answer by vdelecroix for <p>Below I define a polynomial ring K[s,t]. My goal is to compute the minors of a large matrix with entries in this ring.</p>
<pre><code>var('x')
# K.<t> = NumberField(x^2-2)
K.<s,t> = NumberField([x^2-2,x^2-5])
R.<p0,p1,p2,p3,p4,p5> = K[]
M = Mat(R,10,10).random_element()
mins = M.minors(2)
</code></pre>
<p>This code works fine, but if I replace the last line with</p>
<pre><code>mins = M.minors(7)
</code></pre>
<p>it fails with the error message </p>
<pre><code>TypeError: no conversion to a Singular ring defined
</code></pre>
<p>Is it possible to avoid this error?</p>
https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?answer=38387#post-id-38387Thanks for your report, this is a bug in Sage. I opened the [ticket #23535](https://trac.sagemath.org/ticket/23535) to track the issue. Hopefully it will be corrected and fixed in later releases... In the mean time you can fallback to the generic algorithm with
sage: m = random_matrix(R,4)
sage: sage.matrix.matrix2.Matrix.determinant(m)Mon, 24 Jul 2017 21:39:05 +0200https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?answer=38387#post-id-38387Comment by coreyharris for <p>Thanks for your report, this is a bug in Sage. I opened the <a href="https://trac.sagemath.org/ticket/23535">ticket #23535</a> to track the issue. Hopefully it will be corrected and fixed in later releases... In the mean time you can fallback to the generic algorithm with</p>
<pre><code>sage: m = random_matrix(R,4)
sage: sage.matrix.matrix2.Matrix.determinant(m)
</code></pre>
https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38389#post-id-38389So this method only computes determinants? Is there an easy way to manually iterate over submatrices?Mon, 24 Jul 2017 21:57:09 +0200https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38389#post-id-38389Comment by vdelecroix for <p>Thanks for your report, this is a bug in Sage. I opened the <a href="https://trac.sagemath.org/ticket/23535">ticket #23535</a> to track the issue. Hopefully it will be corrected and fixed in later releases... In the mean time you can fallback to the generic algorithm with</p>
<pre><code>sage: m = random_matrix(R,4)
sage: sage.matrix.matrix2.Matrix.determinant(m)
</code></pre>
https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38391#post-id-38391You can take submatrices using indices
sage: m = matrix(4, range(16))
sage: m
[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]
[12 13 14 15]
sage: m[1:3, 2:4]
[ 6 7]
[10 11]
(be careful indices starts at 0)Mon, 24 Jul 2017 22:05:49 +0200https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38391#post-id-38391Comment by dan_fulea for <p>Thanks for your report, this is a bug in Sage. I opened the <a href="https://trac.sagemath.org/ticket/23535">ticket #23535</a> to track the issue. Hopefully it will be corrected and fixed in later releases... In the mean time you can fallback to the generic algorithm with</p>
<pre><code>sage: m = random_matrix(R,4)
sage: sage.matrix.matrix2.Matrix.determinant(m)
</code></pre>
https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38399#post-id-38399The error also shows for the one $4$-minor of a random $4\times 4$-matrix over `R`,
var('x')
K.<s,t> = NumberField([x^2-2,x^2-5])
R.<p0,p1,p2,p3,p4,p5> = K[]
M = Mat(R,4,4).random_element()
try:
mins = M.minors(4)
except TypeError:
print "...got TypeError"
This may be relevant for the tests to fix the bug.
I tried to change the base from `R` to its fraction field, got no error, but also had no time
to wait for that one determinant computation...Tue, 25 Jul 2017 01:21:50 +0200https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38399#post-id-38399Comment by vdelecroix for <p>Thanks for your report, this is a bug in Sage. I opened the <a href="https://trac.sagemath.org/ticket/23535">ticket #23535</a> to track the issue. Hopefully it will be corrected and fixed in later releases... In the mean time you can fallback to the generic algorithm with</p>
<pre><code>sage: m = random_matrix(R,4)
sage: sage.matrix.matrix2.Matrix.determinant(m)
</code></pre>
https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38400#post-id-38400@dan_fulea The determinant code has special cases for size 2 and 3 reason why you do not see the bug before size 4.Tue, 25 Jul 2017 10:19:25 +0200https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38400#post-id-38400Comment by dan_fulea for <p>Thanks for your report, this is a bug in Sage. I opened the <a href="https://trac.sagemath.org/ticket/23535">ticket #23535</a> to track the issue. Hopefully it will be corrected and fixed in later releases... In the mean time you can fallback to the generic algorithm with</p>
<pre><code>sage: m = random_matrix(R,4)
sage: sage.matrix.matrix2.Matrix.determinant(m)
</code></pre>
https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38407#post-id-38407Yes, thanks, my intention was just to give a simple instance for the error, that may serve as test case for the opened ticket... (And also to mention that the 4x4 determinant of the random matrix could not be computed in real time, so computing all 7x7 minors of a 10x10 random matrix...)Tue, 25 Jul 2017 22:32:44 +0200https://ask.sagemath.org/question/38381/polynomials-over-number-fields/?comment=38407#post-id-38407