Collapsing a Chain of Matrices.
Consider the composite function ABCD, i.e. p’ = ABCDp
Matrix multiplication isn’t commutative - the order is important
But matrix multiplication is associative, so can calculate from right to left or left to right: ABCD = (((AB) C) D) = (A (B (CD))).
Iteratively replace either the leading or the trailing pair by its product
- Postmultiply: left-to-right (reverse of function application.)
- Premultiply: right-to-left (same as function application.)