![]() | 1 | initial version |
It is arguable, that
lambda n: 2*n^2-1 # if n in ZZ and n > 0 else None
is the solution getting the full score in an exam. (But this is always a good test for the sense of humor of the examiner. And for the own courage in real life.)
Instead, we may translate as follows from the Italian:
Write a function in Sage that computes the matrix of the linear map F, written in suitable bases,
from the space VA×VB, where VA=VA(n), VB=VB(n) are two copies of Mn(R)
to the space W=W(n) of endomorphisms of Mn(R),
constructed as follows: For A∈VA and B∈VB we associate F(A,B)=F(A,0)+F(0,B) which acts on a matrix X as follows: F(A,B)(X)=AX+XB.
Then compute the rank for some small values of n.
My choice of the bases is as follows. Let EA(j,k) be the standard generators of VA. And EB(j,k) be the standard generators of VB. It is clear that the family of 2n2 endomorphisms in W of the shape F( EA(j,k),0 ) and F( 0,EB(j,k) ) generate the image of F. We associate the matrix for them and the standard generators of W, which are the homomorphisms E( (s,t)→(u,v) ) mapping all standard generators to zero, except for E(s,t), which is mapped to E(u,v).
It is clear now, that a non-trivial liniar combination leads to an equation of the shape AX+XB≡0, an identity in X. (A and B come by assembling the coefficients in the non-trivial linear combination.) This is the case only for A=−B a diagonal matrix. So the dimension of the kernel is one. The following lines compute the matrix explicitly, and the rank is as expected. The programmer has no problems with the linear algebra, but rather with the reshaping of a matrix as a vector.
def FMatrix( n ):
R = range(n)
A = matrix( QQ, n^4, n^2+n^2 )
count_columns = 0
for j, k in cartesian_product( [R, R] ):
# the elementary matrix (j,k) acts on the vector of morphisms ( (s,t) -> (u,v) )
# first of all from the left, then from the right,
# from the left
count_rows = 0
for s, t, u, v in cartesian_product( [R,R,R,R] ):
# is (j,k) o (s,t) = (u,v) ?
if j == u and k == s and t == v:
A[ count_rows, count_columns ] = 1
count_rows += 1
count_columns += 1
# from the right
count_rows = 0
for s, t, u, v in cartesian_product( [R,R,R,R] ):
# is (s,t) o (j,k) = (u,v) ?
if s == u and t == j and k == v:
A[ count_rows, count_columns ] = 1
count_rows += 1
count_columns += 1
return A
for n in [1..4]:
print "Dimension of W(%s) is: %s" % ( n, FMatrix(n).rank() )
And after a short thrill:
Dimension of W(1) is: 1
Dimension of W(2) is: 7
Dimension of W(3) is: 17
Dimension of W(4) is: 31
![]() | 2 | No.2 Revision |
It is arguable, that
lambda n: 2*n^2-1 # if n in ZZ and n > 0 else None
is the solution getting the full score in an exam. (But this is always a good test for the sense of humor of the examiner. And for the own courage in real life.)
Instead, we may translate as follows from the Italian:
Write a function in Sage that computes the matrix of the linear map F, written in suitable bases,
from the space VA×VB, where VA=VA(n), VB=VB(n) are two copies of Mn(R)
to the space W=W(n) of endomorphisms of Mn(R),
constructed as follows: For A∈VA and B∈VB we associate F(A,B)=F(A,0)+F(0,B) which acts on a matrix X as follows: F(A,B)(X)=AX+XB.
Then compute the rank for some small values of n.
My choice of the bases is as follows. Let EA(j,k) be the standard generators of VA. And EB(j,k) be the standard generators of VB. It is clear that the family of 2n2 endomorphisms in W of the shape F( EA(j,k),0 ) and F( 0,EB(j,k) ) generate the image of F. We associate the matrix for them and the standard generators of W, which are the homomorphisms E( (s,t)→(u,v) ) mapping all standard generators to zero, except for E(s,t), which is mapped to E(u,v).
It is clear now, that a non-trivial liniar combination leads to an equation of the shape AX+XB≡0, an identity in X. (A and B come by assembling the coefficients in the non-trivial linear combination.) This is the case only for A=−B a diagonal matrix, moreover a scalar times unit matrix. (This was exactly my first exercise in von Neuman algebras.) So the dimension of the kernel is one. The following lines compute the matrix explicitly, and the rank is as expected. The programmer has no problems with the linear algebra, but rather with the reshaping of a matrix as a vector.
def FMatrix( n ):
R = range(n)
A = matrix( QQ, n^4, n^2+n^2 )
count_columns = 0
for j, k in cartesian_product( [R, R] ):
# the elementary matrix (j,k) acts on the vector of morphisms ( (s,t) -> (u,v) )
# first of all from the left, then from the right,
# from the left
count_rows = 0
for s, t, u, v in cartesian_product( [R,R,R,R] ):
# is (j,k) o (s,t) = (u,v) ?
if j == u and k == s and t == v:
A[ count_rows, count_columns ] = 1
count_rows += 1
count_columns += 1
# from the right
count_rows = 0
for s, t, u, v in cartesian_product( [R,R,R,R] ):
# is (s,t) o (j,k) = (u,v) ?
if s == u and t == j and k == v:
A[ count_rows, count_columns ] = 1
count_rows += 1
count_columns += 1
return A
for n in [1..4]:
print "Dimension of W(%s) is: %s" % ( n, FMatrix(n).rank() )
And after a short thrill:
Dimension of W(1) is: 1
Dimension of W(2) is: 7
Dimension of W(3) is: 17
Dimension of W(4) is: 31