The Algebraic Riccati Equation is:
$$A'X + XA - XBR^{-1}B'X + Q = 0$$
And the Algebraic Riccati Difference Equation is:
$$A'X + XA - XBR^{-1}B'X + Q = \frac{dX}{dt}$$
Some times $\frac{dX}{dt}$ is just called $S$ in books.
But is it not possible to solve the Algebraic Riccati Difference Equation through ODE45 and break the simulation when $-tol <= \frac{dX}{dt} <= tol$ ?
You may wonder "Why not use Schur's method to solve the Riccati equations?". Well, Schur's method is a very bad method and there is a reason why MATLAB and Octave are not using it.
Sure, the method find the solution $X$ to the riccati equation, but build a control law $L$ for the LQR controller by using that solution is not what I recommending.
Right now I using fsolve, but that's a built in library in Octave and a function in Optimization package for MATLAB.
Yes it is. Here is the solution:
Step 1: - Create the function. In this case it's CARE
Step 2: - Create your matrices
Step 3: - Simulate
Step 4: - Find the last values for X and generate a matrix x
Step 5: - Check if the solution is almost zero
Yes it is.
Here is the plot how we can se that after a few seconds, the derivative of $X$ is almost zero.
I use this command
....This is a knif....solution :)