# Splitting a chain of matrix multiplications [closed]

I have defined a matrix function in terms of a chain of matrix multiplications:

f[x_]:=M1.M2[x].M3...M15[x]


where just some of the 15 matrices M depend on x. However, I want to define this function by parts, putting together groups of matrices, for instance:

In order to compute f[x] I want, by definition of f[x], that Mathematica computes it in the follow order

1. M12.M13...M15[x]
2. M5.M6...M11.(result of 1.)
3. M1.M2[2]...M4.(result of 2.)

How can I include this procedure in the definition of f[x]?

• Why not just put parentheses around the matrix multiplications according to the desired order? Feb 8, 2017 at 17:29
• Because that makes the computation as difficult as to perform the whole chain at once. The idea is to use memory to save computational time, storing partial results instead of computing the chain as a whole Feb 8, 2017 at 17:36
• I'm sorry David G. Stork, you are totally right, that can be done by making: M1....M4(M5...M11(M12...M15[x])) Feb 8, 2017 at 17:55
• Incidentally this question may be useful: mathematica.stackexchange.com/q/83412/121 Feb 8, 2017 at 20:01

f[x_] := M1.((M2.M3[x]).(M4.M5[x])).M6