# 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[1]]}

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

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


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

• How about n=4? Commented May 18, 2018 at 10:43
• n=4: {{Tr[M[4]]^4,Tr[M[4]]^2Tr[M[4].M[4]],Tr[M[4]] Tr[M[4].M[4].M[4]],Tr[M[4].M[4].M[4].M[4]]}} Commented May 18, 2018 at 10:48
• Are you sure that you don't want Tr[M[4].M[4]]^2 or Tr[M[4]]^3 Tr[M[4]]? What is the building scheme behind this? Commented May 18, 2018 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. Commented May 18, 2018 at 11:24

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

f /@ Range[5] // 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! Commented May 18, 2018 at 11:47
• @UlrichNeumann, my pleasure.
– kglr
Commented May 18, 2018 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. Commented May 22, 2018 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[4]


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 Commented May 18, 2018 at 12:08
• @Ulrich Neumann You're welcome. But it seems that I made things harder :( Commented May 18, 2018 at 12:31