📖 Explanation
To find the minimum number of scalar multiplications for multiplying four matrices M1,M2,M3,M4 with given dimensions p×q,q×r,r×s,s×t, we use the dynamic programming approach for matrix chain multiplication.
Given dimensions: p=10,q=100,r=20,s=5,t=80.
The possible parenthesizations are:
-
((M1×M2)×M3)×M4:
- (M1×M2) costs pqr=10×100×20=20000. Resulting matrix is 10×20.
- ((M1×M2)×M3) costs (pqr)+(prs)=20000+(10×20×5)=20000+1000=21000. Resulting matrix is 10×5.
- (((M1×M2)×M3)×M4) costs (pqr+prs)+(pst)=21000+(10×5×80)=21000+4000=25000.
-
(M1×(M2×M3))×M4:
- (M2×M3) costs qrs=100×20×5=10000. Resulting matrix is 100×5.
- (M1×(M2×M3)) costs (qrs)+(pqs)=10000+(10×100×5)=10000+5000=15000. Resulting matrix is 10×5.
- ((M1×(M2×M3))×M4) costs (qrs+pqs)+(pst)=15000+(10×5×80)=15000+4000=19000.
-
(M1×M2)×(M3×M4):
- (M1×M2) costs pqr=10×100×20=20000. Resulting matrix is 10×20.
- (M3×M4) costs rst=20×5×80=8000. Resulting matrix is 20×80.
- ((M1×M2)×(M3×M4)) costs (pqr)+(rst)+(prt)=20000+8000+(10×20×80)=28000+16000=44000.
Comparing the costs: 25000,19000,44000. The minimum number of scalar multiplications is 19000.