# The Extended Kalman Filter: An Interactive Tutorial for Non-Experts – Part 18

## The Extended Kalman Filter: An Interactive Tutorial for Non-Experts

### Part 18: Computing the Derivative

If you’ve made it this far, you are in a very good position to understand the Extended Kalman Filter. There are just two more things to consider:

1. How to compute the first derivative from an actual signal, without knowing its underlying function.
2. How to generalize our single-valued nonlinear state/observation model to the multi-valued systems we’ve been considering.

To answer the first question, we note that the first derivative of a function
is defined as the limit of the difference between successive values of that function,
divided by the timestep, as the timestep approaches zero:

$f'(x) = \lim_{\Delta x \to 0} \frac{f(x+\Delta x) – f(x)}{\Delta x}$

If you don’t understand that equation, don’t worry: just think about
subtracting successive differences of a signal $y$ to approximate its first
derivative:

$\frac{(y_{k+1} – y_k)} {timestep}$

Indeed, as the demo below shows, this finite difference formula is often a very good approximation to the first derivative. The demo allows you to choose among the same three functions as on the previous page (shown in the interval [0,1]), but this time you can select between the derivative and finite difference:

 $f(x) = e^{2x}$ $f(x) = 10 log_{10}(x)$ $f(x) = 10 e^{-x/10}$ Derivative Finite difference

If one signal (like sensor value $z_k$) is a function of another signal (like state $x_k$), we can divide successive differences of the first signal by successive differences of the second signal:

$\frac{z_{k+1} – z_k}{x_{k+1}-x_k}$

Previous:
Next: