Exercises — Extended Kalman Filter (EKF) — linearization, Jacobians
Notation refresher (every symbol used below, defined once)
Before any problem, here is every letter you will meet, in plain words:
Keep this open in a side pane; the solutions call each symbol by name.
Level 1 — Recognition
L1.1 — Read the Jacobian's shape
A state has numbers; a sensor returns numbers via . What are the dimensions of ? And which entry answers "how does the 2nd sensor output change when the 1st state changes"?
Recall Solution
WHAT is: a table with one row per output and one column per input. Rows = outputs (), columns = inputs (). The requested entry: "2nd output, 1st input" = row 2, column 1 = . WHY: the Jacobian's job is exactly to store every "output-per-input" slope. Reading its shape = reading (number of sensor channels) × (number of state variables).
L1.2 — Where does the mean go?
In the EKF predict step, does the best estimate get pushed through the nonlinear or through the matrix ?
Recall Solution
Through the true nonlinear : . WHY: the single best guess of tomorrow's state is just the real motion law applied to today's best guess. The Jacobian is only used to move the spread (covariance): . Confusing these two is the classic error — mean uses the curve, uncertainty uses its tangent.
Level 2 — Application
L2.1 — Range Jacobian at a new point
Radar at the origin, target state , range . Compute and evaluate at .

Recall Solution
Step 1 — differentiate the square root. Why chain rule? is a curve; we need its slope in each direction. Step 2 — plug in : . WHAT IT LOOKS LIKE (see figure s01): the target sits straight up the -axis. Sliding it sideways (in , plum arrow) barely changes the distance to origin — the range curve is flat in that direction, so the slope is . Sliding it outward along (orange arrow) changes range one-for-one, so the slope is . These are exactly and of the line-of-sight angle ( here).
L2.2 — Constant-velocity
State , dynamics , with . Write numerically.
Recall Solution
Step 1 — partials. , ; , . WHY it's constant: here is already a straight-line (linear) map, so its slope doesn't depend on where you are — the tangent equals the function itself. The EKF collapses to the plain Kalman Filter (linear).
Level 3 — Analysis
L3.1 — Full range/bearing Jacobian, and its determinant
For , assemble symbolically, then compute at .
Recall Solution
Step 1 — range row (from L2.1): . Step 2 — bearing row. Why ? Bearing is an angle; its rate of change with the coordinates is what we need. Step 3 — stack: Step 4 — at , : Interpretation: the general determinant is It equals — the mapping from to stretches area by , so the linearization is well-conditioned everywhere except at the origin, where it blows up.
L3.2 — Why the bearing Jacobian dies at the origin
Using above, describe what happens as , and why physically.
Recall Solution
As : the range row entries stay bounded (they are of the angle), but the bearing row entries blow up like . And . WHY physically: right on top of the sensor, an infinitesimal sideways move swings the bearing by a huge angle — direction is undefined at a point. The tangent-line approximation (Taylor Series & Linearization) requires a smooth function locally; here is singular, so the EKF is invalid at the origin. This is a degenerate case you must guard against.
Level 4 — Synthesis
L4.1 — Pendulum: linearize and read the stiffness
Continuous pendulum , state , . Take . Compute at and at , and interpret.

Recall Solution
Step 1 — general Jacobian. Why ? . Step 2 — at : , so The bottom-left is the restoring stiffness. Full strength ⇒ this is the ordinary small-angle oscillator. Step 3 — at : , so The stiffness has vanished. Horizontal pendulum: gravity gives no restoring twist at that instant. WHAT IT LOOKS LIKE (see figure s02): the restoring term is a curve; its slope (the stiffness entry) is steepest at (orange tangent) and flat at (plum tangent). The Jacobian genuinely changes with the state — that is the whole reason we re-linearize every step.
L4.2 — One full predict step for the pendulum
Using forward Euler over (so the discrete map is ), and starting from , , , propagate the mean and the covariance.
Recall Solution
Mean (nonlinear ): , so the entry . Covariance — first, WHY the discrete Jacobian is . The covariance must be transported by the slope of the discrete one-step map . Take its Jacobian term-by-term: the derivative of with respect to itself is the identity ; the derivative of is times 's own Jacobian . Adding them: That is not a memorized formula — it is just "differentiate the Euler step". (This is the first-order Taylor Series & Linearization of the flow over one small .) Now build using from L4.1 at : , so . With , : Compute each entry carefully (row of dotted with row of ):
WHY the split: the mean rode the true curve ; the uncertainty rode the tangent via . Covariance is a second-moment object and has no meaningful "".
Level 5 — Mastery
L5.1 — Full range/bearing measurement update with angle wrap
2D target, predicted state (so ), , (range var , bearing var ). The radar's raw reported bearing is — see Step 2 for exactly what the sensor sent. The reported range is . Compute the correctly-wrapped angle innovation, then the innovation , , , and the posterior state.
Recall Solution
Step 1 — predicted measurement. , and rad. So the predicted bearing is . Step 2 — what the sensor actually sent, numerically. The true bearing error is a small rad. But an angle sensor reports values modulo , and this one happened to wrap its reading up near : it reported If you naively subtract, the raw residual is That looks like a huge rad error — but a rad turn is almost a full circle, i.e. essentially the same direction. The real error is tiny. Step 3 — wrap the bearing innovation into . Why? Two angles that differ by a full turn point the same way; the meaningful residual must live in . Subtract : rad. See atan2 & Angle Wrapping. Step 4 — Jacobian at (from L3.1): . Step 5 — innovation covariance . With , : WHY the cross terms vanish (do not skip this): the off-diagonal is the dot product of 's two rows — the range gradient and the bearing gradient . Their dot product is : the two rows are orthogonal. This is not luck — range increases radially while bearing increases tangentially, and radial and tangential directions are always perpendicular. So with the mapped innovation covariance is exactly diagonal at this operating point. In general (any , or different ) it will not be diagonal. Step 6 — invert and form the gain (since ). Here is diagonal, so just reciprocates the diagonal: Step 7 — posterior state : Step 8 — posterior covariance (completes the update): The uncertainty shrank from to on each axis — the measurement genuinely sharpened our estimate. Interpretation: the range surprise () pushes the estimate outward; the (small, correctly-wrapped) bearing surprise nudges it slightly. Had we not wrapped, the bearing innovation would have catastrophically thrown the estimate — this is why wrapping is mandatory, not cosmetic.
Conditioning guard (general case). came out clean and diagonal only because and the rows of happened to be orthogonal here. In a real filter you must always check before inverting: if is near zero (e.g. small range makes the bearing row huge, or two channels become nearly redundant), amplifies noise and explodes. Fix: solve by a stable linear solve (Cholesky) instead of forming explicitly, add a small jitter to to regularize, and monitor / condition number each step. See Covariance Propagation.
L5.2 — When would you abandon the EKF entirely?
Give two concrete conditions from the exercises above where the EKF's core assumption breaks, and name the fix.
Recall Solution
Condition A — singular linearization (L3.2): near the bearing Jacobian blows up () and Taylor's neglected terms dominate. Fix: switch to the Unscented Kalman Filter (UKF) (uses sample points, no Jacobian) or skip the bearing channel. Condition B — large linearization error / bad initial guess: the tangent is only valid near (parent-note mistake #5). A far-off seed ⇒ wrong ⇒ divergence. Fix: seed a good , inflate , or use the UKF. Contrast with the plain Kalman Filter (linear), which never has this problem because its map is exactly linear. WHY these are the same root cause: both are failures of "curve ≈ line locally". When the curvature over your uncertainty region is not small, first-order Taylor Series & Linearization simply is not accurate enough.
Recall Feynman self-test (say it in one breath)
Explain to a 12-year-old why the EKF pushes the guess through the real curved rule but pushes the uncertainty through a flat straight-line copy of that rule ::: Because your single best guess should follow the real physics, but "how unsure you are" is a little cloud around the guess — and to see how a small cloud gets stretched, you only need the local steepness (slope) of the rule, which is the flat tangent = the Jacobian.