DEV Community

ORCHESTRATE
ORCHESTRATE

Posted on

Active Inference — The Learn Arc, Part 41: Session §8.2 — Eq 4.19, the quadratic free energy

Session 8.2 — Eq 4.19

Series: The Learn Arc — 50 posts through the Active Inference workbench.
Previous: Part 40 — Session §8.1: Generalized coordinates

Hero line. Eq 4.19 is Eq 4.13's continuous-time twin: a quadratic approximation to the variational free energy in generalized coordinates. Once you write it down, the rest of Chapter 8 is pattern-matching against neurons.


From softmax to quadratic

In discrete time, inference minimises a KL divergence, and when the posterior is categorical that KL is exactly a softmax update (Eq 4.13). In continuous time with gaussian beliefs, the KL simplifies into a quadratic form — and that is Eq 4.19.

The quadratic is not a shortcut. It is the exact consequence of choosing gaussian variational densities in generalized coordinates.

Five beats

  1. F is a sum of weighted squared errors. Prediction error at each order of generalized coordinate, weighted by its precision. Sensory error + dynamical error + prior error — squared and weighted. That is it.

  2. Gradient is linear in prediction error. Because F is quadratic, ∂F/∂μ is an affine function of (sensory_err, dynamical_err, prior_err). The agent updates its belief by a weighted sum of errors — no softmax, no sampling.

  3. Precisions are the gains. Each error term has a precision (inverse variance) multiplier. High sensory precision → trust observations. High dynamical precision → trust internal model. The balance decides what "believing" means for this agent.

  4. This is predictive coding. The equation matches the canonical predictive-coding circuit line for line: prediction neurons send top-down expectations; error neurons compute the weighted residual; errors drive belief updates. The workbench maps the same algebra onto Elixir processes.

  5. Action lives in the same equation. In Chapter 8, actions are selected to minimise F too — specifically, to reduce sensory prediction error. Perception moves belief; action moves the world. Same F, two different handles.

Why it matters

Eq 4.19 is the equation that makes people say "this is how the brain could actually do it." The discrete softmax was algorithmically beautiful but biologically coarse. The quadratic free energy maps directly to a plausible cortical microcircuit — which is why the rest of the chapter talks about sensors, reflexes, and the motor loop without changing the math.

Quiz

  • Why does a quadratic F imply an affine gradient?
  • What happens to the belief update if sensory precision is set to zero?
  • Which term of Eq 4.19 disappears if you drop generalized coordinates above order one?

Run it yourself

mix phx.server
# open http://localhost:4000/learn/session/8/s2_eq_4_19
Enter fullscreen mode Exit fullscreen mode

Cookbook recipe: continuous/quadratic-f — a minimal continuous-time agent implementing Eq 4.19 on a 1-D tracking task. Toggle the sensory/dynamical precision sliders and watch the belief trajectory stiffen or relax in real time.

Next

Part 42: Session §8.3 — Action on sensors. The quadratic F predicts what the sensors should report. When reality differs, the agent has two knobs: update the belief (perception) or change the world (action). Session 8.3 is where motor control enters the story.


Powered by The ORCHESTRATE Active Inference Learning Workbench — Phoenix/LiveView on pure Jido.

Top comments (0)