summaryrefslogtreecommitdiff
path: root/KalmanIntro.mdwn
blob: d856051db75c960c426c7470dcb3189ad36c1034 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
[[(See also our mathematical notation page)|MathSymbols]]

[[!toc ]]

# Basics

Given a system model, an initial system state, and a sequence of noisy measurements, a Kalman filter can be constructed to produce a sequence of state estimates that are optimal in the sense that they minimize the expected square-error between the estimates and the true system state.

<a name="TblNum1" id="TblNum1"></a> **Summary of Kalman Filter Symbols**
<div>
  <table>
    <tbody>
      <tr>
        <td>
[[!table class="data" data="""
Symbol | Definition | Name
**x**                | n&times;1  |system state vector
**&Phi;** (Phi)      | n&times;n  |state transition matrix
**P**                | n&times;n  |state error covariance matrix
**u**                | u&times;1  |control input vector
**&Gamma;** (Gamma)  | n&times;u  |control input Matrix
**w**                | q&times;1  |process noise vector
**&Lambda;** (Lambda)| n&times;q  |process noise input matrix
**Q**                | q&times;q  |process noise covariance matrix
**y**                | m&times;1  |output vector
**H**                | m&times;n  |output matrix
**&nu;** (nu)        | m&times;1  |measurement noise vector
**R**                | m&times;m  |measurement noise covariance matrix
**K**                | n&times;m  |Kalman gain, feedback matrix
"""]]
        </td>
      </tr>
      <tr>
        <td style="text-align: center">
          <p>Table (1)</p>
        </td>
      </tr>
    </tbody>
  </table>
</div>
     
<a name="TblNum2" id="TblNum2"></a> **Typical Kalman Filter Equations**
<div>
  <table>
    <tbody>
      <tr>
        <td>
[[!table class="data" data="""
Equation | Description
[[!teximg code="\bf{\hat x_0} = \it E[\bf{x_0}]"]] | **state initialization**
[[!teximg code="\bf{P_0} = \it E[(\bf{\hat x_0 - x_0})^2]"]] | **state error initialization**
[[!teximg code="\bf{x_k^-} = \bf{\Phi_{k-1} \hat x_{k-1} + \Gamma_{k-1} u_{k-1}}"]] | **state propagation** <br/>Previous knowledge of the system is used to guess the future state.
[[!teximg code="\bf{P_k^-} = \bf{\Phi_{k-1} P_{k-1} \Phi_{k-1}^{\rm T} + \Lambda_{k-1} Q_{k-1} \Lambda_{k-1}^{\rm T}}"]] | **state error propagation** <br/>System dynamics effect the error. Process noise increases the error.
[[!teximg code="\bf{K_k} = \bf{P_k^-\, H_k^{\rm T} (H_k P_k^-\, H_k^{\rm T} + R_k)^{-1}}"]] | **Kalman gain update** <br/>Recursive least squares solution, trades off state uncertainty and measurement noise.
[[!teximg code="\bf{\hat x_k} = \bf{x_k^- + K_k (\tilde y_k - H_k x_k^-)}"]] | **measurement update**<br/> New optimal state estimate
[[!teximg code="\bf{P_k} = \bf{((P_k^-)^{-1} + H_k^{\rm T} R_k^{-1} H_k)^{-1}}"]] | **state error update**<br/>  new measurements add to knowledge of system, estimated error decreases
"""]]
        </td>
      </tr>
      <tr>
        <td style="text-align: center">
          <p>Table (2)</p>
        </td>
      </tr>
    </tbody>
  </table>
</div>

Start with the discreet linear dynamic system equation

<a name="EqNum1Dot1" id="EqNum1Dot1"></a>
[[!teximg code="\displaystyle (1.1)\quad\
  \bf{x_{k+1}} = \bf{\Phi_k\ x_k} + \bf{\Gamma_k} \bf{u_k} + \bf{\Lambda_k} \bf{w_k}"]]

And the measurement equation

<a name="EqNum1Dot2" id="EqNum1Dot2"></a>
[[!teximg code="\displaystyle (1.2)\quad\
  \bf{\tilde y_k} = \bf{H_k} \bf{x_k} + \bf{\nu_k}"]]

Where the subscript (&middot;<sub>k</sub>) indicates the value at time step (t<sub>k</sub>)

Although the form of the system equations would seem to apply only to strictly
linear systems, as usual, various linearizations and quasi-non-linear
techniques can be applied to extend the Kalman filter to a variety of real
world non-linear problems.

Making some key assumptions will greatly simplify what follows.<br/>
Assume that

- For each time step (k); (**<big>&Phi;</big>**<sub>k</sub>),
  (**<big>&Gamma;</big>**<sub>k</sub>), (**<big>&Lambda;</big>**<sub>k</sub>),
  (**H**<sub>k</sub>) and (**u**<sub>k</sub>) are known without error
- Noise components (**w**<sub>k</sub>) and (**<big>&nu;</big>**<sub>k</sub>)
  are uncorrelated Gaussian random sequences with zero mean
- The noise covariance matrices are known,
  (cov[**w**<sub>k</sub>]=**Q**<sub>k</sub>),
  (cov[**<big>&nu;</big>**<sub>k</sub>]=**R**<sub>k</sub>)

In principle these assumptions can be relaxed somewhat. For example, if any of
the system matrices contain random components, those components may be factored
out into the noise vectors. Similarly, any noise process that is representable
as a linear combination of white Gaussian noise can be modeled by adding extra
states to the system and driving those extra states with zero mean Gaussian
noise. Even if the noise matrices are not known exactly, they can be estimated,
or calculated on line, or discovered by system tuning.

The exact quantity minimized by a Kalman filter is the matrix (**P**),
the _state error covariance matrix_

<a name="EqNum1Dot3" id="EqNum1Dot3"></a>
[[!teximg code="\displaystyle (1.3)\quad\
  \bf{P} \equiv \it{E}[\bf{(\hat x-x)}^2]"]]

Where (_E_ ) is a function returning the expectation of a random variable

The estimated state (**x&#770;**) that minimizes (**P**) is found by solving a
weighted least squares problem. The weights for the computation ultimately come
from the process noise covariance matrix (**Q**) and the measurement noise
covariance matrix (**R**). The actual output of the filter is a sequence of
linear combinations formed from the predicted state (**x**&#8315;), and
the current measurements of the system (**y&#771;**). Technically these outputs
are known as the _best linear unbiased estimates_. The existence of such
estimates is guaranteed only with certain restrictions, see the section on
complications.
(FIXME: complications section not built yet)

Typically the Kalman filter is implemented recursively as a
_predictor-corrector_ system. In the prediction step, knowledge of the past
state of the system is used to extrapolate to the system's state at the next
time step. Once the next time step is actually reached and new measurements
become available, the new measurements are used to refine the filter's estimate
of the true state like this

<a name="EqNum1Dot4" id="EqNum1Dot4"></a>
[[!teximg code="\displaystyle (1.4)\quad\
  \bf{\hat x_k} = \bf{x_k^-} + \bf{K_k}(\bf{\tilde y_k}-\bf{H_k}\bf{x_k^-})"]]

Where the matrix (**K**<sub>k</sub>), the _Kalman gain_, or _feedback matrix_,
is chosen so that (**P**<sub>k</sub>) is minimized

Later there will be some [justification](#EqNum3Dot14), but for now accept that
one possible choice for (**K**<sub>k</sub>) is

<a name="EqNum1Dot5" id="EqNum1Dot5"></a>
[[!teximg code="\displaystyle (1.5)\quad\
  \bf{K_k} = \bf{P_k^-\, H_k^{\rm T} (H_k P_k^-\, H_k^{\rm T} + R_k)^{-1}}
  = \bf{\frac {P_k^-\, H_k^{\rm T}}{H_k P_k^-\, H_k^{\rm T} + R_k}}"]]

Where the _measurement noise covariance matrix_ (**R**<sub>k</sub>) is defined
as

 <a name="EqNum1Dot6" id="EqNum1Dot6"></a>
[[!teximg code="\displaystyle (1.6)\quad\
    \bf{R} \equiv \mbox{\rm cov}[\bf{\nu}] = \it E[\bf{\nu}^2]"]]

The relative magnitudes of matrices (**R**<sub>k</sub>) and (**P**<sub>k</sub>)
control a trade-off between the filter's use of predicted state estimate
(**x**<sub>k</sub>&#8315;) and measurement (**y**&#771;<sub>k</sub>).

Consider some limits on (**K**<sub>k</sub>)

<a name="EqNum1Dot7" id="EqNum1Dot7"></a>
[[!teximg code="\displaystyle (1.7a)\quad\
  \lim\limits_{\bf{R_k \to 0}} \bf{{P_k^-\, H_k^{\rm T}} \over\
  {H_k P_k^-\, H_k^{\rm T} + R_k}}\
    = \bf{H_k^{-1}}"]]

[[!teximg code="\displaystyle (1.7b)\quad\
  \lim\limits_{\bf{P_k \to 0}} \bf{{P_k^-\, H_k^{\rm T}} \over\
  {H_k P_k^-\, H_k^{\rm T} + R_k}}\
   = \bf 0"]]

Substituting the first limit into the measurement update equation
[(1.4)](#EqNum1Dot4) suggests that when the magnitude of (**R**) is small,
meaning that the measurements are accurate, the state estimate depends mostly
on the measurements. Likewise when the state is known accurately, then
(**H P**&#8315; **H**<sup>T</sup>) is small compared to (**R**), and the
filter mostly ignores the measurements relying instead on the prediction
derived from the previous state (**x**<sub>k</sub>&#8315;).

# Example

- [[Simple Kalman Example|Example1D]]

# Derivation

The desired Kalman filter implementation is linear and recursive, that is,
given the old filter state (**&#x1d4d5;**<sub>k-1</sub>) and new measurements
(**&#x1d4dC;**<sub>k</sub>) the new filter state is calculated as

<a name="EqNum3Dot1" id="EqNum3Dot1"></a>
[[!teximg code="\displaystyle (3.1a)\quad\
  {\cal F}_k^- = \it g [{\cal F}_{k-1}]"]]

[[!teximg code="\displaystyle (3.1b)\quad\
  {\cal F}_k = \it f [{\cal F}_k^-\,,\ {\cal M}_k]"]]

Where ( _f_ and _g_ ) are linear functions

Referring to [table(2)](#TblNum2), the sequence of equations shown are both
linear and recursive as desired. Though so far, little explanation has been
given to justify their use. In order to maintain some credibility, and to prove
we aren't total mathematical wimps, we will attempt a derivation of these
equations. The goal here is not mathematical perfection, rather clarity without
serious error.

Fundamentally Kalman filtering involves solving a least squares error problem.
Specifically, given a state estimate (**x**&#8315;) of known covariance
(**P**&#8315;) and a new set of measurements (**y**&#771;) with covariance
(**R**), find a new state estimate (**x**&#770;) such that the new state error
covariance (**P**) is minimized.

For the predicted state error write

<a name="EqNum3Dot2" id="EqNum3Dot2"></a>
[[!teximg code="\displaystyle (3.2)\quad\
  \bf \mbox{\rm cov}[\bf{x^- - x}] = \bf P^-"]]

Likewise for the measurement error

<a name="EqNum3Dot3" id="EqNum3Dot3"></a>
[[!teximg code="\displaystyle (3.3)\quad\
  \bf \mbox{\rm cov}[\bf{\tilde y - y}] = \bf R"]]

Seek a new state vector (**x**&#770;) such that the (n+m&times;1) combined
state error vector

<a name="EqNum3Dot4" id="EqNum3Dot4"></a>
[[!teximg code="\displaystyle (3.4)\quad\
  \begin{pmatrix} \bf I \\ \bf H \end{pmatrix}\
  \bf{\hat x} - \begin{pmatrix} \bf x^- \\ \bf{\tilde y} \end{pmatrix}"]]

Is minimized in the weighted least squares sense

The chief difficulty with Kalman filter theory is contained in
[(3.4)](#EqNum3Dot4). The errors in [(3.2)](#EqNum3Dot2) and
[(3.3)](#EqNum3Dot3) are defined in terms of the true state and exact
measurements, but while operating the filter, all that is available are
estimates and noisy measurements. In equation [(3.4)](#EqNum3Dot4) the
measurement (**y**&#771;) and the estimated state (**x**&#8315;) have been used
where the exact values would seem to be appropriate. Here's a simple-minded
explanation of why it's ok to use the imprecise values in [(3.4)](#EqNum3Dot4):
The noise has been assumed to be zero-mean, therefore the _expectation_ of the
approximate values are the correct true values, so using the approximate values
will produce unbiased estimates. Further, since it has been assumed that the
covariance of both (**y**&#771;) and (**x**&#8315;) are known, the weighted
least squares process has enough information to properly minimize the total
square error.

Whether the previous paragraph constitutes a satisfactory justification of
[(3.4)](#EqNum3Dot4) is a question worth pondering. If not there are many,
many, many, books that address this issue (try looking up _stochastic least
squares_). (However the chances of finding a very clear explanation appear to
be low.) The issue is significant in as much as once [(3.4)](#EqNum3Dot4) is
accepted, Kalman filtering as a theoretical matter is essentially solved.
Though, solved in this sense is still far from a practical implementation. To
derive a practical filter, some clever arithmetic is required.

A weighted least squares solution minimizes a scalar cost function (&#x1D4D9;),
here written in matrix form

<a name="EqNum3Dot5" id="EqNum3Dot5"></a>
[[!teximg code="\displaystyle (3.5)\quad\
  \cal{J}[\bf \epsilon , \bf W] = \bf{\epsilon}^{\rm T} \, \bf W \, \bf \epsilon"]]

Where the matrix (**W**) is the weighting for the cost function. The weighting
can be any positive definite matrix.

In formulating the Kalman filter the noise statistics have been defined in
terms of covariance, and since elements with large covariance should be given
low weight, the correct weighting matrix for this problem is the inverse of the
covariance matrix. This is appealing intuitively and not too difficult to
prove, though no proof is given here.

Using the inverse covariance as the weighting function and referring to
[(3.4)](#EqNum3Dot4) the cost function for the Kalman filter is

<a name="EqNum3Dot6" id="EqNum3Dot6"></a>
[[!teximg code="\displaystyle (3.6)\quad\
  \cal{J} =\
  \begin{pmatrix}\
    \bf{I\, \hat x_k} - \bf{x_k^-} \\\
      \bf{H_k \hat x_k} - \bf{\tilde y_k}\
  \end{pmatrix}^{\rm T}\
  \begin{pmatrix}\
    \bf P_k^- & \bf 0  \\  \bf 0 & \bf R_k\
  \end{pmatrix}^{\rm -1}\
  \begin{pmatrix}\
    \bf{I \, \hat x_k} - \bf{x_k^-} \\ \bf{H_k \hat x_k} - \bf{\tilde y_k}
  \end{pmatrix}"]]

Where the block matrices shown have dimensions (n+m&times;1) and
(n+m&times;n+m) respectively

The notational mapping suggested by [(3.4)](#EqNum3Dot4) is

<a name="EqNum3Dot7" id="EqNum3Dot7"></a>
[[!teximg code="\displaystyle (3.7)\quad\
  \left\{\
    \begin{pmatrix} \bf I \\ \bf H_k \end{pmatrix}\
                           \rightarrow          \bf H,\
    \bf{\hat x_k}          \rightarrow          \bf{\hat x},\
    \begin{pmatrix} \bf x_k^- \\ \bf{\tilde y_k} \end{pmatrix}\
                           \rightarrow  \bf{\tilde y},\
    \begin{pmatrix} \bf P_k^- & 0 \\ 0 & \bf R_k \end{pmatrix}
                           \rightarrow          \bf{R}\
  \right\}"]]

Use this mapping to state the cost function in a slightly more generic form as

<a name="EqNum3Dot8" id="EqNum3Dot8"></a>
[[!teximg code="\displaystyle (3.8)\quad\
  \begin{split}
    \cal{J}& = \bf{(H\,\hat x - \tilde y)^{\rm T}\,R^{-1} (H\,\hat x - \tilde y})\\
    & = (\bf{\hat x^{\rm T} \, H^{\rm T} - \tilde y^{\rm T}})\,\bf R^{-1}\
      (\bf{H\,\hat x - \tilde y})\\
    & = (\bf{\hat x^{\rm T}\,H^{\rm T} - \tilde y^{\rm T}})\
      (\bf{R^{-1}\,H\,\hat x - R^{-1}\,\tilde y})\\
    & = \bf{\hat x^{\rm T}\,H^{\rm T}\,R^{-1}\,H\,\hat x -\
      \hat x^{\rm T}\,H^{\rm T}\,R^{-1}\,\tilde y - \tilde y^{\rm T}\,R^{-1}\,H\,\hat x +\
      \tilde y^{\rm T}\,R^{-1}\,\tilde y}
  \end{split}"]]

In [(3.8)](#EqNum3Dot8) the cost function has been expanded in anticipation of
taking derivatives. (A matrix derivative typically involves taking a transpose.)

Returning to the generic minimization problem, take the partial derivative

<a name="EqNum3Dot9" id="EqNum3Dot9"></a>
[[!teximg code="\displaystyle (3.9)\quad\
  \begin{split}\
    \frac{\partial\cal{J}} {\partial\bf{\hat x}}\
      & = \bf{H^{\rm T}\,R^{-1}\,H\,\hat x + (\hat x^{\rm T}\,H^{\rm T}\,R^{-1}\,H)^{\rm T}\
        - H^{\rm T}\,R^{-1}\,\tilde y - (\tilde y^{\rm T}\,R^{-1}\,H)^{\rm T}}\\\
      & = 2\ \bf{H^{\rm T}\,R^{-1}\,H\,\hat x} - 2\ \bf{H^{\rm T}\,R^{-1}\,\tilde y}\\\
  \end{split}"]]

Set the derivative to zero and solve for (**x**&#770;)

<a name="EqNum3Dot10" id="EqNum3Dot10"></a>
[[!teximg code="\displaystyle (3.10)\quad\
  \bf{\hat x} = \bf{(H^{\rm T}\,R^{-1}\,H)^{-1}\,H^{\rm T}\,R^{-1}\,\tilde y}"]]

This is the classic weighted least squares solution.

Applying [(3.10)](#EqNum3Dot10) to our original problem using
 [(3.7)](#EqNum3Dot7) gets

<a name="EqNum3Dot11" id="EqNum3Dot11"></a>
[[!teximg code="\displaystyle (3.11)\quad\
  \begin{split}\
    \bf{\hat x_k} & =\
      \left(\
        \begin{pmatrix} \bf I \\ \bf H_k \end{pmatrix}^{\rm T}\
        \begin{pmatrix}\
          \bf P_k^- & \bf 0 \\ \bf 0 & \bf R_k\
        \end{pmatrix}^{-1}\
        \begin{pmatrix} \bf I \\ \bf H_k \end{pmatrix}\
      \right)^{-1}\
      \begin{pmatrix} \bf I \\ \bf H_k \end{pmatrix}^{\rm T}\
      \begin{pmatrix} \bf P_k^- & \bf 0 \\ \bf 0 & \bf R_k \end{pmatrix}^{-1}\
      \begin{pmatrix} \bf x_k^- \\ \bf{\tilde y_k} \end{pmatrix}\\\
    & =\
      (\bf{P_k^-}^{-1}+\bf{H_k^{\rm T}\, R_k^{-1}\,H_k})^{-1}\
      (\bf{P_k^-}^{-1}\,\bf{x_k^- + H_k^{\rm T}\, R_k^{-1}\,\tilde y_k})\
  \end{split}"]]

There's nothing wrong with the form given in [(3.11)](#EqNum3Dot11), but for
various reasons it's desirable to exhibit the measurement update form
[(1.4)](#EqNum1Dot4). To do this everyone uses the _matrix inversion lemma_

<a name="EqNum3Dot12" id="EqNum3Dot12"></a>
[[!teximg code="\displaystyle (3.12)\quad\
  \bf{(A-B^{\rm T}\,C^{-1}\,B)^{-1} =\
    A^{-1}-A^{-1}\,B^{\rm T}(B\,A^{-1}B^{\rm T}-C)^{-1}B\,A^{-1}}"]]

Using the mapping

<a name="EqNum3Dot13" id="EqNum3Dot13"></a>
[[!teximg code="\displaystyle (3.13)\quad\
  \left\{
    \bf A  \rightarrow  \bf{P_k^-}^{-1},\ \
    \bf B  \rightarrow  \bf H_k        ,\ \
    \bf C  \rightarrow  -\bf R_k        \ \
  \right\}"]]

The solution given by [(3.11)](#EqNum3Dot11) becomes

<a name="EqNum3Dot14" id="EqNum3Dot14"></a>
[[!teximg code="\displaystyle (3.14)\quad\
  \begin{split}\
  \bf{\hat x_k} & = \bf{\
    (P_k^- - P_k^-\,H_k^{\rm T} (H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}\
      H_k\,P_k^-) ({P_k^-}^{-1}\,x_k^- + H_k^{\rm T}\,R_k^{-1}\,\tilde y_k)
    }\\\
  & = \bf{\
    P_k^-\,{P_k^-}^{-1}\,x_k^- + P_k^-\,H_k^{\rm T}\,R_k^{-1}\,\tilde y_k\
    - P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}\
      H_k\,P_k^-\,{P_k^-}^{-1}\,x_k^-}\\\
  &\quad - \bf{\
    P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}H_k\,P_k^-\,\
      H_k^{\rm T}\,R_k^{-1}\,\tilde y_k}\\\
  & = \bf{\
    x_k^- - P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}H_k\,x_k^-}\\\
  &\quad - \bf{\
    P_k^-\,H_k^{\rm T}(I-(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}H_k\,P_k^-\,\
      H_k^{\rm T})R_k^{-1}\,\tilde y_k}\\\
  & = \bf{\
    x_k^- - P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}H_k\,x_k^-\ \
    - P_k^-\,H_k^{\rm T}}\\\
  &\quad \cdot \bf{\
    \left(\
      (H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}(H_k\,P_k^-\,H_k^{\rm T}\ + R_k)\
      - (H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}H_k\,P_k^-\,H_k^{\rm T}\
    \right)}\\\
  &\quad \cdot \bf{\
    R_k^{-1}\,\tilde y_k}\\\
  & = \bf{\
    x_k^- - P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}H_k\,x_k^-}\\\
  &\quad - \bf{\
    P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}\
    (H_k\,P_k^-\,H_k^{\rm T} + R_k\
    - H_k\,P_k^-\,H_k^{\rm T})R_k^{-1}\,\tilde y_k}\\\
  & = \bf{\
    x_k^- - P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T} + R_k)^{-1}H_k\,x_k^-}\\\
  &\quad - \bf{\
    P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T}\
    + R_k)^{-1}R_k\,R_k^{-1}\,\tilde y_k}\\\
  & = \bf{\
    x_k^- - P_k^-\,H_k^{\rm T}(H_k\,P_k^-\,H_k^{\rm T}\
    + R_k)^{-1}(H_k\,x_k^- - \tilde y_k)
  }\\\
  & = \bf{\
    x_k^- + K_k (\tilde y_k - H_k\,x_k^-)
  }
  \end{split}"]]

Which matches the measurement update form given in [(1.4)](#EqNum1Dot4) with
(**K**<sub>k</sub>) as in [(1.5)](#EqNum1Dot5)

It's possible to derive the state error update equation directly from the
definition given in [(1.3)](#EqNum1Dot3) and repeated here

<a name="EqNum3Dot15" id="EqNum3Dot15"></a>
[[!teximg code="\displaystyle (3.15)\quad\
  \bf{P} \equiv \it{E}[\bf{(\hat x - x)}^2]"]]

It would be very convenient to write the true state (**x**<sub>k</sub>) in
terms of (**x**&#770;), in fact the previous hand-waving argument in support of
equation [(3.4)](#EqNum3Dot4) implies this must be possible.

Using the mapping defined in [(3.7)](#EqNum3Dot7), the measurement equation is

<a name="EqNum3Dot16" id="EqNum3Dot16"></a>
[[!teximg code="\displaystyle (3.16)\quad\
  \bf{\tilde y = H\,x +\
    \begin{pmatrix} \bf{x_k^- - x_k} \\ \bf \nu \end{pmatrix}}"]]

According to our least squares solution [(3.10)](#EqNum3Dot10)

<a name="EqNum3Dot17" id="EqNum3Dot17"></a>
[[!teximg code="\displaystyle (3.17)\quad\
  \begin{split}\
    \bf{\hat x} & =\
      \bf{(H^{\rm T}\,R^{-1}\,H)^{-1} H^{\rm T}\,R^{-1}\,\tilde y}\\\
    & =\
      \bf{(H^{\rm T}\,R^{-1}\,H)^{-1}H^{\rm T}\,R^{-1}}
	 \left( \bf{H\,x +
           \begin{pmatrix} \bf{x_k^- - x_k} \\ \bf \nu \end{pmatrix}} 
	 \right)\\\
    & =\
      \bf{x + (H^{\rm T}\,R^{-1}\,H)^{-1} H^{\rm T}\,R^{-1}
        \begin{pmatrix} \bf{x_k^- - x_k} \\ \bf \nu \end{pmatrix}}\
  \end{split}"]]

Putting this into the definition for (**P**)

<a name="EqNum3Dot18" id="EqNum3Dot18"></a>
[[!teximg code="\displaystyle (3.18)\quad\
  \begin{split}\
    \bf P & =\
      \it{E}[(\bf{\hat x - x})^2]\
      = \it{E} \left[ \left(\
        \bf{(H^{\rm T}\,R^{-1}\,H)^{-1} H^{\rm T}\,R^{-1}\
          \begin{pmatrix} \bf{x_k^- - x_k} \\ \bf \nu \end{pmatrix}\
        }\right)^2 \right]\\\
    & = \bf{\
      \left( \bf{(H^{\rm T}\,R^{-1}\,H)^{-1}H^{\rm T}\,R^{-1}} \right)\
      \it{E} \left[\
        \begin{pmatrix} \bf{x_k^- - x_k} \\ \bf{\nu} \end{pmatrix}^2\
      \right]\
      \left(\
        \bf{(H^{\rm T}\,R^{-1}\,H)^{-1}H^{\rm T}\,R^{-1}}\
      \right)^{\rm T}}\\\
    & = \bf{\
      \left( (H^{\rm T}\,R^{-1}\,H)^{-1}H^{\rm T}\,R^{-1} \right)\
      \,R\,\
      \left( (H^{\rm T}\,R^{-1}\,H)^{-1}H^{\rm T}\,R^{-1} \right)^{\rm T}}\\\
    & =\
      (\bf{H^{\rm T}\,R^{-1} H})^{-1}\
  \end{split}"]]

Substituting back the values for (**H**) and (**R**) from [(3.7)](#EqNum3Dot7)

<a name="EqNum3Dot19" id="EqNum3Dot19"></a>
[[!teximg code="\displaystyle (3.19)\quad\
  \begin{split}\
    \bf{P_k} & =\
      \left(\
        \begin{pmatrix} \bf I \\ \bf H_k \end{pmatrix}^{\rm T}\
        \begin{pmatrix}\
          \bf P_k^- & \bf 0 \\ \bf 0 & \bf R_k\
        \end{pmatrix}^{-1}\
        \begin{pmatrix} \bf I \\ \bf H_k \end{pmatrix}\
      \right)^{-1}\\\
    & =\
      (\bf{{P_k^-}^{-1} + H_k^{\rm T}\,R_k^{-1} H_k})^{-1}\
  \end{split}"]]

Equation [(3.19)](#EqNum3Dot19) performs the "measurement update" for the state
error estimate (**P**).
<br/>It can be written as a parallel sum

<a name="EqNum3Dot20" id="EqNum3Dot20"></a>
[[!teximg code="\displaystyle (3.20)\quad\
  \bf{ {1 \over P_k} = {1 \over P_k^-} + H_k^{\rm T} {1 \over R_k} H_k }"]]

The last term in [(3.20)](#EqNum3Dot20) can be considered to represent the
extra information added to the state because of the current measurement.

The form of [(3.20)](#EqNum3Dot20) makes sense because adding new information
(positive (**R**<sub>k</sub><sup>-1</sup>)) will tend to decrease the system
uncertainty.

Now all that remains is to derive the state error propagation equation.
Again using definition [(1.3)](#EqNum1Dot3)

<a name="#EqNum3Dot21"></a>
[[!teximg code="\displaystyle (3.21)\quad\
  \bf P_{k+1}^- =\
  \it{E} [ ( \bf{ x_{k+1}^- - x_{k+1} } )^2 ]"]]

Applying the state propagation equation [(1.1)](#EqNum1Dot1) to the inside of
[(3.21)](#EqNum3Dot21), the control input, being common, cancels out

<a name="EqNum3Dot22" id="EqNum3Dot22"></a>
[[!teximg code="\displaystyle (3.22)\quad\
  ( \bf{ x_{k+1}^- - x_{k+1} } ) =\
  \bf{ \Phi_k (\hat x_k - x_k) + \Gamma_k (u_k - u_k) + \Lambda_k\,w_k) }"]]

So

<a name="EqNum3Dot23" id="EqNum3Dot23"></a>
[[!teximg code="\displaystyle (3.23)\quad\
  \bf{P_{k+1}^-} =
    \it{E}[ \bf{ \Phi_k (\hat x_k - x_k)^2 \Phi_k^{\rm T} +\
    \Lambda_k\,w_k^2\,\Lambda_k^{\rm T} +
    \Phi_k (\hat x_k - x_k) w_k^2\,\Lambda_k^{\rm T} +
    \Lambda_k\,w_k (\hat x_k - x_k)^2 \Phi_k^{\rm T} } ]"]]

In [(3.23)](#EqNum3Dot23) the expectation of the cross terms is zero because
(**x**<sub>k</sub>) contains terms of (**w**<sub>k-1</sub>) only, and by the
assumption that (**w**) is white noise.

<a name="EqNum3Dot24" id="EqNum3Dot24"></a>
[[!teximg code="\displaystyle (3.24)\quad\
  \it{E}[ \bf{ w_k\,w_{k-1} } ] = \bf 0"]]

So finally

<a name="EqNum3Dot25" id="EqNum3Dot25"></a>
[[!teximg code="\displaystyle (3.25)\quad\
  \bf{P_{k+1}^-} = \bf{ \Phi_k\,P_k\,\Phi_k^{\rm T} + \Lambda_k\,Q_k\,\Lambda_k^{\rm T} }"]]

The derivation of the equations in [table(2)](#TblNum2) is now complete.