need help understanding this transformation step in Riccati equation to Lyapunov equation

62 Views Asked by At

In this note Discrete LQR note, I am not understanding the transition from equation (4) to (5) on page 14.

In particular, I don't get this step:

$$ (A-BK_{s})^{\top}{P_s}(A-BK_{s}) + 2A^{\top}{P_{s}}BK_{s} - K_{s}^{\top}B^{\top}P_{s}BK_{s} + C^{\top}C - K^{\top}(R + B^{\top}PB)K \\ = (A-BK_{s})^{\top}{P_s}(A-BK_{s}) + C^{\top}C + K_{s}^{\top}RK_{s} $$ What is the trick used here?