0
$\begingroup$

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]?

$\endgroup$

closed as off-topic by MarcoB, march, corey979, Feyre, m_goldberg Feb 8 '17 at 19:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, march, corey979, Feyre, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Why not just put parentheses around the matrix multiplications according to the desired order? $\endgroup$ – David G. Stork Feb 8 '17 at 17:29
  • $\begingroup$ 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 $\endgroup$ – NessunDorma Feb 8 '17 at 17:36
  • $\begingroup$ I'm sorry David G. Stork, you are totally right, that can be done by making: M1....M4(M5...M11(M12...M15[x])) $\endgroup$ – NessunDorma Feb 8 '17 at 17:55
  • $\begingroup$ Incidentally this question may be useful: mathematica.stackexchange.com/q/83412/121 $\endgroup$ – Mr.Wizard Feb 8 '17 at 20:01
2
$\begingroup$

[Just so we can close this question as being solved:]

Place parentheses around the grouped matrices, e.g.,

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

etc.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.