title: Octave: which method is more efficient
body: <p>I am trying some machine learning algorithms in GNU Octave like the squared error cost function.  The text I have says the proper vectorized forumula is:</p>
  
  <pre><code>J = (X * theta - y)' * (X * theta - y) * (1/(2*m)
  </code></pre>
  
  <p>where X is an  <code>m x n+1</code> matrix, theta is a <code>n+1 x 1</code> vector, and y is a <code>m x 1</code> vector.  My question is whether this second way is a bit faster:</p>
  
  <pre><code>J = sum((X * theta - y).^2) * (1/(2*m))
  </code></pre>
  
  <p>since it only calculates <code>X * theta -y</code> once.  Being new to octave, which seems to run in a very temperamental environment on windows, I don't know how to do benchmarking myself.  </p>
  
  <p>Since this is more of curiosity than anything, feel free to tell me it just doesn't even matter.</p>