# Nested Matrix Dotproduct

For a given matrix M[n] of size $n\times n$ I want to define the following list of matrix-expressions:

n=1
{Tr[M]}

n=2
{Tr[M]^2,Tr[M.M]}

n=3
{Tr[M]^3,Tr[M]Tr[M.M],Tr[M.M.M]}


How could I generalize this relation for arbitrary $n$? I tried Nest and NestList. Thanks!

• How about n=4? – Αλέξανδρος Ζεγγ May 18 '18 at 10:43
• n=4: {{Tr[M]^4,Tr[M]^2Tr[M.M],Tr[M] Tr[M.M.M],Tr[M.M.M.M]}} – Ulrich Neumann May 18 '18 at 10:48
• Are you sure that you don't want Tr[M.M]^2 or Tr[M]^3 Tr[M]? What is the building scheme behind this? – Henrik Schumacher May 18 '18 at 11:08
• I consider a sheme which contains basically a list of dotproducts Map[Tr[#]&,{M,M.M,M.M.M,...}]. The resulting list elements are scaled by Tr[M]^n. – Ulrich Neumann May 18 '18 at 11:24

f[k_] := Table[Tr[M @ k]^(k - i) Array[M @ k &, i, 1, Tr @ Dot @ ## &], {i, k}]

f /@ Range // Column // TeXForm


$\tiny\begin{array}{l} \{\text{Tr}[M(1)]\} \\ \left\{\text{Tr}[M(2)]^2,\text{Tr}[M(2).M(2)]\right\} \\ \left\{\text{Tr}[M(3)]^3,\text{Tr}[M(3).M(3)] \text{Tr}[M(3)],\text{Tr}[M(3).M(3).M(3)]\right\} \\ \left\{\text{Tr}[M(4)]^4,\text{Tr}[M(4).M(4)] \text{Tr}[M(4)]^2,\text{Tr}[M(4).M(4).M(4)] \text{Tr}[M(4)],\text{Tr}[M(4).M(4).M(4).M(4)]\right\} \\ \left\{\text{Tr}[M(5)]^5,\text{Tr}[M(5).M(5)] \text{Tr}[M(5)]^3,\text{Tr}[M(5).M(5).M(5)] \text{Tr}[M(5)]^2,\text{Tr}[M(5).M(5).M(5).M(5)] \text{Tr}[M(5)],\text{Tr}[M(5).M(5).M(5).M(5).M(5)]\right\} \\ \end{array}$

• That's it, thank you! – Ulrich Neumann May 18 '18 at 11:47
• @UlrichNeumann, my pleasure. – kglr May 18 '18 at 11:52
• @UlrichNeumann kglr's solution seems to fit your requirements, and sufficient time has elapsed without any better implementations. You might consider formally accepting his answer then! You can do so by clicking on the grey check mark next to the answer. – MarcoB May 22 '18 at 16:38

listVonMat[M_] := Module[{n = Length[M], inter1, inter2},
inter1 = TakeDrop[Table[M, n], #] & /@ Range[n - 1, 0, -1];
inter2 = {Times @@ Tr /@ #1, Tr @ (Dot @@ #2)} & @@@ inter1;
Times @@@ inter2
]


Maybe numerical results are easier to be checked with:

listVonMat[Partition[Range[#^2], #]] & /@ Range


returns

{
{1},
{25, 29},
{3375, 3915, 4185},
{1336336, 1521296, 1613776, 1719056}
}


Update

To show that the scheme is indeed implemented, run, e.g., codes below

TakeDrop[{a, a, a, a}, #] & /@ Range[3, 0, -1]
Times @@@ ({Times @@ Tr /@ #1, Tr @ (Dot @@ #2)} & @@@ %)


and one gets

{{{a, a, a}, {a}}, {{a, a}, {a, a}}, {{a}, {a, a, a}}, {{}, {a, a, a, a}}}
{Tr[a]^4, Tr[a]^2 Tr[a.a], Tr[a] Tr[a.a.a], Tr[a.a.a.a]}

• Thank you for your solution – Ulrich Neumann May 18 '18 at 12:08
• @Ulrich Neumann You're welcome. But it seems that I made things harder :( – Αλέξανδρος Ζεγγ May 18 '18 at 12:31