Exercise 2.4.36

Answers

Multiplying AB = (m by n)(n by p) needs mnp multiplications. Then (AB)C needs mpq more. Multiply BC = (n by p)(p by q) needs npq and then A(BC) needs mnq.

(a)
If m,n,p,q are 2,4,7,10 we compare (2)(4)(7) + (2)(7)(10) = 196 with the larger number (2)(4)(10) + (4)(7)(10) = 360. So AB first is better, we want to multiply that 7 by 10 matrix by as few rows as possible.
(b)
If u,v,w are N by 1 , then (uTv)wT needs 2N multiplications but uT (vwT) needs N2 to find vwT and N2 more to multiply by the row vector uT. Apologies for using the transpose symbol so early.
(c)
We are comparing mnp + mpq with mnq + npq. Divide all terms by mnpq. Now we are comparing q1 + n1 with p1 + m1. This yields a simple important rule. If matrices A and B are multiplying v for ABv, don’t multiply the matrices first. Better to multiply Bv and then A(Bv).
User profile picture
2021-12-06 18:23
Comments