# Express block matrix in terms of matrix basis

I'm trying to construct a function that returns the multiplication table of a matrix Lie algebra. Assuming a basis of matrices, my definitions:

Commutator[A_, B_] := A.B - B.A;
MultiplicationTable[basis_] :=  Outer[Commutator[#1, #2] &, basis, basis, 1]


yield a matrix comprising smaller matrices of numbers. The final step would be to rewrite this matrix, so that it is expressed in terms of the basis matrices. This is not a simple find-and-replace rule, because multiples of a matrix cannot be found this way. Any help is welcome.

# Example

The Lie algebra so(2,1) is generated by

 H = {{0, 1, 0}, {-1, 0, 0}, {0, 0, 0}};
E1 = {{0, 0, 1}, {0, 0, 0}, {1, 0, 0}};
E2 = {{0, 0, 0}, {0, 0, 1}, {0, 1, 0}};
Basis = {H, E1, E2};


and the output of MultiplicationTable is

$$\begin{pmatrix} \begin{pmatrix} 0 & 0 & 0\\ 0& 0& 0\\ 0& 0 & 0 \end{pmatrix} & \begin{pmatrix} 0 & 0 & 0\\ 0 & 0 & -1\\ 0 & -1 & 0 \end{pmatrix} & \begin{pmatrix} 0 & 0 & 1\\ 0 & 0 & 0\\ 1 & 0 & 0 \end{pmatrix}\\ \begin{pmatrix} 0 & 0 & 0\\ 0 & 0 & 1\\ 0 & 1& 0\end{pmatrix} & \begin{pmatrix} 0 & 0 & 0\\ 0& 0& 0\\ 0& 0 & 0 \end{pmatrix} & \begin{pmatrix} 0 & 1 & 0\\ -1 & 0 & 0\\ 0 & 0 &0 \end{pmatrix} \\ \begin{pmatrix} 0 & 0 & -1\\ 0 & 0 & 0\\-1 & 0 &0 \end{pmatrix} & \begin{pmatrix} 0 & -1 & 0\\ 1 & 0 & 0\\ 0 & 0 & 0 \end{pmatrix} & \begin{pmatrix} 0 & 0 & 0\\ 0& 0& 0\\ 0& 0 & 0 \end{pmatrix} \end{pmatrix}.$$

I would like the output to be in the form

$$\begin{pmatrix} 0 & -E2 & E1\\ E2 & 0 & H\\ -E1 & -H &0 \end{pmatrix},$$ because the multiplication table of algebras of higher dimension quickly becomes huge.

• examples might help – Mr.Wizard Apr 15 '15 at 14:54

## 4 Answers

(Note, it's best practice to use lowercase symbols to avoid conflicts with builtins.)

multiplicationTable[basis_] :=
Outer[LinearSolve[Transpose[Flatten /@ basis],
Flatten[commutator[##]]] &, basis, basis, 1]


If we turn each matrix in the basis and the commutator into a vector, we can find a linear combination of basis elements that equal the commutator using standard linear algebra (in this case, LinearSolve).

multiplicationTable[basis]

(* {
{{0,  0, 0}, { 0, 0, -1}, {0, 1, 0}},
{{0,  0, 1}, { 0, 0,  0}, {1, 0, 0}},
{{0, -1, 0}, {-1, 0,  0}, {0, 0, 0}}
} *)


If you want to see the sum as an expression, we can Dot with a string representation of the basis (if we just used basis we'd end up with your original expression):

multiplicationTable[basis].{"H", "E1", "E2"} // MatrixForm

(* 0 -E2 E1
E2   0  H
-E1   H  0 *)

• Thanks, this is very close to what I was looking for. Please check my answer and feel free to add the changes I made to yours, so that I accept yours and delete mine. – auxsvr Apr 16 '15 at 8:28

This is essentially 2012rcampion's answer using Association for Basis. The definitions are:

 commutator[A_, B_] := A.B - B.A;
multiplicationTable[basis_] := Outer[LinearSolve[Transpose[Flatten /@  Values[basis]],
Flatten[commutator[#1, #2]]] &, Values@basis, Values@basis, 1].Keys[basis]


and the basis:

 Basis = Association["H" -> H, "E1" -> E1, "E2" -> E2];


yielding

 multiplicationTable[Basis] // MatrixForm


$$\begin{pmatrix} 0 & -\text{E2} & \text{E1} \\ \text{E2} & 0 & \text{H} \\ -\text{E1} & -\text{H} & 0 \end{pmatrix}.$$

Further definitions useful for study of group theory:

 adjoint[X_, basis_] := Outer[Normalize[Flatten[#1]]\[Conjugate].Normalize[
Flatten[commutator[X, #2]]] &, Values@basis, Values@basis, 1]


to obtain the adjoint or regular representation of a generator, and

 CKmetric[basis_] := Outer[Tr[adjoint[#1, basis].adjoint[#2, basis]] &,
Values@basis, Values@basis, 1]


to obtain the Cartan-Killing metric.

There may be a more efficient way to compute your MultiplicationTable itself but as a post-processing measure you could use something like this:

rules = Join[
Thread[Basis -> {"H", "E1", "E2"}],
Thread[-Basis -> {"-H", "-E1", "-E2"}],
{m_ /; MatrixQ[m, # == 0 &] :> 0}
];

Replace[MultiplicationTable[Basis], rules, {2}]

{{0, "-E2", "E1"}, {"E2", 0, "H"}, {"-E1", "-H", 0}}


You could use HoldForm rather than strings if you wish to reuse the output by way of ReleaseHold.

• You can half the number of matrix multiplications by using # - Transpose[#] & [Outer[Dot, basis, basis, 1]] – 2012rcampion Apr 15 '15 at 17:47

The answers provided here are good. But I would lean towards using group-theoretic properties rather than just a LinearSolve.

innerProduct[a_,b_]:=1/2 Tr[ConjugateTranspose[a].b] (* Usually *)
groupSolve[basis_,names_][matrix_]:=Total[MapThread[
innerProduct[#1,matrix] #2 &,{basis,names}
]]


which then can be used with

multiplicationTable[basis_, names_]:=Outer[groupSolve[basis,names][Commutator[#1,#2]]&,
basis,basis,1]


via multiplicationTable[Basis,{"H","E1","E2"}].

• Would you mind including reasoning or examples to support your position that this is superior? – Mr.Wizard May 5 '15 at 0:24
• Mainly: if you have additional information about the problem, why not use it? I don't have a claim that it's superior. But it's how I would have solved the problem, given knowledge that it was a problem of group theory. – evanb May 5 '15 at 17:50