State space models
What is a state space model?
A state-space model is a set of ordinary differential equations that can be written in this form:
There are two variables:
is the state is the input
Both variables are functions of time, so we could have written
The state and input may have more than one element — that is to say, they may be vectors (represented by a matrix of numbers) and not scalars (represented by a single number). Suppose, in particular, that:
- the state
has elements - the input
has elements
Then, we would represent them as column matrices:
Taking the time derivative of a matrix is equivalent to taking the time derivative of each element of that matrix, so we would write
The state-space model also has two constants:
is a constant matrix of size is a constant matrix of size
The state space model has two key properties:
- it is linear because both
is a linear function of and - it is time-invariant because
and are constant
How do I put a system in state space form?
Suppose we are given a description of a dynamic system. We would like to describe this same system with a state space model.
Remember that every state space model is linear. The equations of motion that describe a dynamic system are often nonlinear. So apparently, we will have to accept that state space models can only approximate some of the systems we want to describe.
We will use linearization to arrive at this approximation, in four steps.
Step 1. Rewrite the system as a set of first-order ordinary differential equations:
In this expression, the variables
Step 2. Find an equilibrium point
A solution to this equation is called an equilibrium point because if
then
and so
This equation may have no solutions, in which case no equilibrium point exists for the system. This is bad. We will ignore this situation for now.
This equation also may have many solutions, in which case you have to make a choice. A good choice is whatever equilibrium point you would like your system to achieve.
Step 3. Define the state and input as follows:
Note that
Step 4. Compute
Why does this make any sense? Look again at the ODEs that describe the original system:
First, because
then
So the left-hand side of the ODEs can simply be replaced with
Now, suppose we want a linear approximation to the right-hand side of the ODEs — the function
There you have it: “
Example (first-order)
Consider the system with dynamics that are described by the following equation of motion:
Let’s apply our method to put this system in state space form.
We begin by rewriting it as a set of first-order ODEs. Lucky us, the system is already described by just one first-order ODE, so all we need to do is solve for
Next, we find an equilibrium point by solving
In this case, there are many solutions. Suppose we pick this one:
Then, we define the state and input based on this choice of equilibrium point:
Finally, we compute
The resulting state space model is
Note that the original system was linear, so there was no approximation here. We could probably have skipped most of these steps and written the system in state-space form by inspection. On the other hand, it is nice to know that the process of “linearization” still works even in this simple case.
Example (second-order)
Consider the system with dynamics that are described by the following equation of motion:
Let’s apply our method to put this system in state-space form.
We begin by rewriting it as a set of first-order ODEs:
- We find the time-derivative of
with highest order — in this case, , of order 2. - We define new variables for each time-derivative of
with lower order — in this case, , the only time-derivative with order between 0 and 2. We might choose the following name for this time-derivative:
- We rewrite the original ODEs (in this case, just one) in terms of these new variables:
- We add one extra ODE for each new variable (in this case, just one extra) — this is trivial, coming from the way we defined these new variables:
- We collect the original ODEs and the extra ODEs together, if necessary solving for all of the time-derivatives (that’s not necessary here):
- Finally, we rewrite our result in the form
by collecting things in column matrices as follows:
Note that, as desired, these rewritten ODEs have time derivatives that are at most of first order. Also note that all of these time-derivatives are on the left-hand side of the equations — none appear on the right-hand side.
Next, we find an equilibrium point by solving
There are many solutions. Suppose we pick this one:
In this case, there are many solutions. Suppose we pick this one:
Then, we define the state and input based on this choice of equilibrium point:
Finally, we compute
The resulting state space model is
The original system was nonlinear and the state space model is linear, so there must be some approximation here! As we will see, this approximation is good near the equilibrium point but can be very bad elsewhere.