Consider, $f(x,u)=\dot{x}(t)=Ax(t)+Bu(t)$, $t\ge 0$, with cost to be minimised such as $J=\frac{1}{2}\int_0^\infty L(x,u) {\rm d}t=\frac{1}{2}\int_0^\infty x^{\rm T}(t)Qx(t)+u^{\rm T}Ru(t){\rm d}t$ and the associated Hamiltonian denoted as $\mathbb{H}=L(x,u)+\lambda^{\rm T}f(x,u)$. Using first order optimality condition $\frac{\partial \mathbb{H}}{\partial u}=0$, it can be shown that the optimal control solution is $u^*=-R^{-1}B^{\rm T}Px(t)$, where $P$ satisfies $A^{\rm T}P+PA+Q-PBR^{-1}B^{\rm T}P=0$. The cost $J$ associated can shown to be equal to $\frac{1}{2}x(t)^{\rm T}Px(t)$ (Quadratic cost).
My question is , I have seen that some authors use a quadratic Lyapunov function the $V=x(t)^{\rm T}Px(t)$ to derive Riccati equation such as this and some times Riccati equation is used to show that the cost is quadratic. I do understand the mathematical derivation in both the cases. I miss to understand the flow. Which comes first?quadratic cost or Riccati? which one is derived with the help of other?
Is it that, since the optimal solution is unique (if and only if), to and fro is valid? I believe, Riccati equation is derived first as a necessary condition for stability and optimality. Then, with $u(t)=-R^{-1}B^{\rm T}P$, where $P$ is the solution of associated Riccati equation we arrive at the condition $J=x(t)^{\rm T}Px(t)$. Please type in if you have a better picture of these associations. Many thanks