title: Number of flops in Gaussian Elimination Matlab code
body: <p>I am having a hard time trying to understand why this Matlab code to perform Gaussian Elimination without pivoting using LU factorization takes <code>(2/3) * n^3</code> flops. (FLOPs: floating point operations and <strong>not</strong> FLOPS: floating point operations per second)</p>
  
  <pre><code>function x = GaussianElimination(A,b)
  
  n = length(b);
  for k = 1:n-1
      for i = k+1:n
          mult = A(i,k)/A(k,k);
          A(i,k+1:n) = A(i,k+1:n)-mult*A(k,k+1:n);
          b(i) = b(i) - mult*b(k);
      end
  end
  
  x = zeros(n,1);
  x(n) = b(n)/A(n,n);
  
  for k = n-1:-1:1
      x(k) = (b(k) - A(k,k+1:n)*x(k+1:n))/A(k,k);
  end
  
  end
  </code></pre>
  
  <p>If anyone could explain to me how flops are counted for those nested loops that start at <code>k+1</code> I would be grateful.</p>
  
  <p>PS: I am not talking about algorithmic complexity here.</p>