Chapter three The EKF: pretend it is a straight line
Reality curves. Rotations compose multiplicatively, a camera projects by dividing by depth, range to a beacon is a square root of a sum of squares. None of these is linear, so the Kalman filter's guarantee evaporates. The extended Kalman filter's answer is the most obvious one an engineer could give: if the function is curved, replace it with its tangent and carry on as though nothing happened.
3.1 · The first-order Taylor expansion
Expand \(f\) about the current estimate \(\hat{x}_{k-1}\) and throw away everything past the linear term:
Likewise \(H_k = \partial h / \partial x\) evaluated at the predicted state \(\hat{x}_k^-\). Now substitute those Jacobians into the Kalman equations wherever \(F\) and \(H\) appeared. One subtlety matters enormously and is the source of most EKF bugs:
The mean travels through the real function; only the covariance is transported by the linear approximation. The update step follows the same pattern:
3.2 · What goes wrong
You linearise about a guess. If \(\hat{x}\) is off, the Jacobian is evaluated at the wrong point, the covariance update is wrong, the gain is wrong, and the next estimate is worse. The error compounds. This is divergence, and it is the classic EKF failure.
The covariance becomes a lie. Truncating the Taylor series discards real uncertainty, so \(P\) reports more confidence than is warranted. An overconfident filter down-weights good measurements, which makes it more wrong, which makes it more overconfident.
You must supply Jacobians. By hand, for a sixteen-dimensional state, with quaternions in it. They are tedious, error-prone, and silently wrong when you get a sign backwards.
And yet the EKF remains the workhorse of embedded state estimation, because it is cheap, deterministic, single-pass, and — when the sampling rate is high enough that the state barely moves between steps — the linearisation error is genuinely small.