Number of additions in naive matrix multiplication

algorithmsmatrices

In the naive matrix multiplication algorithm where you have 3 loops, the total number of multiplications is $n^2(n)=n^3$ given that we have two matrices each with size $n\times n$. But a proof claims that the number of additions is $(n-1)$, so the total number of additions is $n^2(n-1)$. I don't understand how the number of additions is $(n-1)$ as I think it should be $n$ because whenever we multiply we add that element, so we should have the same number of multiplications $n$?

Best Answer

When you add $n$ terms there are only $n-1$ additions. For example, $1+2+3$ has only two additions. You are making a fencepost error.

Related Question