Fundamentals / Mechanical engineering / Control engineering

Optimal state feedback and the Riccati equation

Choose how heavily to penalise tracking error and actuator effort, then derive the feedback gain that minimises that stated cost.

From first principles

Derive a feedback gain by minimising future cost

A control objective must say what counts as expensive. Consider a known continuous linear system \(\dot x=Ax+Bu\) with state penalty \(x^\mathsf TQx\) and effort penalty \(u^\mathsf TRu\), where \(Q\) is positive semidefinite and \(R\) positive definite. Assume the usual stabilisability and detectability conditions for the infinite-horizon problem. If \(V(x)\) is the least remaining accumulated cost, minimising over one short interval and then using the optimal continuation gives

\[0=\min_u\{x^\mathsf TQx+u^\mathsf TRu+\nabla V^\mathsf T(Ax+Bu)\}.\]

Take the quadratic value form \(V=x^\mathsf TPx\) with symmetric \(P\). Differentiate the expression inside braces with respect to \(u\). The positive effort penalty makes its stationary value a minimum.

\[2Ru+2B^\mathsf TPx=0,\]
\[u_*=-R^{-1}B^\mathsf TPx .\]

Substitute this control back into the optimality condition and require the quadratic state coefficient to vanish for every state.

\[A^\mathsf TP+PA-PBR^{-1}B^\mathsf TP+Q=0.\]

The stabilising solution gives the feedback gain and the predicted least cost from the initial state. Hard limits on actuator effort require a further model constraint.

Derivation and applications

Relate an optimal feedback value function to energy spent

The Riccati solution predicts more than a feedback gain. Consider a scalar integrator \(\dot x=bu\) with \(b>0\) and a cost accumulated over an unlimited horizon. Use positive weights \(q,r\) and charge both state deviation and control amplitude squared. Assume the actuator has no amplitude or rate limit and the chosen stabilising control returns the state to zero. A quadratic candidate value \(V=Px^2\) changes at rate \(2Pbxu\). Add this derivative to the running cost and complete the square in the control.

\[qx^2+ru^2+\dot V=r\left(u+\frac{bP}{r}x\right)^2+\left(q-\frac{b^2P^2}{r}\right)x^2 .\]

Choose \(P\) so that the residual state term vanishes. The positive solution makes the candidate value nonnegative and gives a stabilising feedback. Integrating in time then writes the entire cost as its initial value plus a nonnegative penalty for departures from that control.

\[P=\frac{\sqrt{qr}}{b},\]
\[J=Px_0^2+\int_0^\infty r\left(u+\frac{bP}{r}x\right)^2dt .\]

Equality holds when \(u=-Kx\) with \(K=\sqrt{q/r}\). Substitution into the state balance gives an exponential return with time constant \(1/(bK)\). The optimum assigns equal instantaneous penalties to state and effort in this specific integrator model.

\[x=x_0e^{-bKt},\]
\[J_x=J_u=\frac{q x_0^2}{2bK},\]
\[J_{\min}=Px_0^2 .\]

Worked example

Price a change in the initial deviation

A normalised stage has \(b=2.00\), \(q=9.00\) and \(r=4.00\). Its optimal \(K=1.50\) gives a decay rate of 3.00 s⁻¹. For \(x_0=0.400\), the minimum cost is \((\sqrt{36}/2)(0.400)^2=0.480\) weighted units. Half comes from control effort. Doubling the starting deviation quadruples total cost to 1.92 and doubles the magnitude of the initial command.

Change the inputs and inspect this calculation below

Second application

Test a proposed control weight against an actuator limit

A second integrator has \(b=1.00\), \(q=4.00\), initial deviation 0.300 and an available command magnitude of 0.200. Since peak command is \(K|x_0|\), the unconstrained solution fits this experiment only when \(K\leq2/3\), requiring \(r\geq9.00\). At the boundary the time constant is 1.50 s and total optimal cost is

\[\sqrt{4\times9}(0.300)^2=0.540.\]

A larger starting deviation would need its own constraint check.

Interactive calculation · Change the inputs of this example

Use the adjustable quantities to test the two worked calculations above. The plot recomputes this derivation’s balance or constitutive relation; its numerical readout reports the quantities needed for the forward calculation and the inverse or design question. Keep the fixed assumptions stated in the readout when comparing with the example values.

Make the design objective explicit

Pole placement prescribes decay rates but says nothing about how much actuator energy a manoeuvre consumes. For a continuous linear system \(\dot x=Ax+Bu\) consider the regulator objective \(J=\int_0^\infty(x^\mathsf{T}Qx+u^\mathsf{T}Ru)\,dt\). Assume \(Q\) positive semidefinite and \(R\) positive definite. A large displacement penalty or a small control penalty generally encourages stronger corrective action. The ratio matters: multiplying both matrices by the same positive scalar leaves the best control unchanged. Scale states and inputs before comparing entries; a displacement in millimetres and a velocity in metres per second cannot share an arbitrary numerical weight without a unit convention.

Derive the continuous algebraic Riccati equation

For an infinite-horizon stationary problem propose a quadratic remaining cost \(V(x)=x^\mathsf{T}Px\). During a short interval \(dt\), optimality requires the minimum of instantaneous cost plus the change in remaining cost to vanish. In the limit this gives

\[0=\min_u[x^\mathsf{T}Qx+u^\mathsf{T}Ru+2x^\mathsf{T}P(Ax+Bu)].\]

Completing the square in \(u\) yields

\[u^*=-R^{-1}B^\mathsf{T}Px,\]
\[A^\mathsf{T}P+PA-PBR^{-1}B^\mathsf{T}P+Q=0.\]

The desired solution is the stabilising symmetric solution. Under standard stabilisability and detectability conditions it exists and yields finite nonnegative cost. Other algebraic roots need not make sense as stored future cost. Once a candidate is found, check the eigenvalues of \(A-BR^{-1}B^\mathsf{T}P\) and the residual of the matrix equation.

Solve the scalar unstable case

Let \(\dot x=x+u\) with \(Q=R=1\). The scalar equation is \(2P-P^2+1=0\), giving \(P=1\pm\sqrt2\). Only \(1+\sqrt2\) is positive and makes the closed-loop pole \(1-P=-\sqrt2\). From initial state \(x_0=2\), the theoretical minimum cost is \(4(1+\sqrt2)\simeq9.657\). Verify independently: insert \(x=2e^{-\sqrt2t}, u=-Px\) into the cost integral to obtain \(4(1+P^2)/(2\sqrt2)\), the same value. By contrast a stabilising gain of 2 gives state pole −1 and cost 10. Stabilising the state is necessary but still leaves a meaningful optimisation problem.

Distinguish control penalties from hard actuator limits

The optimal initial input for the scalar example has magnitude \(2P=4.83\). If the actuator is limited to 3, clipping the command invalidates the quadratic unconstrained solution during the clipped interval. Increasing \(R\) makes large inputs more expensive but generally supplies no absolute guarantee for arbitrary initial conditions. A concrete certificate is possible inside a stated region. In one dimension \(|u|\le u_{\max}\) is guaranteed by \(|x|\le u_{\max}/P\) under this gain, and the resulting stable exponential stays in that interval. Later we will impose hard constraints directly in a finite-horizon design.

The MIT notes on linear quadratic regulators extend this derivation to time-varying and finite-horizon problems.

Solve the Riccati equation for a position-and-velocity plant

A carriage moving on nearly frictionless guides is locally a double integrator. Take its position error \(x_1\) and velocity \(x_2\) as states and acceleration command \(u\) as input. After selecting consistent physical scales, use \(A=\left(\begin{smallmatrix}0&1\\0&0\end{smallmatrix}\right)\), \(B=(0,1)^T\) and diagonal cost \(Q=\operatorname{diag}(q_x,q_v)\), \(R=r\). Assume \(q_x>0,\ q_v\ge0,\ r>0\). Both states are reachable because acceleration changes velocity immediately and position through integration. Choosing a positive position penalty also makes a stationary position error visible to the cost.

Set \(P=\left(\begin{smallmatrix}p_{11}&p_{12}\\p_{12}&p_{22}\end{smallmatrix}\right)\) in \(A^TP+PA-PBr^{-1}B^TP+Q=0\). Matching the upper-left, lower-right and off-diagonal entries gives three scalar equations:

\[p_{12}^2/r=q_x,\]
\[p_{22}^2/r=2p_{12}+q_v,\]
\[p_{11}=p_{12}p_{22}/r .\]

Choose the positive roots giving stabilising feedback. The gains in \(u=-k_x x_1-k_v x_2\) become

\[k_x=\sqrt{q_x/r},\]
\[k_v=\sqrt{2\sqrt{q_x/r}+q_v/r}.\]

Substitution into the state equations gives

\[s^2+k_vs+k_x=0.\]

The effort penalty and position penalty enter the squared natural frequency through a square root; the natural frequency itself varies as a fourth root. This explains why a moderate change of settling speed may require a surprisingly large change in a numerical cost weight.

Set a settling speed and calculate its actuator cost

In chosen metre, second and acceleration units let \(q_x=16,\ q_v=0,\ r=1\), with weights understood to include the needed unit conversions. Then

\[k_x=4\,\mathrm{s^{-2}},\ k_v=\sqrt8=2.828\,\mathrm{s^{-1}}.\]

The poles are \(-1.414\pm1.414i\,\mathrm{s^{-1}}\), with natural frequency 2 rad/s and damping ratio \(1/\sqrt2\). From an initial positive position error of 0.20 m and zero speed, commanded acceleration is −0.80 m/s². The optimum quadratic cost is \(V=x^TPx\). Here \(p_{12}=4\), \(p_{22}=2.828\), \(p_{11}=11.314\), so the initial cost value is \(11.314(0.2)^2=0.453\) in the chosen cost units.

To double natural frequency while keeping \(q_v=0,\ r=1\), increase \(q_x\) by sixteen to 256. The new position gain is 16 s⁻², velocity gain is \(\sqrt{32}=5.657\,\mathrm{s^{-1}}\), and the same initial condition demands −3.2 m/s². An acceleration-limited drive rated for ±1.5 m/s² cannot execute this ideal motion from that initial error. For the larger gain, the zero-velocity initial error must be no more than \(1.5/16=0.0938\,\mathrm m\) for the first command to lie within its limit. That calculation addresses the initial state only; subsequent velocity feedback must also be checked. Comparing physical demand rather than weight values makes the practical tradeoff visible.

The chosen gains can be tested without explicitly solving the Riccati equation again. Along an optimal unconstrained trajectory \(V=x^TPx\) decreases according to \(\dot V=-(x^TQx+u^TRu)\). At the original initial state the instantaneous cost is \(16(0.20)^2+(-0.80)^2=1.28\) cost units per second. Directly differentiating \(V\) there gives \(2x^TP\dot x=2(0.20)(4)(-0.80)=-1.28\), since initial speed is zero and acceleration equals the command. The sign and magnitude agree. This check simultaneously tests the gain sign, state ordering and cost convention. Introducing an input clip breaks the square-completion identity for the proposed unconstrained controller, so the same matrix cannot simply be read as the realised accumulated cost of the clipped manoeuvre.