Let Anxn be a given square matrix. Compute the number of multiplications and additions required to evaluate A28 using
a) the naive method, A28 = A x A x A ......... A (28 times)
b) A2, A4 = A2 x A2 etc.
Solution:
a) For the given square matrix, A x A has
no of multiplication = n x n x n = n3
no of addition = (n-1) x n x n = n3 - n2
For total of 28 times,
no of multiplication = 27 n3
no of addition = 27(n3 - n2)
b)
Step 1
A2 = A x A
Step 2
A4 = A2 x A2
Step 3
A8 = A4 x A4
Step 4
A16 = A8 x A8
Step 5
A12 = A8 x A4
Step 6
A28 = A16 x A12
Total no of steps required = 6
So, total no of multiplication and addition 6n3 and 6(n3 - n2) respectively.