3.5.35 · D2Guidance, Navigation & Control (GNC)

Visual walkthrough — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

3,265 words15 min readBack to topic

Step 0 — The two words: state and control (before any math)

PICTURE. A cart sits at position moving right at speed . Your hand pushes it with force . The target is the origin — the little flag at . That is the entire universe of this problem.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

The arrow labelled is red because it is the only thing under your command. Everything we do from now on answers one question: how hard, and which way, should that red arrow push, given where the cart is right now?


Step 1 — The machine is linear:

WHY care that it's linear? Because a straight rule is the only kind we can fully solve in closed form. The whole payoff of LQR rides on this.

PICTURE. The state lives as a point in a plane (position across, velocity up). At every point an arrow shows which way the machine drifts on its own (). Your push nudges that arrow.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

Look at the black arrows: with no push, a cart to the right and moving right () drifts further right — it runs away. The red overlay shows how one choice of bends those arrows back toward the flag.


Step 2 — The bill we pay: the quadratic cost

WHY squares and not absolute values or fourth powers? Two reasons, one practical, one magical.

  • Practical: a square is smooth and has no sharp corner at zero, so the machine never chatters.
  • Magical: a linear machine fed a squared bill produces a controller that is itself linear. That coincidence is the entire reason LQR is beautiful. We prove it below.

PICTURE. A squared penalty is a bowl. Being at the bottom (on-target, no push) costs nothing; climbing the wall costs more and more, faster and faster.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

The orange bowl is the error bill in ; the teal bowl is the effort bill in . Because and , both bowls open upward — they never dip below the ground. LQR looks for the path that keeps total bowl-height smallest, forever.


Step 3 — The "cost-to-go" is also a bowl:

WHY must be a bowl (a quadratic )? Three clues, each forced:

  1. At the target, playing perfectly costs zero, so — the bowl touches ground at the origin.
  2. Left and right of target are symmetric mirror situations, so no odd/linear term survives.
  3. A straight machine can't manufacture cubes or quartics out of a squared bill — the shape stays a clean bowl.

So , where is an unknown symmetric grid of numbers — the one thing we must find. This choice is exactly the value-function guess.

PICTURE. The bowl sits over the state plane. Its steepness in each direction is set by . Find and you know the price of every situation — and, as we'll see, the perfect push.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

Step 4 — Bellman's balance: instant cost + downhill speed = 0

That last line is the HJB equation. The slogan "instant cost cancels the fall of the future bill" is now derived, not merely asserted.

PICTURE. Stand on the inside wall of the bowl. The uphill slope arrow is . Your motion is another arrow. Their alignment (via the chain rule) tells you whether the future bill is dropping (moving downhill) and how fast.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

Step 5 — Turn the knob to the bottom: solve for

Inside the bracket, the only thing you control is . Everything with a in it: This is a bowl (because , i.e. is a genuine upward bowl) tilted by the state. A tilted bowl has exactly one lowest point. Slide to it by setting the slope in to zero:

WHY does appear, and why must be strictly positive? If effort were free () you'd shove infinitely hard — the bowl in would be flat and have no bottom. A real, strictly-positive gives the bowl a genuine bottom, so exists and one finite best push exists. This is the feedback law , now derived rather than guessed.

PICTURE. For a fixed state, the cost as a function of your push is a parabola. Its vertex is the perfect push. Steeper parabola (bigger ) → vertex closer to zero → gentler push.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

Step 6 — Put the best push back in: the Riccati equation appears

We now substitute into Bellman's balance and carefully collect terms. Start from

Term (i) — the drift becomes the symmetric pair . The number is a scalar, so it equals its own transpose: (using ). Averaging the two identical copies, So the lone lop-sided is rewritten as the symmetric sum — the "drift up the bowl" term.

Term (ii) — the two pieces merge into . Plug into the effort cost and the tilt separately: Add them: , so together they give This is exactly what steering saves — the optimizer buys a reduction, hence the minus sign.

Collect (i) + (ii) + the error term : This must hold at every state . A quadratic form that is zero for all can only come from the flat zero matrix, so the whole grid in the middle must vanish:

WHY nonlinear? The saving term has multiplied by — a square. That single squared term is what makes this a Riccati equation rather than a plain linear one.

PICTURE. The equation is a see-saw of grids: drift () and error price () push up; the steering saving () pulls it down. The balance point is the we want.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

Step 7 — The degenerate & edge cases (never leave a gap)

PICTURE. Three miniature bowls side by side: cheap fuel (deep narrow bowl, sharp gain), free error (flat wide bowl, lazy gain), and the correct-vs-wrong root (bowl up vs bowl down).

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains

The one-picture summary

Read the five panels below left-to-right — they are exactly Steps 1 → 6 compressed into one strip:

  1. Panel 1 (Step 1) — Linear machine : the straight cause-and-effect rule.
  2. Panel 2 (Step 2) — Quadratic bill : the two upward bowls we pay.
  3. Panel 3 (Step 3) — Cost-to-go bowl : forced to be a smooth quadratic; find .
  4. Panel 4 (Steps 4–5) — Bellman's knob : turning the U-curve to its vertex gives a linear law.
  5. Panel 5 (Step 6) — Riccati → : back-substitution forces , whose stabilizing root hands you .

Each black arrow between panels is a "therefore": linear + quadratic therefore bowl therefore linear law therefore Riccati therefore one gain.

Figure — Linear Quadratic Regulator (LQR) — Riccati equation, optimal gains
Recall Feynman: the whole walk in plain words

You're pushing a cart to a flag. First I taught you the two numbers that describe the cart (where, how fast) and the one thing you control (your push). The cart obeys a straight-line rule: your push feeds its speed, its speed feeds its position. Then I handed you a bill — one part for sitting far from the flag, one part for shoving hard — and I squared both so the bill is a smooth bowl that never dips below zero (that's , ). Standing anywhere, there's a price of your situation, and because everything is straight-and-squared that price is itself a smooth bowl, . Perfect play means the bill you pay each second exactly matches how fast your future bill drops as you slide down that bowl — I got that by splitting time into "the next instant" plus "everything after," which is Bellman's principle, and using the chain rule because the bowl is smooth. Freeze the state and your push-vs-cost is a simple U-curve; its bottom is the perfect push, and it turns out to be just "push in proportion to how far off you are," . Feed that best push back into the balance and the algebra coughs up one matrix equation — Riccati — whose good (bowl-up) solution gives you once and for all. Cheap fuel → hammer it; ruinously dear fuel → barely tap; free error → laze; runaway cart → still tamed. One recipe, computed once, works everywhere.


Active Recall