# Large products of a matrix-valued function [closed]

I have a $3\times 3$ matrix valued function $f(x)$ where $x\in\mathbb{R}$.

I want to perform the following:

$$\prod_{k=a}^b f(k),$$

where $a,b$ are known, but I cant seem to get Mathematica to do it. Any ideas?

I know I have to use .. instead of *, but I want something similar to

Product[f[k],{k,a,b}]


Clearly this won't work since Product works on $\mathbb{C}$ only (at least as far as my knowledge goes)

I have tried

Dot[f[k],{k,a,b}]


but that doesn't work.

• If a,b are known, then Fold[Dot, Table[f[x], {x, a, b}]] will work. – Patrick Stevens Sep 8 '15 at 7:07
• Try Dot @@ Table[f[j], {j, a, b}] – Hubble07 Sep 8 '15 at 7:34
• Dot @@ (f /@ Range[a, b]) – Dr. belisarius Sep 8 '15 at 15:20
• SetAttributes[f, Listable]; Dot @@ f@Range[a, b] – Dr. belisarius Sep 8 '15 at 15:22
• "Put on hold". The mind boggles! – Pixel Sep 11 '15 at 11:57

There's a bunch of comments with upvotes. So, to sum up:

PatrickStevens says to Fold Dot over the List of f[x]'s

Fold[Dot, Table[f[x], {x, a, b}]]


Hubble07 says to try Applying Dot to the Table of f[x]'s.

Dot @@ Table[f[x], {x, a, b}]


belisarius says to Apply Dot to f Mapped over the Range:

Dot @@ f /@ Range[a, b]


or to make the function f Listable:

SetAttributes[f, Listable];
Dot @@ f@Range[a, b]


One more version:

Fold[Dot, Array[f, b - a + 1, a]]
Dot @@ Array[f, b - a + 1, a]
Array[f, b - a + 1, a, Dot]

• Do all of these methods result in the full list of matrices being put into memory simultaneously? – ComptonScattering Aug 14 '17 at 22:06
• @ComptonScattering. I believe so. You want something that generates the matrices on the fly as they're multiplied together? Maybe something like Fold[#1.f[#2] &, f[a], Range[a + 1, b]]? Or maybe it should be Fold[f[#2].#1 &, f[a], Range[a + 1, b]]; order matters of course, – march Aug 14 '17 at 22:22
• I see what you have done. This has been very useful for me to understand. Thank you. – ComptonScattering Aug 15 '17 at 1:25