title: Which way has better accuracy to compute the matrix matrix vector product, A B u?
body: <p>I want to compute the vector,</p>
  
  <p>s = A B u,</p>
  
  <p>where s and u are N-dimensional complex vector, A is a N-by-M complex matrix, B is M-by-N complex matrix. Which of the following two ways has better accuracy (more significant digits) when the elements of A, B, and u are represented as floating-point numbers?</p>
  
  <p>(1) Computing B u first.</p>
  
  <p>First do the matrix-vector multiplication,</p>
  
  <p>y = B u</p>
  
  <p>Then, another matrix-vector multiplication</p>
  
  <p>s = A y</p>
  
  <p>(2) Computing A B first.</p>
  
  <p>First do the matrix-matrix multiplication,</p>
  
  <p>C = A B</p>
  
  <p>Then, matrix-vector multiplication</p>
  
  <p>s = C u</p>
  
  <p>Is there any known general rule?</p>
  
  <p>By the way, I understand that the method (1) is much more efficient than method (2).</p>