title: Complexity of recursive least squares (RLS) algorithm
body: <p>Which operation(s) make the complexity of <a href="https://en.wikipedia.org/wiki/Recursive_least_squares_filter" rel="nofollow noreferrer">recursive least squares (RLS)</a> algorithm is equal to O(n^2) and why?</p>
  
  <pre><code>% Filter Parameters
  p       = 4;                % filter order
  lambda  = 1.0;              % forgetting factor
  laminv  = 1/lambda;
  delta   = 1.0;              % initialization parameter
  w       = zeros(p,1);       % filter coefficients
  P       = delta*eye(p);     % inverse correlation matrix
  e       = x*0;              % error signal
  for m = p:length(x)
      % Acquire chunk of data
      y = n(m:-1:m-p+1);
      % Error signal equation
      e(m) = x(m)-w'*y;
      Pi = P*y; % Parameters for efficiency
      % Filter gain vector update
      k = (Pi)/(lambda+y'*Pi);  
      P = (P - k*y'*P)*laminv;  % Inverse correlation matrix update
      w = w + k*e(m);  % Filter coefficients adaption
  end
  </code></pre>
  
  <p><a href="https://www.mathworks.com/matlabcentral/fileexchange/36858-recursive-least-squares-filter" rel="nofollow noreferrer">full code</a></p>