There is no analytic method and for real-world problems in control theory, you do not need an analytic solution.
Here is the solution suggested from Vasile Sima which I wrote the C++ codes based upon here.
/*
This file contains a continuous-time algebraic Riccati equation solver based on the explanations from Dr. Vasile Sima.
Further reference: Sima, Vasile. Algorithms for linear-quadratic optimization. Vol. 200. CRC Press, 1996.
*/
// A C++ implementation of a Continuous-time Algebraic Riccati Equation (CARE) solver based on Schur vectors.
// Solves a CARE, A'X + XA - XBR^(-1)B'X + Q = 0, using Schur vectors method, with A and Q n-by-n, B n-by-m, and R m-by-m real matrices, and Q and R symmetric, R positive definite. It is assumed, e.g., that the matrix pair (A,B) is stabilizable, and the matrix pair (C,A) is detectable, where Q = C'C, and rank(C) = rank(Q).
// Main steps:
// 1. Construct the Hamiltonian matrix H, H = [ A -B*(R\B'); Q -A' ]; (in MATLAB notation).
// 2. Reduce H to a real Schur form S and accumulate the transformations in U, S = U'HU, U orthogonal.
// 3. Reorder the real Schur form S so that all n stable eigenvalues are moved to the leading part of S, accumulating the transformations in U.
// 4. Compute the unique positive-semidefinite stabilizing solution X, X = U(n+1:2n,1:n)*U(1:n,1:n)^(-1).
// 5. Symmetrize X, X = ( X + X' )/2.
If you are using MATLAB, you can simply use care, dare and even lqg commands.
An ad-hoc solution is using Genetic Algorithm to solve these problems via C++ (solver, NLP demo) or MATLAB.
With respect to uniqueness:
Consider the $vec(\cdot)$ operator that stacks the columns of a matrix into one long vector and define $\otimes$ for the Kronecker product of two matrices. If we apply the $vec(\cdot)$ operator to the Lyapunov equation we have
$$vec\left(S\right)-vec\left(A^TSA\right)=vec(Q)$$
Equivalently we have
$$[\mathbb{I}-(A^T\otimes A^T)]vec\left(S\right)=vec(Q)$$
and a unique solution exists iff the matrix $\mathbb{I}-(A^T\otimes A^T)$ is invertible. Matrix $A^T\otimes A^T$ has $n^2$ eigenvalues $\lambda_i\lambda_j$ ($1\leq i,j\leq n$) and therefore the eigenvalues of $\mathbb{I}-(A^T\otimes A^T)$ are $1-\lambda_i\lambda_j$. So a necessary and sufficient condition for uniqueness is
$$\lambda_i\lambda_j\neq 1\qquad \forall i,j=1,\cdots,n$$
A sufficient condition for uniqueness is therefore the stability of $A$ ($|\lambda_i|<1$).
Also if $A$ stable then the above series $S_{\infty}$ converges and one can directly verify by substitution that this is a solution (unique) of the Lyapunov equation.
Best Answer
Lyapunov equation is used for the stability analysis of a relaxed system, I.e. no input signal. There exists a unique positive definite $P$ for any given positive definite $Q$ if and only if the system $\dot{x}=Ax$ is globally asymptotically stable. This means we can make $\dot{V}$ arbitrarily small where $V$ is the quadratic Lyapunov function $V(x)=x^T Px$.
On the other hand, Riccati equation appears in LQR and LQE problems. The first one is used to find the optimal regulator that minimizes quadratic cost function. The second one is used to estimate the state variables from the output when there is measurement noise. First problem deals with input and second deals with output. This is why the extra term appears.
These two problems are dual and convertible to each other. Together these problems makes LQG problem.