# State and Output Equation

We consider a dynamical system that is described by the state variables $\mathbf{x}(t)$, where $\mathbf{x}(t)$ is a vector in the state-space $\mathbf{x} \in \mathbb{R}^n$. The representation of a system is not unique, e.g. the system can be represented in cartesian or polar coordinates, however the dimension of the state-space is independent of the representation. The system can be influenced by some input $\mathbf{u}(t)$. Together they generate a certain output or response $\mathbf{y}(t)$. The equations describing the state of the dynamical system are \begin{align} \dot{\mathbf{x}}(t)=\mathbf{f}(\mathbf{x},\mathbf{u},t)\\ \end{align} and the equations describing the output of the system are \begin{align} \mathbf{y}(t)=\mathbf{g}(\mathbf{x},\mathbf{u},t)\\ \end{align} In general $\mathbf{f}$ and $\mathbf{g}$ involve time explicitly. In this case they are called time varying systems. If we assume that the system is autonomous, in other words that the system contains no explicit time dependence, then it is called a time-invariant system. In the case of a nonlinear system, we can linearize the system about a steady state to obtain a linear time-invariant system that obeys the state and output equation \begin{align} \dot{\mathbf{x}}(t)&=\mathbf{A}\mathbf{x}(t)+\mathbf{B}\mathbf{u}(t)\\ \mathbf{y}(t)&=\mathbf{C}\mathbf{x}(t)+\mathbf{D}\mathbf{u}(t)\\ \end{align}

## Example

Spring mass system

Spring mass system: external force acting on the mass $u(t)$; $y(t)$ deviation of the equilibrium position

The dynamics of the spring mass system is dictated by Newton's laws ($F=m\ddot{y}$), Hookes law $F=ky$ and a damping force $F=b\dot{y}$. The state of the system is given by the second order differential equation \begin{align} m\ddot{y}-b \dot{y} -ky=u \end{align} where $u$ is the external force acting on the mass $m$. We can write the second order equation as a system of first order differential equations by calling \begin{align} x_1=y\\ x_2=\dot{y} \end{align} then the system reads \begin{align} \dot{x}_1&=\dot{y}=x_2\\ \dot{x}_2&=\frac{b \dot{y}}{m} +\frac{ky}{m}+\frac{u}{m}=\frac{b x_2}{m} +\frac{kx_1}{m}+\frac{u}{m} \end{align} in Matrix notation this is \begin{align} \begin{bmatrix} \dot{x}_1\\ \dot{x}_1\end{bmatrix} = \begin{bmatrix} 0 & 1 \\ \frac{k}{m} & \frac{b}{m}\end{bmatrix} \begin{bmatrix} x_1\\ x_2\end{bmatrix}+\begin{bmatrix} 0 \\ \frac{1}{m} \end{bmatrix}u \end{align} The output is given by the deviation of the mass $m$ from the equilibrium point, which is simply \begin{align} y(t)=\begin{bmatrix} 1 & 0\end{bmatrix}\begin{bmatrix} x_1\\ x_2\end{bmatrix} \end{align} We can read of the matrices determining the state and output equation directly \begin{align} \mathbf{A}= \begin{bmatrix} 0 & 1 \\ \frac{k}{m} & \frac{b}{m}\end{bmatrix} \end{align} \begin{align} \mathbf{B}= \begin{bmatrix} 0 \\ \frac{1}{m}\end{bmatrix} \end{align} \begin{align} \mathbf{C}= \begin{bmatrix} 1 & 0\end{bmatrix} \end{align} and $D=0$ \begin{align} \dot{\mathbf{x}}(t)&=\mathbf{A}\mathbf{x}(t)+\mathbf{B}\mathbf{u}(t)\\ \mathbf{y}(t)&=\mathbf{C}\mathbf{x}(t) \end{align} If the input is known the general solution for $\mathbf{x}(t)$ is given by \begin{align} \mathbf{x}(t)=\mathbf{x}_c(t)+ \mathbf{x}_p(t)=e^{\mathbf{A}t}\mathbf{x}_0 + e^{\mathbf{A}t} \int_0^t e^{- \mathbf{A}t} \, \mathbf{B} \, \mathbf{u}(t) \, dt \end{align} and we can calculate the output \begin{align} \mathbf{y}(t)&=\mathbf{C} \, e^{\mathbf{A}t}\mathbf{x}_0 + \mathbf{C} \, e^{\mathbf{A}t} \int_0^t e^{- \mathbf{A}t} \, \mathbf{B} \, \mathbf{u}(t) \, dt +\mathbf{D} \, \mathbf{u}(t) \end{align}