Skip to content
Quantoros

For A:10×1000, B:1000×5, C:5×100, which association is cheaper?

MathematicsLevel: IntermediateMatrix geometry and computation

For A:10×1000, B:1000×5, C:5×100, which association is cheaper?

Hints
  • Count m×k×n per multiply.
  • Compare intermediate shapes.

Answer

(AB)C uses about 50,000+5,000 multiplications, versus 500,000+1,000,000 for A(BC). Association changes computation, not the mathematical product.

Source and licence: NumPy — numerical linear algebra · BSD-3-Clause · answer: Quantoros editorial

Related questions