# Controllability Gramian

In control theory, we may need to find out whether or not a system such as ${\begin{aligned}{\dot {\boldsymbol {x}}}(t)&={\boldsymbol {Ax}}(t)+{\boldsymbol {Bu}}(t)\\{\boldsymbol {y}}(t)&={\boldsymbol {Cx}}(t)+{\boldsymbol {Du}}(t)\end{aligned}}$ is controllable, 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 for a system with $p$ inputs, $n$ state variables and $q$ outputs.
One of the many ways one can achieve such goal is by the use of the Controllability Gramian.

## Controllability 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 observe if the LTI system is or is not controllable simply by looking at the pair $({\boldsymbol {A}},{\boldsymbol {B}})$. Then, we can say that the following statements are equivalent:
* The pair $({\boldsymbol {A}},{\boldsymbol {B}})$ is controllable.
* The $n\times n$ matrix ${\boldsymbol {W_{c}}}(t)=\int _{0}^{t}e^{{\boldsymbol {A}}\tau }{\boldsymbol {BB^{T}}}e^{{\boldsymbol {A}}^{T}\tau }d\tau =\int _{0}^{t}e^{{\boldsymbol {A}}(t-\tau )}{\boldsymbol {BB^{T}}}e^{{\boldsymbol {A}}^{T}(t-\tau )}d\tau$ is nonsingular for any $t>0$.
* The $n\times np$ controllability matrix ${\mathcal {C}}={\begin{bmatrix}{\boldsymbol {B}}&{\boldsymbol {AB}}&{\boldsymbol {A}}^{2}{\boldsymbol {B}}&\cdots &{\boldsymbol {A}}^{n-1}{\boldsymbol {B}}\end{bmatrix}}$ has rank n.
* The $n\times (n+p)$ matrix ${\begin{bmatrix}{\boldsymbol {A}}-\lambda {\boldsymbol {I}}&{\boldsymbol {B}}\end{bmatrix}}$ has full row 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 the Lyapunov equation ${\boldsymbol {A}}{\boldsymbol {W}}_{c}+{\boldsymbol {W}}_{c}{\boldsymbol {A}}^{T}=-{\boldsymbol {BB}}^{T}$ is positive definite, the system is controllable. The solution is called the Controllability Gramian and can be expressed as ${\boldsymbol {W_{c}}}=\int _{0}^{\infty }e^{{\boldsymbol {A}}\tau }{\boldsymbol {BB}}^{T}e^{{\boldsymbol {A}}^{T}\tau }d\tau$
In the following section we are going to take a closer look at the Controllability Gramian.

## Controllability Gramian

The controllability Gramian can be found as the solution of the Lyapunov equation given by ${\boldsymbol {A}}{\boldsymbol {W}}_{c}+{\boldsymbol {W}}_{c}{\boldsymbol {A}}^{T}=-{\boldsymbol {BB}}^{T}$
In fact, we can see that if we take ${\boldsymbol {W_{c}}}=\int _{0}^{\infty }e^{{\boldsymbol {A}}\tau }{\boldsymbol {BB}}^{T}e^{{\boldsymbol {A}}^{T}\tau }d\tau$ as a solution, we are going to find that: ${\begin{aligned}{\boldsymbol {A}}{\boldsymbol {W}}_{c}+{\boldsymbol {W}}_{c}{\boldsymbol {A}}^{T}&=\int _{0}^{\infty }{\boldsymbol {A}}e^{{\boldsymbol {A}}\tau }{\boldsymbol {BB}}^{T}e^{{\boldsymbol {A}}^{T}\tau }d\tau +\int _{0}^{\infty }e^{{\boldsymbol {A}}\tau }{\boldsymbol {BB^{T}}}e^{{\boldsymbol {A}}^{T}\tau }{\boldsymbol {A}}^{T}d\tau \\[1ex]&=\int _{0}^{\infty }{\frac {d}{d\tau }}\left(e^{{\boldsymbol {A}}\tau }{\boldsymbol {B}}{\boldsymbol {B}}^{T}e^{{\boldsymbol {A}}^{T}\tau }\right)d\tau \\[1ex]&=\left.e^{{\boldsymbol {A}}t}{\boldsymbol {B}}{\boldsymbol {B}}^{T}e^{{\boldsymbol {A}}^{T}t}\right|_{t=0}^{\infty }\\[1ex]&={\boldsymbol {0}}-{\boldsymbol {BB}}^{T}\\[1ex]&={\boldsymbol {-BB}}^{T}\end{aligned}}$
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}}_{c}$ is indeed the solution for the Lyapunov equation under analysis.

### Properties

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

## Discrete Time Systems

For discrete time systems as ${\begin{aligned}{\boldsymbol {x}}[k+1]&={\boldsymbol {Ax}}[k]+{\boldsymbol {Bu}}[k]\\{\boldsymbol {y}}[k]&={\boldsymbol {Cx}}[k]+{\boldsymbol {Du}}[k]\end{aligned}}$
One can check that there are equivalences for the statement “The pair $({\boldsymbol {A}},{\boldsymbol {B}})$ is controllable” (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 {B}})$ is controllable” and all the eigenvalues of ${\boldsymbol {A}}$ have magnitude less than $1$ (${\boldsymbol {A}}$ is stable), then the unique solution of $W_{dc}-{\boldsymbol {A}}{\boldsymbol {W}}_{dc}{\boldsymbol {A}}^{T}={\boldsymbol {BB}}^{T}$ is positive definite and given by ${\boldsymbol {W}}_{dc}=\sum _{m=0}^{\infty }{\boldsymbol {A}}^{m}{\boldsymbol {BB}}^{T}\left({\boldsymbol {A}}^{T}\right)^{m}$
That is called the discrete Controllability 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 controllable. More properties and proofs can be found in Chen (1999, p. 169).

## Linear Time Variant Systems

Linear time variant (LTV) systems are those in the form: ${\begin{aligned}{\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{aligned}}$
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 {B}}(t))$ is controllable or not. This can be done in a very similar way of the preceding cases.
The system $({\boldsymbol {A}}(t),{\boldsymbol {B}}(t))$ is controllable 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 Controllability Gramian, given by ${\boldsymbol {W}}_{c}(t_{0},t_{1})=\int _{t_{0}}^{t_{1}}{\boldsymbol {\Phi }}(t_{1},\tau ){\boldsymbol {B}}(\tau ){\boldsymbol {B}}^{T}(\tau ){\boldsymbol {\Phi }}^{T}(t_{1},\tau )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 is not a controllable system.

### Properties of W$_c$(t$_0$,t$_1$)

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