Extended Kalman Filter
March 23, 2026 · View on GitHub
Overview & Motivation
Many real-world systems are nonlinear: a pendulum's restoring force is , not ; a radar measured range depends on , not a linear combination of states. The standard Kalman filter assumes linear dynamics and cannot handle this directly.
The Extended Kalman Filter (EKF) extends the Kalman framework to nonlinear systems by linearizing the state transition and measurement functions around the current estimate at each step. It uses the same predict–update structure, but replaces the constant system matrices with Jacobians evaluated at the current operating point.
This makes the EKF the simplest and most widely-used nonlinear state estimator — at the cost of requiring the user to supply Jacobian functions and the assumption that linearization remains accurate within the filter's uncertainty.
Mathematical Theory
Nonlinear State-Space Model
where and are arbitrary (differentiable) nonlinear functions.
Predict Step
- Compute the Jacobian of at the current estimate:
- Nonlinear state prediction:
- Covariance prediction (using the linearized model):
Update Step
- Compute the Jacobian of at the predicted state:
- Nonlinear innovation:
- Innovation covariance, Kalman gain, state and covariance updates follow the standard Kalman filter equations using the Jacobian :
Complexity Analysis
| Operation | Time | Space | Notes |
|---|---|---|---|
| Jacobian eval | (user-defined) | Depends on the specific nonlinear functions | |
| Predict | Matrix multiply plus nonlinear state propagation | ||
| Update | Same as standard Kalman — the linearized equations are identical | ||
| Total per step | Dominated by Jacobian evaluation for complex models |
Step-by-Step Walkthrough
System: Estimating angle and angular velocity of a simple pendulum from noisy angle measurements.
State: , s.
Nonlinear dynamics:
Jacobian:
Linear measurement: , .
At :
- Predict: (velocity decreases due to restoring force )
- Update with : The Kalman gain weights the measurement against the prediction, pulling toward 0.28.
After 50 iterations the EKF tracks the true pendulum oscillation closely, despite the nonlinear dynamics.
Pitfalls & Edge Cases
- Linearization error. The EKF assumes the nonlinearity is approximately linear within the filter's uncertainty. Large initial errors or highly nonlinear systems can cause divergence.
- Jacobian correctness. Incorrect Jacobians silently produce wrong estimates. Always validate Jacobians numerically (e.g., finite-difference check) before deploying.
- Non-observable modes. If does not observe all states, convergence of unobserved states depends entirely on the model .
- Large time steps. For stiff or fast dynamics, large amplifies linearization errors. Reduce the step size or use a higher-order integration scheme.
- Covariance symmetry. Numerical drift can break symmetry of ; the Joseph form of the covariance update is more robust for long runs.
Variants & Generalizations
- Iterated EKF (IEKF). Re-linearizes the measurement function at the updated state estimate and repeats the update step until convergence. Reduces linearization error in the measurement model at the cost of multiple Jacobian evaluations per time step.
- Second-Order EKF. Includes second-order terms of the Taylor expansion in the prediction and update equations. Improves accuracy for moderately nonlinear systems but requires Hessians of and .
- Error-State EKF. Tracks a small error state rather than the full state. Popular in inertial navigation where the nominal trajectory is integrated separately and the filter corrects deviations.
- EKF with Joseph Form. Replaces the standard covariance update with the symmetric Joseph form to guarantee positive-definiteness under finite-precision arithmetic.
- EKF with Control Input. When the control is present, the state transition becomes and the Jacobian is evaluated at . This variant is supported directly in the implementation via the
ControlSizetemplate parameter.
Comparison with Other Filters
| Filter | Jacobian Required? | Accuracy for Nonlinear Systems | Computational Cost |
|---|---|---|---|
| Kalman Filter | No (linear only) | Exact for linear | Lowest |
| EKF | Yes | First-order approximation | Low |
| UKF | No | Second-order approximation | Moderate |
| Particle | No | Arbitrary (Monte Carlo) | High |
Applications
- Attitude estimation — Fusing gyroscope and accelerometer for orientation (nonlinear quaternion kinematics).
- Robot localization — SLAM (Simultaneous Localization and Mapping) with range-bearing measurements.
- Pendulum control — Estimating angle and angular velocity for swing-up or balancing.
- Battery management — Nonlinear electrochemical models for state-of-charge estimation.
- Spacecraft navigation — Orbit determination from range and range-rate measurements.
Connections to Other Algorithms
graph LR
EKF["Extended Kalman Filter"]
KF["Kalman Filter"]
UKF["Unscented Kalman Filter"]
EL["Euler-Lagrange"]
EKF -->|"linear limit"| KF
UKF -->|"alternative to"| EKF
EL -->|"plant model"| EKF
| Algorithm | Relationship |
|---|---|
| Kalman Filter | The EKF reduces to the standard KF when and are linear |
| Unscented Kalman Filter | Avoids Jacobians using sigma points; better for highly nonlinear cases |
| Euler-Lagrange | Provides the nonlinear dynamics model for mechanical systems |
References & Further Reading
- Simon, D., Optimal State Estimation: Kalman, H∞, and Nonlinear Approaches, Wiley, 2006 — Chapters 13–14.
- Bar-Shalom, Y., Li, X.R. and Kirubarajan, T., Estimation with Applications to Tracking and Navigation, Wiley, 2001.
- Julier, S.J. and Uhlmann, J.K., "Unscented Filtering and Nonlinear Estimation", Proceedings of the IEEE, 92(3), 2004 — Motivation for UKF as EKF alternative.