Matrix multiplication is not Commutative but it's Associative. If we have 4 matrices A1,A2,A3,A4 then we can multiply them using any of the following possible 5 ways:
Our job is to parenthesize these matrix in such a way that number of scalar multiplications are minimized:
If we multiply M1, M2, M3, M4, M5, M6 such as ((M1xM2)x((M3xM4)x(M5xM6))), total multiplications will be required 2010.