The corresponding convergence rate in the Recursive Least Squares (RLS) algorithm is faster, but the implementation is more complex than that of LMS-based algorithms.

The (RLS algorithm uses the following equations to modify the cost function J(k) = E[e2(k)].

Jk=Ee2k1Ni=0N-1θ2k-1

Compare this modified cost function, which uses the previous N error terms, to the cost function, J(k) =  E[e2(k)], which uses only the current error information e(k). The modified cost function J(k) is more robust.

The following procedure describes how to implement the RLS algorithm:

  1. Initialize the parametric vector ⃗w(k) using a small positive number ε.

    w0=ε, ε,..., εT

  2. Initialize the data vector ⃗φ(k).
  3. Initialize the k × k matrix P(0).

    P0=ε0000ε0000...0000ε

  4. For k = 1, update the data vector ⃗φ(k) based on ⃗φ(k-1) and the current input data u(k) and output data y(k).
  5. Compute the predicted response ŷ(k) by using the following equation.

    y^k=φTk·wk

  6. Compute the error e(k) by solving the following equation:

    ek=yk-y^k

  7. Update the gain vector ⃗k(k) defined by the following equation:

    Kk=Pk·φkλ+φT·Pk·φk

    The properties of a system might vary with time, so you must ensure that the algorithm tracks the variations. You can use the forgetting factor λ, which is an adjustable parameter, to track these variations. The smaller the forgetting factor λ, the less previous information this algorithm uses. When you use small forgetting factors, the adaptive filter is able to track time-varying systems that vary rapidly. The range of the forgetting factor λ is between zero and one, typically 0.98 < λ < 1. P(k) is a k × k matrix whose initial value is defined by P(0) in step 3.
  8. Update the parametric vector
    wk+1
    .

    wk+1=wk+ek·Kk

  9. Update the P(k) matrix.

    Pk+1=λ-1Pk-λ-1Kk·φTk·Pk

  10. Stop if the error is small enough, else set k = k + 1 and repeat steps 4–10.