Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

HJB Formulation of the Finite-Horizon Linear Quadratic Regulator

This session applies the Hamilton–Jacobi–Bellman equation to the finite-horizon linear quadratic regulator (LQR). The objective is to recover, using dynamic programming, the same matrix Riccati differential equation and state-feedback law obtained previously from the calculus of variations and Pontryagin’s minimum principle.

The importance of this derivation is not merely algebraic. It shows that the Riccati equation is a direct consequence of the HJB partial differential equation when the system is linear and the cost is quadratic.

Finite-Horizon LQR Problem

Consider the time-varying linear system

x˙(t)=A(t)x(t)+B(t)u(t),x(t0)=x0.\boxed{ \dot{\boldsymbol{x}}(t)=\boldsymbol{A}(t)\boldsymbol{x}(t)+\boldsymbol{B}(t)\boldsymbol{u}(t), \qquad \boldsymbol{x}(t_0)=\boldsymbol{x}_0. }

The finite-horizon quadratic cost is

J=12xT(tf)Sfx(tf)+12t0tf[xT(t)Q(t)x(t)+uT(t)R(t)u(t)]dt.\boxed{ J= \frac{1}{2}\boldsymbol{x}^\mathsf{T}(t_f)\boldsymbol{S}_f\boldsymbol{x}(t_f) + \frac{1}{2} \int_{t_0}^{t_f} \left[ \boldsymbol{x}^\mathsf{T}(t)\boldsymbol{Q}(t)\boldsymbol{x}(t) + \boldsymbol{u}^\mathsf{T}(t)\boldsymbol{R}(t)\boldsymbol{u}(t) \right]\,\mathrm{d} t. }

Assume

Q(t)=QT(t)0,R(t)=RT(t)0,Sf=SfT0.\begin{aligned} \boldsymbol{Q}(t)&=\boldsymbol{Q}^\mathsf{T}(t)\succeq 0,\\ \boldsymbol{R}(t)&=\boldsymbol{R}^\mathsf{T}(t)\succ 0,\\ \boldsymbol{S}_f&=\boldsymbol{S}_f^\mathsf{T}\succeq 0. \end{aligned}

The positive definiteness of R\boldsymbol{R} guarantees that the Hamiltonian is strictly convex in the control.

Structural Assumptions

For the classical finite-horizon LQR problem, one often assumes that

These assumptions ensure that the problem is well posed and that the resulting feedback law has the expected properties.

Cost-to-Go Function

At an arbitrary state x\boldsymbol{x} and time tt, define the optimal cost-to-go

J(x,t)=minu()[12xT(tf)Sfx(tf)+12ttf(xTQx+uTRu)dτ].J^*(\boldsymbol{x},t) = \min_{\boldsymbol{u}(\cdot)} \left[ \frac{1}{2}\boldsymbol{x}^\mathsf{T}(t_f)\boldsymbol{S}_f\boldsymbol{x}(t_f) + \frac{1}{2} \int_t^{t_f} \left( \boldsymbol{x}^\mathsf{T}\boldsymbol{Q}\boldsymbol{x} + \boldsymbol{u}^\mathsf{T}\boldsymbol{R}\boldsymbol{u} \right)\,\mathrm{d}\tau \right].

The terminal condition is

J(x,tf)=12xTSfx.\boxed{ J^*(\boldsymbol{x},t_f) = \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{S}_f\boldsymbol{x}. }

Hamiltonian in the HJB Formulation

The running cost is

L(x,u,t)=12xTQx+12uTRu.L(\boldsymbol{x},\boldsymbol{u},t) = \frac{1}{2} \boldsymbol{x}^\mathsf{T}\boldsymbol{Q}\boldsymbol{x} + \frac{1}{2} \boldsymbol{u}^\mathsf{T}\boldsymbol{R}\boldsymbol{u}.

The dynamics are

f(x,u,t)=Ax+Bu.\boldsymbol{f}(\boldsymbol{x},\boldsymbol{u},t) = \boldsymbol{A}\boldsymbol{x}+\boldsymbol{B}\boldsymbol{u}.

The HJB Hamiltonian is therefore

H=12xTQx+12uTRu+JxT(Ax+Bu).\boxed{ \mathcal{H} = \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{Q}\boldsymbol{x} + \frac{1}{2}\boldsymbol{u}^\mathsf{T}\boldsymbol{R}\boldsymbol{u} + J_{\boldsymbol{x}}^{*\mathsf{T}} (\boldsymbol{A}\boldsymbol{x}+\boldsymbol{B}\boldsymbol{u}). }

Here,

Jx=xJ(x,t).J_{\boldsymbol{x}}^* = \nabla_{\boldsymbol{x}}J^*(\boldsymbol{x},t).

Optimal Control from Hamiltonian Minimization

The optimal control minimizes the Hamiltonian:

u=argminuH.\boldsymbol{u}^* = \arg\min_{\boldsymbol{u}}\mathcal{H}.

Differentiate with respect to u\boldsymbol{u}:

Hu=Ru+BTJx.\frac{\partial\mathcal{H}}{\partial\boldsymbol{u}} = \boldsymbol{R}\boldsymbol{u} + \boldsymbol{B}^\mathsf{T}J_{\boldsymbol{x}}^*.

The first-order condition is

Ru+BTJx=0.\boldsymbol{R}\boldsymbol{u}^* + \boldsymbol{B}^\mathsf{T}J_{\boldsymbol{x}}^* = \boldsymbol{0}.

Because R0\boldsymbol{R}\succ0,

u=R1BTJx.\boxed{ \boldsymbol{u}^* = - \boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T}J_{\boldsymbol{x}}^*. }

This is already a feedback relationship, although the value-function gradient is not yet known.

Reduced Optimal Hamiltonian

Substitute

u=R1BTJx\boldsymbol{u}^* = - \boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T}J_{\boldsymbol{x}}^*

into the Hamiltonian.

First,

12uTRu=12JxTBR1BTJx.\begin{aligned} \frac{1}{2}\boldsymbol{u}^{*\mathsf{T}}\boldsymbol{R}\boldsymbol{u}^* &= \frac{1}{2} J_{\boldsymbol{x}}^{*\mathsf{T}} \boldsymbol{B}\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T} J_{\boldsymbol{x}}^*. \end{aligned}

Second,

JxTBu=JxTBR1BTJx.\begin{aligned} J_{\boldsymbol{x}}^{*\mathsf{T}}\boldsymbol{B}\boldsymbol{u}^* &= - J_{\boldsymbol{x}}^{*\mathsf{T}} \boldsymbol{B}\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T} J_{\boldsymbol{x}}^*. \end{aligned}

Therefore,

H=12xTQx12JxTBR1BTJx+JxTAx.\boxed{ \mathcal{H}^* = \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{Q}\boldsymbol{x} - \frac{1}{2} J_{\boldsymbol{x}}^{*\mathsf{T}} \boldsymbol{B}\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T} J_{\boldsymbol{x}}^* + J_{\boldsymbol{x}}^{*\mathsf{T}}\boldsymbol{A}\boldsymbol{x}. }

Hamilton–Jacobi–Bellman PDE

The HJB equation is

Jt+H=0.J_t^* + \mathcal{H}^* = 0.

Thus,

Jt+12xTQx12JxTBR1BTJx+JxTAx=0.\boxed{ J_t^* + \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{Q}\boldsymbol{x} - \frac{1}{2} J_{\boldsymbol{x}}^{*\mathsf{T}} \boldsymbol{B}\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T} J_{\boldsymbol{x}}^* + J_{\boldsymbol{x}}^{*\mathsf{T}}\boldsymbol{A}\boldsymbol{x} = 0. }

The terminal boundary condition is

J(x,tf)=12xTSfx.\boxed{ J^*(\boldsymbol{x},t_f) = \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{S}_f\boldsymbol{x}. }

Classification of the PDE

The HJB equation is a first-order nonlinear partial differential equation:

The terminal condition is specified at tft_f, so the problem is solved backward in time.

Why an Additional Structural Assumption Is Needed

The PDE contains derivatives with respect to both time and state. For a general nonlinear problem, one must solve the PDE over the full state-time domain.

The LQR problem is special because the terminal cost is quadratic and the system and running cost preserve quadratic structure. This motivates a quadratic value function.

Quadratic Value-Function Ansatz

Assume

J(x,t)=12xTS(t)x,\boxed{ J^*(\boldsymbol{x},t) = \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{S}(t)\boldsymbol{x}, }

where

S(t)=ST(t).\boldsymbol{S}(t)=\boldsymbol{S}^\mathsf{T}(t).

This form is consistent with the terminal boundary condition.

At t=tft=t_f,

12xTS(tf)x=12xTSfx.\frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{S}(t_f)\boldsymbol{x} = \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{S}_f\boldsymbol{x}.

Hence,

xT[S(tf)Sf]x=0for all x.\boldsymbol{x}^\mathsf{T} \left[ \boldsymbol{S}(t_f)-\boldsymbol{S}_f \right] \boldsymbol{x} = 0 \quad \text{for all }\boldsymbol{x}.

Therefore,

S(tf)=Sf.\boxed{ \boldsymbol{S}(t_f)=\boldsymbol{S}_f. }

State Gradient of the Value Function

Since S\boldsymbol{S} is symmetric,

Jx=S(t)x.\boxed{ J_{\boldsymbol{x}}^* = \boldsymbol{S}(t)\boldsymbol{x}. }

To see this,

x(12xTSx)=12(S+ST)x=Sx.\frac{\partial}{\partial\boldsymbol{x}} \left( \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{S}\boldsymbol{x} \right) = \frac{1}{2} (\boldsymbol{S}+\boldsymbol{S}^\mathsf{T})\boldsymbol{x} = \boldsymbol{S}\boldsymbol{x}.

Time Derivative of the Value Function

The partial derivative with respect to time holds x\boldsymbol{x} fixed:

Jt=12xTS˙(t)x.\boxed{ J_t^* = \frac{1}{2} \boldsymbol{x}^\mathsf{T}\dot{\boldsymbol{S}}(t)\boldsymbol{x}. }

Only the explicit time dependence of S(t)\boldsymbol{S}(t) is differentiated.

Substitution into the HJB Equation

Substituting

Jx=Sx,Jt=12xTS˙x\begin{aligned} J_{\boldsymbol{x}}^*&=\boldsymbol{S}\boldsymbol{x},\\ J_t^*&=\frac{1}{2}\boldsymbol{x}^\mathsf{T}\dot{\boldsymbol{S}}\boldsymbol{x} \end{aligned}

into the HJB equation gives

0=12xTS˙x+12xTQx12xTSBR1BTSx+xTSAx.\begin{aligned} 0 ={}& \frac{1}{2}\boldsymbol{x}^\mathsf{T}\dot{\boldsymbol{S}}\boldsymbol{x} + \frac{1}{2}\boldsymbol{x}^\mathsf{T}\boldsymbol{Q}\boldsymbol{x} - \frac{1}{2} \boldsymbol{x}^\mathsf{T} \boldsymbol{S}\boldsymbol{B}\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T}\boldsymbol{S} \boldsymbol{x} \nonumber\\ &+ \boldsymbol{x}^\mathsf{T}\boldsymbol{S}\boldsymbol{A}\boldsymbol{x}. \end{aligned}

The final term is scalar. Therefore,

xTSAx=12xT(SA+ATS)x.\boldsymbol{x}^\mathsf{T}\boldsymbol{S}\boldsymbol{A}\boldsymbol{x} = \frac{1}{2} \boldsymbol{x}^\mathsf{T} \left( \boldsymbol{S}\boldsymbol{A}+\boldsymbol{A}^\mathsf{T}\boldsymbol{S} \right) \boldsymbol{x}.

Symmetrization of the Cross Term

For any square matrix M\boldsymbol{M},

xTMx=xT[12(M+MT)]x.\boldsymbol{x}^\mathsf{T}\boldsymbol{M}\boldsymbol{x} = \boldsymbol{x}^\mathsf{T} \left[ \frac{1}{2} (\boldsymbol{M}+\boldsymbol{M}^\mathsf{T}) \right] \boldsymbol{x}.

The skew-symmetric part contributes nothing because

xT[12(MMT)]x=0.\boldsymbol{x}^\mathsf{T} \left[ \frac{1}{2} (\boldsymbol{M}-\boldsymbol{M}^\mathsf{T}) \right] \boldsymbol{x} = 0.

Applying this to M=SA\boldsymbol{M}=\boldsymbol{S}\boldsymbol{A} gives

xTSAx=12xT(SA+ATS)x.\boldsymbol{x}^\mathsf{T}\boldsymbol{S}\boldsymbol{A}\boldsymbol{x} = \frac{1}{2} \boldsymbol{x}^\mathsf{T} (\boldsymbol{S}\boldsymbol{A}+\boldsymbol{A}^\mathsf{T}\boldsymbol{S}) \boldsymbol{x}.

Quadratic-Form Identity

The HJB equation becomes

12xT[S˙+QSBR1BTS+SA+ATS]x=0.\frac{1}{2} \boldsymbol{x}^\mathsf{T} \left[ \dot{\boldsymbol{S}} + \boldsymbol{Q} - \boldsymbol{S}\boldsymbol{B}\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T}\boldsymbol{S} + \boldsymbol{S}\boldsymbol{A} + \boldsymbol{A}^\mathsf{T}\boldsymbol{S} \right] \boldsymbol{x} = 0.

Because this must hold for every x\boldsymbol{x},

S˙+QSBR1BTS+SA+ATS=0.\boxed{ \dot{\boldsymbol{S}} + \boldsymbol{Q} - \boldsymbol{S}\boldsymbol{B}\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T}\boldsymbol{S} + \boldsymbol{S}\boldsymbol{A} + \boldsymbol{A}^\mathsf{T}\boldsymbol{S} = \boldsymbol{0}. }

Part II develops the Riccati equation, feedback law, implementation, interpretation, and verification.

Summary

  1. The finite-horizon LQR problem has linear dynamics and quadratic cost.

  2. The HJB Hamiltonian is minimized with respect to the control.

  3. The minimizing control is

u=R1BTJx.\boldsymbol{u}^*=-\boldsymbol{R}^{-1}\boldsymbol{B}^\mathsf{T}J_{\boldsymbol{x}}^*.
  1. The HJB PDE is nonlinear in the value-function gradient.

  2. A quadratic value-function ansatz is consistent with the problem structure.

  3. The terminal condition gives

S(tf)=Sf.\boldsymbol{S}(t_f)=\boldsymbol{S}_f.
  1. Substitution reduces the HJB PDE to a matrix differential equation.

Connection. The quadratic ansatz now yields the Riccati equation, the optimal feedback law, and a practical backward-in-time numerical procedure.