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.

Linear–Quadratic Optimal Control and the Riccati Differential Equation

The preceding sections derived the state equation, costate equation, stationarity condition, endpoint constraints, and transversality conditions for a general optimal-control problem. This section applies those necessary conditions to one of the most important analytically tractable problems in control theory: the finite-horizon linear–quadratic regulator (LQR).

The LQR problem is important for two reasons. First, it provides a complete example in which the optimality conditions can be reduced to a computable feedback law. Second, it exposes a central difficulty of indirect optimal control: the state and costate equations form a two-point boundary-value problem, with state information specified at the initial time and costate information specified at the final time.

The finite-horizon LQR problem

Consider the linear time-invariant system

x˙(t)=Ax(t)+Bu(t),x(0)=x0,\dot{\boldsymbol{x}}(t)=A\boldsymbol{x}(t)+B\boldsymbol{u}(t), \qquad \boldsymbol{x}(0)=\boldsymbol{x}_0,

where x(t)Rn\boldsymbol{x}(t)\in\mathbb{R}^n, u(t)Rm\boldsymbol{u}(t)\in\mathbb{R}^m, ARn×nA\in\mathbb{R}^{n\times n}, and BRn×mB\in\mathbb{R}^{n\times m}.

The finite-horizon LQR problem is

minu()J=12xT(tf)Sfx(tf)+120tf[xT(t)Qx(t)+uT(t)Ru(t)]dt,\begin{aligned} \min_{\boldsymbol{u}(\cdot)}\quad J &= \frac{1}{2}\boldsymbol{x}^{\mathsf{T}}(t_f)S_f\boldsymbol{x}(t_f) + \frac{1}{2}\int_{0}^{t_f} \left[ \boldsymbol{x}^{\mathsf{T}}(t)Q\boldsymbol{x}(t) + \boldsymbol{u}^{\mathsf{T}}(t)R\boldsymbol{u}(t) \right]\,\mathrm{d} t, \end{aligned}
subject tox˙(t)=Ax(t)+Bu(t),x(0)=x0.\begin{aligned} \text{subject to}\quad \dot{\boldsymbol{x}}(t)&=A\boldsymbol{x}(t)+B\boldsymbol{u}(t), \qquad \boldsymbol{x}(0)=\boldsymbol{x}_0. \end{aligned}

The final state is free; it is penalized rather than prescribed.

The standard weighting assumptions are

Q=QT0,R=RT0,Sf=SfT0.Q=Q^{\mathsf{T}}\succeq 0, \qquad R=R^{\mathsf{T}}\succ 0, \qquad S_f=S_f^{\mathsf{T}}\succeq 0.

The matrices may be time varying in the general finite-horizon problem. This section assumes constant AA, BB, QQ, and RR to make the derivation transparent; the resulting Riccati equation remains valid in time-varying form after replacing the constant matrices by their time-dependent counterparts.

Interpretation of the quadratic cost

The running cost contains two competing penalties:

12xTQxand12uTRu.\frac{1}{2}\boldsymbol{x}^{\mathsf{T}} Q\boldsymbol{x} \qquad\text{and}\qquad \frac{1}{2}\boldsymbol{u}^{\mathsf{T}} R\boldsymbol{u}.

The first penalizes undesirable state deviations, while the second penalizes control effort. The terminal term 12xT(tf)Sfx(tf)\tfrac12\boldsymbol{x}^{\mathsf{T}}(t_f)S_f\boldsymbol{x}(t_f) penalizes the state remaining at the end of the horizon.

Controllability and observability assumptions

A common strong set of assumptions is that (A,B)(A,B) is controllable and (A,Q1/2)(A,Q^{1/2}) is observable. For many stabilization results, these may be weakened to stabilizability and detectability, respectively.

Step 1: Form the Hamiltonian

The Mayer term and running cost are

Φ=12xT(tf)Sfx(tf),L=12xTQx+12uTRu.\Phi=\frac12\boldsymbol{x}^{\mathsf{T}}(t_f)S_f\boldsymbol{x}(t_f), \qquad L=\frac12\boldsymbol{x}^{\mathsf{T}} Q\boldsymbol{x}+\frac12\boldsymbol{u}^{\mathsf{T}} R\boldsymbol{u}.

The dynamics are

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

Therefore, the Hamiltonian is

H(x,u,λ)=12xTQx+12uTRu+λT(Ax+Bu).H(\boldsymbol{x},\boldsymbol{u},\boldsymbol{\lambda}) = \frac12\boldsymbol{x}^{\mathsf{T}} Q\boldsymbol{x} + \frac12\boldsymbol{u}^{\mathsf{T}} R\boldsymbol{u} + \boldsymbol{\lambda}^{\mathsf{T}}(A\boldsymbol{x}+B\boldsymbol{u}).

Step 2: Derive the costate equation

The costate equation is

λ˙=HxT.\dot{\boldsymbol{\lambda}}=-H_{\boldsymbol{x}}^{\mathsf{T}}.

Because Q=QTQ=Q^{\mathsf{T}},

x(12xTQx)=xTQ.\frac{\partial}{\partial\boldsymbol{x}} \left(\frac12\boldsymbol{x}^{\mathsf{T}} Q\boldsymbol{x}\right) = \boldsymbol{x}^{\mathsf{T}} Q.

Also,

x(λTAx)=λTA.\frac{\partial}{\partial\boldsymbol{x}} \left(\boldsymbol{\lambda}^{\mathsf{T}} A\boldsymbol{x}\right) = \boldsymbol{\lambda}^{\mathsf{T}} A.

Thus,

Hx=xTQ+λTA,H_{\boldsymbol{x}}=\boldsymbol{x}^{\mathsf{T}} Q+\boldsymbol{\lambda}^{\mathsf{T}} A,

and therefore

λ˙=QxATλ.\boxed{ \dot{\boldsymbol{\lambda}}=-Q\boldsymbol{x}-A^{\mathsf{T}}\boldsymbol{\lambda}. }

Step 3: Determine the stationary control

The control is unconstrained, so the minimizing control lies in the interior of the admissible control set. The stationarity condition is therefore

Hu=0T.H_{\boldsymbol{u}}=\boldsymbol{0}^{\mathsf{T}}.

Differentiating (12) with respect to u\boldsymbol{u} gives

Hu=uTR+λTB.H_{\boldsymbol{u}}=\boldsymbol{u}^{\mathsf{T}} R+\boldsymbol{\lambda}^{\mathsf{T}} B.

Taking the transpose and setting the result equal to zero yields

Ru+BTλ=0.R\boldsymbol{u}+B^{\mathsf{T}}\boldsymbol{\lambda}=\boldsymbol{0}.

Since R0R\succ0, it is invertible, and the stationary control is

u=R1BTλ.\boxed{ \boldsymbol{u}^*=-R^{-1}B^{\mathsf{T}}\boldsymbol{\lambda}. }

The coupled state–costate system

Substituting (21) into the state equation gives

x˙=AxBR1BTλ.\dot{\boldsymbol{x}} =A\boldsymbol{x}-BR^{-1}B^{\mathsf{T}}\boldsymbol{\lambda}.

Together with (17),

λ˙=QxATλ.\dot{\boldsymbol{\lambda}}=-Q\boldsymbol{x}-A^{\mathsf{T}}\boldsymbol{\lambda}.

These equations may be assembled as

[x˙λ˙]=[ABR1BTQAT]H[xλ].\boxed{ \begin{bmatrix} \dot{\boldsymbol{x}}\\[1mm] \dot{\boldsymbol{\lambda}} \end{bmatrix} = \underbrace{ \begin{bmatrix} A & -BR^{-1}B^{\mathsf{T}}\\ -Q & -A^{\mathsf{T}} \end{bmatrix}}_{\displaystyle \mathcal{H}} \begin{bmatrix} \boldsymbol{x}\\[1mm] \boldsymbol{\lambda} \end{bmatrix}. }

The matrix HR2n×2n\mathcal{H}\in\mathbb{R}^{2n\times2n} is called a Hamiltonian matrix.

Although this expression is formally complete, it does not yet solve the optimal-control problem because λ(0)\boldsymbol{\lambda}(0) is unknown.

Endpoint conditions

Initial endpoint

The initial condition may be represented as the endpoint constraint

ϕ=x(0)x0=0.\boldsymbol{\phi}=\boldsymbol{x}(0)-\boldsymbol{x}_0=\boldsymbol{0}.

Because the initial state is fixed,

δx(0)=0.\delta\boldsymbol{x}(0)=\boldsymbol{0}.

Consequently, the initial transversality condition does not provide a useful numerical condition on λ(0)\boldsymbol{\lambda}(0). Formally, it only relates the initial costate to the endpoint multiplier associated with (28); both quantities remain unknown.

Final endpoint

The final state is free, so the terminal transversality condition applies:

λ(tf)=Φx(tf)T.\boldsymbol{\lambda}(t_f)=\Phi_{\boldsymbol{x}(t_f)}^{\mathsf{T}}.

Since

Φ=12xT(tf)Sfx(tf)\Phi=\frac12\boldsymbol{x}^{\mathsf{T}}(t_f)S_f\boldsymbol{x}(t_f)

and Sf=SfTS_f=S_f^{\mathsf{T}},

λ(tf)=Sfx(tf).\boxed{ \boldsymbol{\lambda}(t_f)=S_f\boldsymbol{x}(t_f). }

The complete boundary data are therefore

x(0)=x0,λ(tf)=Sfx(tf).\boxed{ \boldsymbol{x}(0)=\boldsymbol{x}_0, \qquad \boldsymbol{\lambda}(t_f)=S_f\boldsymbol{x}(t_f). }

There are nn scalar conditions at the initial time and nn scalar conditions at the final time, exactly enough for the 2n2n first-order equations in (24).

The two-point boundary-value problem

Equations (24), and (33) form a linear two-point boundary-value problem (TPBVP):

x˙=AxBR1BTλ,x(0)=x0,\begin{aligned} \dot{\boldsymbol{x}}&=A\boldsymbol{x}-BR^{-1}B^{\mathsf{T}}\boldsymbol{\lambda}, &\boldsymbol{x}(0)&=\boldsymbol{x}_0, \end{aligned}
λ˙=QxATλ,λ(tf)=Sfx(tf).\begin{aligned} \dot{\boldsymbol{\lambda}}&=-Q\boldsymbol{x}-A^{\mathsf{T}}\boldsymbol{\lambda}, &\boldsymbol{\lambda}(t_f)&=S_f\boldsymbol{x}(t_f). \end{aligned}

The difficulty is structural: the full vector [xT,λT]T[\boldsymbol{x}^{\mathsf{T}},\boldsymbol{\lambda}^{\mathsf{T}}]^{\mathsf{T}} is not known at either endpoint.

Boundary information for finite-horizon LQR is split between the initial state and terminal costate relation.

Figure 1:Boundary information for finite-horizon LQR is split between the initial state and terminal costate relation.

A direct matrix-exponential representation is possible. Partition the state-transition matrix as

eHtf=[Ψ11Ψ12Ψ21Ψ22].e^{\mathcal{H}t_f} = \begin{bmatrix} \Psi_{11} & \Psi_{12}\\ \Psi_{21} & \Psi_{22} \end{bmatrix}.

Then

[x(tf)λ(tf)]=[Ψ11Ψ12Ψ21Ψ22][x0λ(0)].\begin{bmatrix} \boldsymbol{x}(t_f)\\ \boldsymbol{\lambda}(t_f) \end{bmatrix} = \begin{bmatrix} \Psi_{11} & \Psi_{12}\\ \Psi_{21} & \Psi_{22} \end{bmatrix} \begin{bmatrix} \boldsymbol{x}_0\\ \boldsymbol{\lambda}(0) \end{bmatrix}.

Using λ(tf)=Sfx(tf)\boldsymbol{\lambda}(t_f)=S_f\boldsymbol{x}(t_f) gives

(Ψ22SfΨ12)λ(0)=(SfΨ11Ψ21)x0.\left(\Psi_{22}-S_f\Psi_{12}\right)\boldsymbol{\lambda}(0) = \left(S_f\Psi_{11}-\Psi_{21}\right)\boldsymbol{x}_0.

If the matrix on the left is nonsingular, (38) determines λ(0)\boldsymbol{\lambda}(0). The Riccati transformation provides a more useful feedback-oriented representation.

The Riccati transformation

Motivated by the linear structure of the problem, introduce

λ(t)=S(t)x(t)+β(t),\boxed{ \boldsymbol{\lambda}(t)=S(t)\boldsymbol{x}(t)+\boldsymbol{\beta}(t), }

where S(t)Rn×nS(t)\in\mathbb{R}^{n\times n} and β(t)Rn\boldsymbol{\beta}(t)\in\mathbb{R}^n are to be determined.

This transformation initially loses no generality because β(t)\boldsymbol{\beta}(t) is an unrestricted vector function. Its purpose is to select S(t)S(t) so that the dynamics of β\boldsymbol{\beta} decouple from the state.

Differentiating (39) gives

λ˙=S˙x+Sx˙+β˙.\dot{\boldsymbol{\lambda}}=\dot{S}\boldsymbol{x}+S\dot{\boldsymbol{x}}+\dot{\boldsymbol{\beta}}.

Using

x˙=AxBR1BT(Sx+β),\dot{\boldsymbol{x}}=A\boldsymbol{x}-BR^{-1}B^{\mathsf{T}}(S\boldsymbol{x}+\boldsymbol{\beta}),

we obtain

λ˙=(S˙+SASBR1BTS)x+β˙SBR1BTβ.\begin{aligned} \dot{\boldsymbol{\lambda}} ={}& \left( \dot{S}+SA-SBR^{-1}B^{\mathsf{T}} S \right)\boldsymbol{x} \nonumber\\ &+ \dot{\boldsymbol{\beta}}-SBR^{-1}B^{\mathsf{T}}\boldsymbol{\beta}. \end{aligned}

On the other hand, the costate equation gives

λ˙=QxAT(Sx+β)=(QATS)xATβ.\begin{aligned} \dot{\boldsymbol{\lambda}} &=-Q\boldsymbol{x}-A^{\mathsf{T}}(S\boldsymbol{x}+\boldsymbol{\beta}) \nonumber\\ &= \left(-Q-A^{\mathsf{T}} S\right)\boldsymbol{x}-A^{\mathsf{T}}\boldsymbol{\beta}. \end{aligned}

Equating (42), and (43) yields

β˙=[S˙SAATS+SBR1BTSQ]x+(SBR1BTAT)β.\begin{aligned} \dot{\boldsymbol{\beta}} ={}& \Bigl[ -\dot{S}-SA-A^{\mathsf{T}} S +SBR^{-1}B^{\mathsf{T}} S-Q \Bigr]\boldsymbol{x} \nonumber\\ &+ \left(SBR^{-1}B^{\mathsf{T}}-A^{\mathsf{T}}\right)\boldsymbol{\beta}. \end{aligned}

Define the matrix residual

Γ(S)=S˙SAATS+SBR1BTSQ.\Gamma(S) = -\dot{S}-SA-A^{\mathsf{T}} S+SBR^{-1}B^{\mathsf{T}} S-Q.

Then

β˙=Γ(S)x+(SBR1BTAT)β.\dot{\boldsymbol{\beta}} = \Gamma(S)\boldsymbol{x}+ \left(SBR^{-1}B^{\mathsf{T}}-A^{\mathsf{T}}\right)\boldsymbol{\beta}.

The Riccati differential equation

Choose S(t)S(t) so that

Γ(S)=0.\Gamma(S)=0.

This eliminates the state forcing from the β\boldsymbol{\beta} equation and gives

S˙=ATS+SASBR1BTS+Q.\boxed{ -\dot{S} =A^{\mathsf{T}} S+SA-SBR^{-1}B^{\mathsf{T}} S+Q. }

Equivalently,

S˙=SAATS+SBR1BTSQ.\boxed{ \dot{S} =-SA-A^{\mathsf{T}} S+SBR^{-1}B^{\mathsf{T}} S-Q. }

Equation (48) is the finite-horizon Riccati differential equation (RDE).

Terminal conditions for the Riccati matrix and auxiliary vector

At t=tft=t_f, the transformation (39) gives

λ(tf)=S(tf)x(tf)+β(tf).\boldsymbol{\lambda}(t_f)=S(t_f)\boldsymbol{x}(t_f)+\boldsymbol{\beta}(t_f).

The transversality condition requires

λ(tf)=Sfx(tf).\boldsymbol{\lambda}(t_f)=S_f\boldsymbol{x}(t_f).

A natural choice consistent for every terminal state is therefore

S(tf)=Sf,β(tf)=0.\boxed{ S(t_f)=S_f, \qquad \boldsymbol{\beta}(t_f)=\boldsymbol{0}. }

Once SS satisfies the RDE, (46) reduces to

β˙=(SBR1BTAT)β.\dot{\boldsymbol{\beta}} = \left(SBR^{-1}B^{\mathsf{T}}-A^{\mathsf{T}}\right)\boldsymbol{\beta}.

This is a homogeneous linear differential equation. Because β(tf)=0\boldsymbol{\beta}(t_f)=0, uniqueness implies

β(t)0for all t[0,tf].\boxed{ \boldsymbol{\beta}(t)\equiv\boldsymbol{0} \qquad\text{for all }t\in[0,t_f]. }

Hence,

λ(t)=S(t)x(t).\boxed{ \boldsymbol{\lambda}(t)=S(t)\boldsymbol{x}(t). }

Optimal feedback law

Substituting (57) into (21) gives

u(t)=R1BTS(t)x(t).\boldsymbol{u}^*(t) =-R^{-1}B^{\mathsf{T}} S(t)\boldsymbol{x}^*(t).

Define the time-varying gain

K(t)=R1BTS(t).\boxed{ K(t)=R^{-1}B^{\mathsf{T}} S(t). }

Then

u(t)=K(t)x(t).\boxed{ \boldsymbol{u}^*(t)=-K(t)\boldsymbol{x}^*(t). }

The optimal state satisfies the closed-loop equation

x˙(t)=[ABK(t)]x(t),x(0)=x0.\boxed{ \dot{\boldsymbol{x}}^*(t) = \left[A-BK(t)\right]\boldsymbol{x}^*(t), \qquad \boldsymbol{x}^*(0)=\boldsymbol{x}_0. }
Backward–forward computational workflow for finite-horizon linear–quadratic optimal control.

Figure 2:Backward–forward computational workflow for finite-horizon linear–quadratic optimal control.

Backward–forward computational procedure

The Riccati formulation converts the original TPBVP into two sequential initial/terminal-value integrations:

  1. Specify AA, BB, QQ, RR, SfS_f, tft_f, and x0\boldsymbol{x}_0.

  2. Integrate the RDE

S˙=ATS+SASBR1BTS+Q-\dot{S}=A^{\mathsf{T}} S+SA-SBR^{-1}B^{\mathsf{T}} S+Q

backward from S(tf)=SfS(t_f)=S_f to t=0t=0.

  1. Compute K(t)=R1BTS(t)K(t)=R^{-1}B^{\mathsf{T}} S(t) over the horizon.

  2. Integrate

x˙=[ABK(t)]x,x(0)=x0,\dot{\boldsymbol{x}}^*=[A-BK(t)]\boldsymbol{x}^*, \qquad \boldsymbol{x}^*(0)=\boldsymbol{x}_0,

forward from 0 to tft_f.

  1. Recover

u(t)=K(t)x(t),λ(t)=S(t)x(t).\boldsymbol{u}^*(t)=-K(t)\boldsymbol{x}^*(t), \qquad \boldsymbol{\lambda}^*(t)=S(t)\boldsymbol{x}^*(t).
  1. Verify the state equation, costate equation, stationarity condition, and terminal condition numerically.

Value-function interpretation

For the LQR problem, the optimal cost-to-go has the quadratic form

V(x,t)=12xTS(t)x.V(\boldsymbol{x},t)=\frac12\boldsymbol{x}^{\mathsf{T}} S(t)\boldsymbol{x}.

Its state gradient is

VxT=S(t)x.V_{\boldsymbol{x}}^{\mathsf{T}}=S(t)\boldsymbol{x}.

Thus,

λ(t)=VxT(x(t),t)=S(t)x(t).\boldsymbol{\lambda}(t)=V_{\boldsymbol{x}}^{\mathsf{T}}(\boldsymbol{x}^*(t),t)=S(t)\boldsymbol{x}^*(t).

The Riccati matrix therefore encodes the curvature of the optimal value function and maps the state to its associated costate sensitivity.

Substitution of (65) into the Hamilton–Jacobi–Bellman equation produces the same RDE as (48). This equivalence connects the indirect costate derivation to dynamic programming.

Scalar worked example

Consider

x˙=ax+bu,x(0)=x0,\begin{aligned} \dot{x}&=ax+bu, &x(0)&=x_0, \end{aligned}
J=12sfx2(tf)+120tf(qx2+ru2)dt,\begin{aligned} J&=\frac12s_f x^2(t_f) +\frac12\int_0^{t_f}\left(qx^2+ru^2\right)\,\mathrm{d} t, \end{aligned}

where q0q\ge0, r>0r>0, and sf0s_f\ge0.

The Hamiltonian is

H=12qx2+12ru2+λ(ax+bu).H=\frac12qx^2+\frac12ru^2+\lambda(ax+bu).

The stationarity condition gives

ru+bλ=0u=brλ.ru+b\lambda=0 \quad\Longrightarrow\quad u^*=-\frac{b}{r}\lambda.

The costate equation is

λ˙=qxaλ,λ(tf)=sfx(tf).\dot{\lambda}=-qx-a\lambda, \qquad \lambda(t_f)=s_f x(t_f).

Let λ=sx\lambda=sx. Then

s˙=2asb2rs2+q,s(tf)=sf.-\dot{s}=2as-\frac{b^2}{r}s^2+q, \qquad s(t_f)=s_f.

The optimal feedback law is

u(t)=brs(t)x(t).\boxed{ u^*(t)=-\frac{b}{r}s(t)x^*(t). }

The closed-loop state equation is

x˙(t)=(ab2rs(t))x(t).\dot{x}^*(t)= \left(a-\frac{b^2}{r}s(t)\right)x^*(t).

Why this example matters

The LQR derivation illustrates several general lessons:

  1. The necessary conditions naturally produce a TPBVP.

  2. Fixed endpoint states do not automatically provide costate values at the same endpoint.

  3. Free terminal states produce terminal costate conditions through transversality.

  4. An appropriate transformation can decouple a state–costate system.

  5. The Riccati equation converts an open-loop indirect solution into a feedback representation.

  6. Analytical structure reduces computational burden and clarifies what a numerical solver is doing.

The historical importance of such transformations is easy to underestimate. Before modern numerical software, solving a nonlinear or even large linear TPBVP could be prohibitively expensive. Analytical reductions such as the Riccati formulation made many control problems computationally feasible and remain valuable for interpretation, verification, and real-time implementation.

Common errors

Connection. The finite-horizon Riccati equation points naturally toward steady feedback laws, which leads to infinite-horizon LQR and the algebraic Riccati equation.