ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 16 Dec 2015 18:57:53 -0600multiplication matrix in number fieldhttp://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/Hello
Given two integral numbers, say `a` and `b` such that `a^3=2` and `b^2=3`, I want to check "by hand" that `a+b` is again integral over Z. To do that, I want to build the matrix of the linear transform "`m`: multiplication by `a+b` on the number field Q(a,b)
since `a+b` is obviously an eigenvalue, i.e. root of it's caracteristic polynomial which then SAGE can compute for me). Then I can check that `(a+b).minpoly()` gives the same result as `P(X)=(M-XI).determinant()` and then after coercision within `Q.<x>=QQ[], P=Q(P)`, check `P.is_irreducible()`, meaning `a+b` integral.
Thus, given a basis (1,a,a²,b,ab,a²b) for Q(a,b), one can determine the matrix "by hand": each column is the image of each element times `a+b`: (transpose the vectors bellow)
- 1st is:`(a+b).1=[0,1,0,1,0,0]`,
- 2d is `(a+b).a=[0,0,1,0,1,0]`,
- 3d is `(a+b).a²=[2,0,0,0,0,1]`,
- 4th is `(a+b).b=[3,0,0,0,1,0]`,
- 5th is `(a+b).ab=[0,3,0,0,0,1]`,
- 6th is `(a+b).a²b=[0,0,3,2,0,0]`
One can define the extension `k.<a,b>=NumberField([x³-2,x²-3])`, isomorphic to `z⁶-9*z⁴-4*z³+27*z²-36*z-23` (via `k.absolute_field()` . Then, I don't know how to do these calculations automatically within SAGE:
=> for example: how make the vector `a²=[0,0,1,0,0,0]` become `(a+b).a²=2+a²b=[2,0,0,,0,1]` after multiplication of `a²` by `a+b` given the relations `a³=2` and `b²=3`? ?
Mon, 02 Nov 2015 11:55:55 -0600http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/Comment by nd for <p>Hello
Given two integral numbers, say <code>a</code> and <code>b</code> such that <code>a^3=2</code> and <code>b^2=3</code>, I want to check "by hand" that <code>a+b</code> is again integral over Z. To do that, I want to build the matrix of the linear transform "<code>m</code>: multiplication by <code>a+b</code> on the number field Q(a,b)</p>
<p>since <code>a+b</code> is obviously an eigenvalue, i.e. root of it's caracteristic polynomial which then SAGE can compute for me). Then I can check that <code>(a+b).minpoly()</code> gives the same result as <code>P(X)=(M-XI).determinant()</code> and then after coercision within <code>Q.<x>=QQ[], P=Q(P)</code>, check <code>P.is_irreducible()</code>, meaning <code>a+b</code> integral.</p>
<p>Thus, given a basis (1,a,a²,b,ab,a²b) for Q(a,b), one can determine the matrix "by hand": each column is the image of each element times <code>a+b</code>: (transpose the vectors bellow)</p>
<ul>
<li>1st is:<code>(a+b).1=[0,1,0,1,0,0]</code>, </li>
<li>2d is <code>(a+b).a=[0,0,1,0,1,0]</code>,</li>
<li>3d is <code>(a+b).a²=[2,0,0,0,0,1]</code>,</li>
<li>4th is <code>(a+b).b=[3,0,0,0,1,0]</code>,</li>
<li>5th is <code>(a+b).ab=[0,3,0,0,0,1]</code>,</li>
<li>6th is <code>(a+b).a²b=[0,0,3,2,0,0]</code></li>
</ul>
<p>One can define the extension <code>k.<a,b>=NumberField([x³-2,x²-3])</code>, isomorphic to <code>z⁶-9*z⁴-4*z³+27*z²-36*z-23</code> (via <code>k.absolute_field()</code> . Then, I don't know how to do these calculations automatically within SAGE:</p>
<p>=> for example: how make the vector <code>a²=[0,0,1,0,0,0]</code> become <code>(a+b).a²=2+a²b=[2,0,0,,0,1]</code> after multiplication of <code>a²</code> by <code>a+b</code> given the relations <code>a³=2</code> and <code>b²=3</code>? ?</p>
http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?comment=31621#post-id-31621Sorry for late response. Very interresting too & thanks as I alos need this approach for different usage. I might come back!Wed, 16 Dec 2015 18:57:53 -0600http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?comment=31621#post-id-31621Comment by nbruin for <p>Hello
Given two integral numbers, say <code>a</code> and <code>b</code> such that <code>a^3=2</code> and <code>b^2=3</code>, I want to check "by hand" that <code>a+b</code> is again integral over Z. To do that, I want to build the matrix of the linear transform "<code>m</code>: multiplication by <code>a+b</code> on the number field Q(a,b)</p>
<p>since <code>a+b</code> is obviously an eigenvalue, i.e. root of it's caracteristic polynomial which then SAGE can compute for me). Then I can check that <code>(a+b).minpoly()</code> gives the same result as <code>P(X)=(M-XI).determinant()</code> and then after coercision within <code>Q.<x>=QQ[], P=Q(P)</code>, check <code>P.is_irreducible()</code>, meaning <code>a+b</code> integral.</p>
<p>Thus, given a basis (1,a,a²,b,ab,a²b) for Q(a,b), one can determine the matrix "by hand": each column is the image of each element times <code>a+b</code>: (transpose the vectors bellow)</p>
<ul>
<li>1st is:<code>(a+b).1=[0,1,0,1,0,0]</code>, </li>
<li>2d is <code>(a+b).a=[0,0,1,0,1,0]</code>,</li>
<li>3d is <code>(a+b).a²=[2,0,0,0,0,1]</code>,</li>
<li>4th is <code>(a+b).b=[3,0,0,0,1,0]</code>,</li>
<li>5th is <code>(a+b).ab=[0,3,0,0,0,1]</code>,</li>
<li>6th is <code>(a+b).a²b=[0,0,3,2,0,0]</code></li>
</ul>
<p>One can define the extension <code>k.<a,b>=NumberField([x³-2,x²-3])</code>, isomorphic to <code>z⁶-9*z⁴-4*z³+27*z²-36*z-23</code> (via <code>k.absolute_field()</code> . Then, I don't know how to do these calculations automatically within SAGE:</p>
<p>=> for example: how make the vector <code>a²=[0,0,1,0,0,0]</code> become <code>(a+b).a²=2+a²b=[2,0,0,,0,1]</code> after multiplication of <code>a²</code> by <code>a+b</code> given the relations <code>a³=2</code> and <code>b²=3</code>? ?</p>
http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?comment=30758#post-id-30758The answer below is more comprehensive in that it applies to any basis choice. If you want to work with respect to the tensor basis, you don't have to compute an "absolute" field (although the another basis ordering than the one you propose is easier to obtain):
sage: v= lambda u: flatten(map(list,list(u)))
sage: [v(u) for u in [k(1),b,a,a*b,a^2,a^2*b]]
[[1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1]]
sage: v( (a+b)*a^2)
[2, 0, 0, 0, 0, 1]Mon, 16 Nov 2015 11:18:52 -0600http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?comment=30758#post-id-30758Answer by nbruin for <p>Hello
Given two integral numbers, say <code>a</code> and <code>b</code> such that <code>a^3=2</code> and <code>b^2=3</code>, I want to check "by hand" that <code>a+b</code> is again integral over Z. To do that, I want to build the matrix of the linear transform "<code>m</code>: multiplication by <code>a+b</code> on the number field Q(a,b)</p>
<p>since <code>a+b</code> is obviously an eigenvalue, i.e. root of it's caracteristic polynomial which then SAGE can compute for me). Then I can check that <code>(a+b).minpoly()</code> gives the same result as <code>P(X)=(M-XI).determinant()</code> and then after coercision within <code>Q.<x>=QQ[], P=Q(P)</code>, check <code>P.is_irreducible()</code>, meaning <code>a+b</code> integral.</p>
<p>Thus, given a basis (1,a,a²,b,ab,a²b) for Q(a,b), one can determine the matrix "by hand": each column is the image of each element times <code>a+b</code>: (transpose the vectors bellow)</p>
<ul>
<li>1st is:<code>(a+b).1=[0,1,0,1,0,0]</code>, </li>
<li>2d is <code>(a+b).a=[0,0,1,0,1,0]</code>,</li>
<li>3d is <code>(a+b).a²=[2,0,0,0,0,1]</code>,</li>
<li>4th is <code>(a+b).b=[3,0,0,0,1,0]</code>,</li>
<li>5th is <code>(a+b).ab=[0,3,0,0,0,1]</code>,</li>
<li>6th is <code>(a+b).a²b=[0,0,3,2,0,0]</code></li>
</ul>
<p>One can define the extension <code>k.<a,b>=NumberField([x³-2,x²-3])</code>, isomorphic to <code>z⁶-9*z⁴-4*z³+27*z²-36*z-23</code> (via <code>k.absolute_field()</code> . Then, I don't know how to do these calculations automatically within SAGE:</p>
<p>=> for example: how make the vector <code>a²=[0,0,1,0,0,0]</code> become <code>(a+b).a²=2+a²b=[2,0,0,,0,1]</code> after multiplication of <code>a²</code> by <code>a+b</code> given the relations <code>a³=2</code> and <code>b²=3</code>? ?</p>
http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?answer=30410#post-id-30410Your first try should probably be
k.<a,b>=NumberField([x^3-2,x^2-3])
L=L=k.absolute_field('z')
O=L.order([1,a,a^2,b,a*b,a^2,b])
which creates the appropriate rank 6 order over ZZ. However, Sage seems to prefer to keep representing elements with respect to the power basis in z, even in O:
sage: O(a+b)
-4/51*z^5 - 1/51*z^4 + 40/51*z^3 + 26/51*z^2 - 127/51*z + 91/51
sage: list(O(a+b))
[91/51, -127/51, 26/51, 40/51, -1/51, -4/51]
However, you're just a change-of-basis away from the appropriate result, and you can compute the corresponding matrix easily (and indeed, since orders don't allow you to specify the basis, you don't have to bother with orders at all. You might as well just work in the field)
sage: T=matrix([list(L(u)) for u in [1,a,a^2,b,a*b,a^2*b]])
sage: T
[ 1 0 0 0 0 0]
[ 91/102 -38/51 13/51 20/51 -1/102 -2/51]
[ 61/51 -53/51 -19/51 10/51 4/51 -1/51]
[ 91/102 -89/51 13/51 20/51 -1/102 -2/51]
[ 107/51 -53/102 -35/51 5/51 2/51 -1/102]
[ 125/51 -25/51 26/51 23/51 -1/51 -4/51]
Given what `<number field element>.matrix` does, you can now get the appropriate matrix for multiplication by a+b with respect to the tensor basis (acting on row vectors) via
sage: T*L(a+b).matrix()*T^(-1)
[0 1 0 1 0 0]
[0 0 1 0 1 0]
[2 0 0 0 0 1]
[3 0 0 0 1 0]
[0 3 0 0 0 1]
[0 0 3 2 0 0]
Mon, 02 Nov 2015 12:39:13 -0600http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?answer=30410#post-id-30410Comment by nd for <p>Your first try should probably be</p>
<pre><code>k.<a,b>=NumberField([x^3-2,x^2-3])
L=L=k.absolute_field('z')
O=L.order([1,a,a^2,b,a*b,a^2,b])
</code></pre>
<p>which creates the appropriate rank 6 order over ZZ. However, Sage seems to prefer to keep representing elements with respect to the power basis in z, even in O:</p>
<pre><code>sage: O(a+b)
-4/51*z^5 - 1/51*z^4 + 40/51*z^3 + 26/51*z^2 - 127/51*z + 91/51
sage: list(O(a+b))
[91/51, -127/51, 26/51, 40/51, -1/51, -4/51]
</code></pre>
<p>However, you're just a change-of-basis away from the appropriate result, and you can compute the corresponding matrix easily (and indeed, since orders don't allow you to specify the basis, you don't have to bother with orders at all. You might as well just work in the field)</p>
<pre><code>sage: T=matrix([list(L(u)) for u in [1,a,a^2,b,a*b,a^2*b]])
sage: T
[ 1 0 0 0 0 0]
[ 91/102 -38/51 13/51 20/51 -1/102 -2/51]
[ 61/51 -53/51 -19/51 10/51 4/51 -1/51]
[ 91/102 -89/51 13/51 20/51 -1/102 -2/51]
[ 107/51 -53/102 -35/51 5/51 2/51 -1/102]
[ 125/51 -25/51 26/51 23/51 -1/51 -4/51]
</code></pre>
<p>Given what <code><number field element>.matrix</code> does, you can now get the appropriate matrix for multiplication by a+b with respect to the tensor basis (acting on row vectors) via</p>
<pre><code>sage: T*L(a+b).matrix()*T^(-1)
[0 1 0 1 0 0]
[0 0 1 0 1 0]
[2 0 0 0 0 1]
[3 0 0 0 1 0]
[0 3 0 0 0 1]
[0 0 3 2 0 0]
</code></pre>
http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?comment=30417#post-id-30417Great & thanks for your prompt answer! Indeed, Sage kept using the primitive element z of K instead of k.gens() within an order as defined on L, and I couldn't go around that. I will have a closer look to the number field element page and the .matrix(). to understand your answer.Mon, 02 Nov 2015 14:28:17 -0600http://ask.sagemath.org/question/30408/multiplication-matrix-in-number-field/?comment=30417#post-id-30417