CS application algorithmsOne of the properties of matrix mul
(CS application: algorithms)One of the properties of matrix multiplication is that it is associative. That is, if we have matrices A,B, and C with dimensions that allow them to be multiplied as ABC, then A(BC) = (AB)C. However, the amount of multiplications and additions may not be identical for both orderings.
(a) If A has dimensions 3×2,B has dimensions 2×4, and C has dimensions 4×5, then what is the total number of multiplications and the total number of additions for each of the two orderings?
(b) Also, if A,B, and C have dimensions m×n,n×p, and p×q, respectively, what are the formulae for the number of multiplications and additions for each ordering? You should show that you derived these formulae.You should produce separate values and formulae for the multiplications and additions; don’t combine them. For example, you might find that A(BC) with the dimensions given above requires 100 multiplications and 80 additions with the generic formula for multiplications being mn+pq and the generic formula for additions being m+n+p.
Solution
a) amount of multiplication = m*n*p + n*p*q = 3*2*4 + 2*4*5= 24+ 40 = 64
amount of addition = m+n+p = 3+2+4 = 9
b) amount of multiplication = m*n*p + n*p*q
amount of addition = m+n+p
