# Observability Gramian

In control theory, we may need to find out whether or not a system such as
${\begin{array}{c}{\dot {\boldsymbol {x}}}(t){\boldsymbol {=Ax}}(t)+{\boldsymbol {Bu}}(t)\\{\boldsymbol {y}}(t)={\boldsymbol {Cx}}(t)+{\boldsymbol {Du}}(t)\end{array}}$
is observable, where ${\boldsymbol {A}}$, ${\boldsymbol {B}}$, ${\boldsymbol {C}}$ and ${\boldsymbol {D}}$ are, respectively, $n\times n$, $n\times p$,$q\times n$ and $q\times p$ matrices.
One of the many ways one can achieve such goal is by the use of the Observability Gramian.

## Observability in LTI Systems

Linear Time Invariant (LTI) Systems are those systems in which the parameters ${\boldsymbol {A}}$, ${\boldsymbol {B}}$, ${\boldsymbol {C}}$ and ${\boldsymbol {D}}$ are invariant with respect to time.
One can determine if the LTI system is or is not observable simply by looking at the pair $({\boldsymbol {A}},{\boldsymbol {C}})$. Then, we can say that the following statements are equivalent:
1. The pair $({\boldsymbol {A}},{\boldsymbol {C}})$ is observable.
2. The $n\times n$ matrix
${\boldsymbol {W_{o}}}(t)=\int _{0}^{t}e^{{\boldsymbol {A}}^{T}\tau }{\boldsymbol {C}}^{T}{\boldsymbol {C}}e^{{\boldsymbol {A}}\tau }d\tau$
is nonsingular for any $t>0$.
3. The $nq\times n$ observability matrix
$\left[{\begin{array}{c}{\boldsymbol {C}}\\{\boldsymbol {CA}}\\{\boldsymbol {CA}}^{2}\\\vdots \\{\boldsymbol {CA}}^{n-1}\end{array}}\right]$
has rank n.
4. The $(n+q)\times n$ matrix
$\left[{\begin{array}{c}{\boldsymbol {A}}{\boldsymbol {-\lambda }}{\boldsymbol {I}}\\{\boldsymbol {C}}\end{array}}\right]$
has full column rank at every eigenvalue $\lambda$ of ${\boldsymbol {A}}$.
If, in addition, all eigenvalues of ${\boldsymbol {A}}$ have negative real parts (${\boldsymbol {A}}$ is stable) and the unique solution of
${\boldsymbol {A^{T}}}{\boldsymbol {W}}_{o}+{\boldsymbol {W}}_{o}{\boldsymbol {A}}=-{\boldsymbol {C^{T}C}}$
is positive definite, then the system is observable. The solution is called the Observability Gramian and can be expressed as
${\boldsymbol {W_{o}}}=\int _{0}^{\infty }e^{{\boldsymbol {A}}^{T}\tau }{\boldsymbol {C^{T}C}}e^{{\boldsymbol {A}}\tau }d\tau$
In the following section we are going to take a closer look at the Observability Gramian.

## Observability Gramian

The Observability Gramian can be found as the solution of the Lyapunov equation given by
${\boldsymbol {A^{T}}}{\boldsymbol {W}}_{o}+{\boldsymbol {W}}_{o}{\boldsymbol {A}}=-{\boldsymbol {C^{T}C}}$
In fact, we can see that if we take
${\boldsymbol {W_{o}}}=\int _{0}^{\infty }e^{{\boldsymbol {A^{T}}}\tau }{\boldsymbol {C^{T}C}}e^{{\boldsymbol {A}}\tau }d\tau$
as a solution, we are going to find that:
${\begin{array}{ccccc}{\boldsymbol {A^{T}}}{\boldsymbol {W}}_{o}+{\boldsymbol {W}}_{o}{\boldsymbol {A}}&=&\int _{0}^{\infty }{\boldsymbol {A^{T}}}e^{{\boldsymbol {A^{T}}}\tau }{\boldsymbol {C^{T}C}}e^{{\boldsymbol {A}}\tau }d\tau &+&\int _{0}^{\infty }e^{{\boldsymbol {A^{T}}}\tau }{\boldsymbol {C^{T}C}}e^{{\boldsymbol {A}}\tau }{\boldsymbol {A}}d\tau \\&=&\int _{0}^{\infty }{\frac {d}{d\tau }}(e^{{\boldsymbol {A^{T}}}\tau }{\boldsymbol {C}}^{T}{\boldsymbol {C}}e^{{\boldsymbol {A}}\tau })d\tau &=&e^{{\boldsymbol {A^{T}}}t}{\boldsymbol {C}}^{T}{\boldsymbol {C}}e^{{\boldsymbol {A}}t}|_{t=0}^{\infty }\\&=&{\boldsymbol {0}}-{\boldsymbol {C^{T}C}}\\&=&{\boldsymbol {-C^{T}C}}\end{array}}$
Where we used the fact that $e^{{\boldsymbol {A}}t}=0$ at $t=\infty$ for stable ${\boldsymbol {A}}$ (all its eigenvalues have negative real part). This shows us that ${\boldsymbol {W}}_{o}$ is indeed the solution for the Lyapunov equation under analysis.

### Properties

We can see that ${\boldsymbol {C^{T}C}}$ is a symmetric matrix, therefore, so is ${\boldsymbol {W}}_{o}$.
We can use again the fact that, if ${\boldsymbol {A}}$ is stable (all its eigenvalues have negative real part) to show that ${\boldsymbol {W}}_{o}$ is unique. In order to prove so, suppose we have two different solutions for
${\boldsymbol {A^{T}}}{\boldsymbol {W}}_{o}+{\boldsymbol {W}}_{o}{\boldsymbol {A}}=-{\boldsymbol {C^{T}C}}$
and they are given by ${\boldsymbol {W}}_{o1}$ and ${\boldsymbol {W}}_{o2}$. Then we have:
${\boldsymbol {A^{T}}}{\boldsymbol {(W}}_{o1}-{\boldsymbol {W}}_{o2})+{\boldsymbol {(W}}_{o1}-{\boldsymbol {W}}_{o2}){\boldsymbol {A}}={\boldsymbol {0}}$
Multiplying by $e^{{\boldsymbol {A^{T}}}t}$ by the left and by $e^{{\boldsymbol {A}}t}$ by the right, would lead us to
$e^{{\boldsymbol {A^{T}}}t}[{\boldsymbol {A^{T}}}{\boldsymbol {(W}}_{o1}-{\boldsymbol {W}}_{o2})+{\boldsymbol {(W}}_{o1}-{\boldsymbol {W}}_{o2}){\boldsymbol {A}}]e^{{\boldsymbol {A}}t}={\frac {d}{dt}}[e^{{\boldsymbol {A^{T}}}t}[({\boldsymbol {W}}_{o1}-{\boldsymbol {W}}_{o2})e^{{\boldsymbol {A}}t}]={\boldsymbol {0}}$
Integrating from $0$ to $\infty$:
$[e^{{\boldsymbol {A^{T}}}t}[({\boldsymbol {W}}_{o1}-{\boldsymbol {W}}_{o2})e^{{\boldsymbol {A}}t}]|_{t=0}^{\infty }={\boldsymbol {0}}$
using the fact that $e^{{\boldsymbol {A}}t}\rightarrow 0$ as $t\rightarrow \infty$:
${\boldsymbol {0}}-({\boldsymbol {W}}_{o1}-{\boldsymbol {W}}_{o2})={\boldsymbol {0}}$
In other words, ${\boldsymbol {W}}_{o}$ has to be unique.
Also, we can see that
${\boldsymbol {x^{T}W_{o}x}}=\int _{0}^{\infty }{\boldsymbol {x}}^{T}e^{{\boldsymbol {A^{T}}}t}{\boldsymbol {C^{T}C}}e^{{\boldsymbol {A}}t}{\boldsymbol {x}}dt=\int _{0}^{\infty }\left\Vert {\boldsymbol {Ce^{{\boldsymbol {A}}t}{\boldsymbol {x}}}}\right\Vert _{2}^{2}dt$
is positive for any ${\boldsymbol {x}}$ (assuming the non-degenerate case where ${\displaystyle {\boldsymbol {Ce^{{\boldsymbol {A}}t}{\boldsymbol {x}}}}}$ is not identically zero), and that makes ${\boldsymbol {W}}_{o}$ a positive definite matrix.
More properties of observable systems can be found in, as well as the proof for the other equivalent statements of "The pair $({\boldsymbol {A}},{\boldsymbol {C}})$ is observable" presented in section Observability in LTI Systems.

## Discrete Time Systems

For discrete time systems as
${\begin{array}{c}{\boldsymbol {x}}[k+1]{\boldsymbol {=Ax}}[k]+{\boldsymbol {Bu}}[k]\\{\boldsymbol {y}}[k]={\boldsymbol {Cx}}[k]+{\boldsymbol {Du}}[k]\end{array}}$
One can check that there are equivalences for the statement "The pair $({\boldsymbol {A}},{\boldsymbol {C}})$ is observable" (the equivalences are much alike for the continuous time case).
We are interested in the equivalence that claims that, if "The pair $({\boldsymbol {A}},{\boldsymbol {C}})$ is observable" and all the eigenvalues of ${\boldsymbol {A}}$ have magnitude less than $1$ (${\boldsymbol {A}}$ is stable), then the unique solution of
${\boldsymbol {A^{T}}}{\boldsymbol {W}}_{do}{\boldsymbol {A}}-W_{do}=-{\boldsymbol {C^{T}C}}$
is positive definite and given by
${\boldsymbol {W}}_{do}=\sum _{m=0}^{\infty }({\boldsymbol {A}}^{T})^{m}{\boldsymbol {C}}^{T}{\boldsymbol {C}}{\boldsymbol {A}}^{m}$
That is called the discrete Observability Gramian. We can easily see the correspondence between discrete time and the continuous time case, that is, if we can check that ${\boldsymbol {W}}_{dc}$ is positive definite, and all eigenvalues of ${\boldsymbol {A}}$ have magnitude less than $1$, the system $({\boldsymbol {A}},{\boldsymbol {B}})$ is observable. More properties and proofs can be found in.

## Linear Time Variant Systems

Linear time variant (LTV) systems are those in the form:
${\begin{array}{c}{\dot {\boldsymbol {x}}}(t){\boldsymbol {=A}}(t){\boldsymbol {x}}(t)+{\boldsymbol {B}}(t){\boldsymbol {u}}(t)\\{\boldsymbol {y}}(t)={\boldsymbol {C}}(t){\boldsymbol {x}}(t)\end{array}}$
That is, the matrices ${\boldsymbol {A}}$, ${\boldsymbol {B}}$ and ${\boldsymbol {C}}$ have entries that varies with time. Again, as well as in the continuous time case and in the discrete time case, one may be interested in discovering if the system given by the pair $({\boldsymbol {A}}(t),{\boldsymbol {C}}(t))$ is observable or not. This can be done in a very similar way of the preceding cases.
The system $({\boldsymbol {A}}(t),{\boldsymbol {C}}(t))$ is observable at time $t_{0}$ if and only if there exists a finite $t_{1}>t_{0}$ such that the $n\times n$ matrix also called the Observability Gramian is given by
${\boldsymbol {W}}_{o}(t_{0},t_{1})=\int _{t_{0}}^{^{t_{1}}}{\boldsymbol {\Phi }}^{T}(\tau ,t_{0}){\boldsymbol {C}}^{T}(\tau ){\boldsymbol {C}}(\tau ){\boldsymbol {\Phi }}(\tau ,t_{0})d\tau$
where ${\boldsymbol {\Phi }}(t,\tau )$ is the state transition matrix of ${\boldsymbol {\dot {x}}}={\boldsymbol {A}}(t){\boldsymbol {x}}$ is nonsingular.
Again, we have a similar method to determine if a system is or not an observable system.

### Properties of ${\boldsymbol {W}}_{o}(t_{0},t_{1})$

We have that the Observability Gramian ${\boldsymbol {W}}_{o}(t_{0},t_{1})$ have the following property:
${\boldsymbol {W}}_{o}(t_{0},t_{1})={\boldsymbol {W}}_{o}(t_{0},t)+{\boldsymbol {\Phi }}^{T}(t,t_{0}){\boldsymbol {W}}_{o}(t,t_{0}){\boldsymbol {\Phi }}(t,t_{0})$
that can easily be seen by the definition of ${\boldsymbol {W}}_{o}(t_{0},t_{1})$ and by the property of the state transition matrix that claims that:
${\boldsymbol {\Phi }}(t_{0},t_{1})={\boldsymbol {\Phi }}(t_{1},\tau ){\boldsymbol {\Phi }}(\tau ,t_{0})$
More about the Observability Gramian can be found in.