The equation

, with a negative definite
c, yields a unique positive definite solution if and only if the eigenvalues of
a are in the closed left-half plane:
The definite integral

is the solution to

if
a is asymptotically stable:
Compute the infinite-horizon quadratic cost for the asymptotically stable system

:
Solve the matrix equation

:
Solve the Lyapunov equation

using
LinearSolve: