title: Efficient solution of matrix product equality in MATLAB
body: <p>I have the following matrix equation in MATLAB: <a href="https://i.stack.imgur.com/XUg3T.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XUg3T.gif" alt="formula"></a><br>
  </p>
  
  <p>In the subscript in brackets I have written the matrix size.
  I know N, Kt and P and need to solve this equation for the vector Lambda.</p>
  
  <p>The straightforward but slow/naive approach would be:</p>
  
  <pre><code>A = N*inv(Kt)*N';
  Lambda = A\P;
  </code></pre>
  
  <p>What is the most efficient way in which I can solve this equation? It is generally strongly discouraged to use inv(Kt) in Matlab, so what alternative ways might I be able to solve this problem? An attempt that I have made (although I don't know if it is any good, I haven't clocked it) is:</p>
  
  <pre><code>inv_Kt = Kt\speye(size(Kt));
  A = N*inv_Kt*N';
  Lambda = A\P;
  </code></pre>