---
title: State-space models and their solution
heading: Writing plants as first-order matrix equations, the DC motor in state form, the matrix exponential and the solution with inputs, eigenvalues as poles and modes, transfer functions from state models, and changes of coordinates
eyebrow: S9 · Lesson 33 · State-space models and their solution
xp: 50
---

::: hook
Transfer functions describe one input and one output, and hide what's going on inside. A state-space model tracks every energy-storing quantity, every capacitor voltage, inductor current, position and velocity, as one vector that evolves by a matrix equation. It handles many inputs and outputs, it's how simulators and microcontrollers actually compute, and it opens the door to the second half of this course: placing every closed-loop pole at once, estimating states you can't measure, and optimal control.
:::

::: play
- The phase portrait of $\dot{x} = Ax$ for a 2 × 2 matrix A, with the trajectories from three starting points.
- The readouts give the trace and determinant of A. Its eigenvalues are the roots of $s^2 - (\text{tr}\,A)s + \det A$, so these two numbers decide the picture.
- Negative trace and positive determinant: stable. A negative discriminant ($\text{tr}^2 - 4\det$) makes the eigenvalues complex and the trajectories spiral; a negative determinant gives a saddle.
:::

```sim plot
view: flow
x: x1 = -3..3
y: x2 = -3..3
slider: a = -3..1 = 0
slider: b = -3..3 = 1
slider: c = -3..3 = -2
slider: d = -3..1 = -3
dx: a*x1 + b*x2
dy: c*x1 + d*x2
start: 2.5, 0
start: -1, 2.5
start: 0, -2.5
heads: on
readout: trace = a + d | digits: 3
readout: determinant = a*d - b*c | digits: 3
readout: discriminant = (a + d)^2 - 4*(a*d - b*c) | digits: 3
```

::: predict
## With the defaults, $A = \begin{pmatrix} 0 & 1 \\ -2 & -3 \end{pmatrix}$. What are its eigenvalues, and how do trajectories approach the origin?

- [ ] ±j√2: they circle forever
- [x] −1 and −2: they curve in without spiraling, ending along the slower mode's direction
- [ ] −1.5 ± j1.3: they spiral in
- [ ] +1 and −2: a saddle

::: reveal
$s^2 + 3s + 2 = (s + 1)(s + 2)$. Two real negative eigenvalues make a stable node. The $e^{-2t}$ mode dies first, so every trajectory ends up arriving along the eigenvector of −1, the line $x_2 = -x_1$.
:::
:::

::: nameit
## The model

$$\dot{x} = Ax + Bu, \qquad y = Cx + Du$$

with n states, m inputs and p outputs; A is n × n. An nth-order differential equation $y^{(n)} + a_{n-1}y^{(n-1)} + \dots + a_0y = b_0u$ becomes state form with $x = (y, \dot{y}, \dots)$:

$$A = \begin{pmatrix} 0 & 1 & & \\ & & \ddots & \\ -a_0 & -a_1 & \cdots & -a_{n-1} \end{pmatrix}, \quad B = \begin{pmatrix} 0 \\ \vdots \\ b_0 \end{pmatrix}$$

**The DC motor** with states (i, ω):

$$A = \begin{pmatrix} -R/L & -K_e/L \\ K_t/J & -b/J \end{pmatrix}, \quad B = \begin{pmatrix} 1/L \\ 0 \end{pmatrix}, \quad C = \begin{pmatrix} 0 & 1 \end{pmatrix}$$

## The solution

$$x(t) = e^{At}x(0) + \int_0^te^{A(t - \tau)}Bu(\tau)\,d\tau, \qquad e^{At} = I + At + \frac{(At)^2}{2!} + \dots$$

The eigenvalues $\lambda_k$ of A are the system's poles. If A has n independent eigenvectors $v_k$, then $e^{At} = \sum_k e^{\lambda_kt}v_kw_k^T$ (with $w_k$ the left eigenvectors), so every motion is a sum of **modes** $e^{\lambda_kt}v_k$.

## Transfer function

$$G(s) = C(sI - A)^{-1}B + D, \qquad G(0) = D - CA^{-1}B$$

The denominator is $\det(sI - A)$, the characteristic polynomial.

## Coordinates

With x = Tz, the model becomes $(T^{-1}AT, T^{-1}B, CT, D)$: different matrices, same eigenvalues and transfer function. Choosing T well gives the canonical forms used for design in lessons 34 and 37.
:::

::: example
## Write the motor of lesson 2 in state form and check its poles and DC gain.

::: solution
1. **Parameters.** R = 2 Ω, L = 0.5 mH, $K_t = K_e$ = 0.05, J = 2 × 10⁻⁵ and b = 10⁻⁵.
2. **State matrix.**
   $$A = \begin{pmatrix} -4000 & -100 \\ 2500 & -0.5 \end{pmatrix}$$
3. **Eigenvalues.** From the trace, −4000.5, and the determinant, 252,000:
   $$\lambda = -64.0,\ -3936\ \text{s}^{-1}$$
   as found from the transfer function.
4. **DC gain.**
   $$-CA^{-1}B = 19.84\ \text{rad/s per V}$$
   the DC gain from before.

**Answer:** the poles are at −64.0 and −3936 s⁻¹ and the DC gain is 19.84 rad/s per volt, both as found from the transfer function.
:::
:::

::: example
## Find $e^{At}$ for $A = \begin{pmatrix} 0 & 1 \\ -2 & -3 \end{pmatrix}$ and the motion from x(0) = (1, 0).

::: solution
1. **Form of each entry.** With eigenvalues −1 and −2, each entry is a combination of $e^{-t}$ and $e^{-2t}$.
2. **Fit the entries.** Fit them to $e^{A0} = I$ and its derivative A:
   $$\begin{aligned} (e^{At})_{11} &= 2e^{-t} - e^{-2t} \\ (e^{At})_{12} &= e^{-t} - e^{-2t} \\ (e^{At})_{21} &= -2e^{-t} + 2e^{-2t} \\ (e^{At})_{22} &= -e^{-t} + 2e^{-2t} \end{aligned}$$
3. **Motion from (1, 0).** The first column gives
   $$x_1(t) = 2e^{-t} - e^{-2t}$$
   which is 0.600 at t = 1, matching the power series to every digit.

**Answer:** each entry of $e^{At}$ mixes $e^{-t}$ and $e^{-2t}$ as in step 2, and from (1, 0) the motion is $x_1(t) = 2e^{-t} - e^{-2t}$, which is 0.600 at t = 1.
:::
:::

::: example
## Write a series RLC circuit (10 Ω, 1 mH, 1 µF) in state form with states i and $v_C$, and find its poles from the trace and determinant.

::: solution
1. **Circuit equations.**
   $$\begin{aligned} L\,di/dt &= v - Ri - v_C \\ C\,dv_C/dt &= i \end{aligned}$$
2. **State matrices.**
   $$\begin{aligned} A &= \begin{pmatrix} -R/L & -1/L \\ 1/C & 0 \end{pmatrix} \\ B &= \begin{pmatrix} 1/L \\ 0 \end{pmatrix} \end{aligned}$$
3. **Trace and determinant.**
   $$\begin{aligned} \operatorname{tr} A &= -R/L \\ &= -10^4 \\ \det A &= 1/(LC) \\ &= 10^9 \end{aligned}$$
4. **Natural frequency and damping.**
   $$\begin{aligned} \omega_n &= \sqrt{10^9} \\ &= 31\,600\ \text{rad/s} \\ \zeta &= \frac{10^4}{2 \times 31\,600} \\ &= 0.158 \end{aligned}$$
   matching $\frac{R}{2}\sqrt{C/L}$.

**Answer:** the trace −10⁴ and determinant 10⁹ give $\omega_n$ = 31,600 rad/s and ζ = 0.158.
:::
:::

::: check
given: a = -5 | -1; b = 1 | 2; c = 0.5 | 1.5; d = -4 | -2
answer: ((a + d) + sqrt((a + d)^2 - 4*(a*d - b*c)))/2
tolerance: 0.5%

## $A = \begin{pmatrix} \given{a} & \given{b} \\ \given{c} & \given{d} \end{pmatrix}$. What's its larger eigenvalue?

::: right
Right. $\frac{\text{tr} + \sqrt{\text{tr}^2 - 4\det}}{2}$ = {answer}.
:::

::: misses
- [((a + d) - sqrt((a + d)^2 - 4*(a*d - b*c)))/2] That's the other, more negative one.
- [any] Not yet. Roots of $s^2 - (\text{tr}A)s + \det A$.
:::
:::

::: check
given: t = -2 | -4 | -6; e = 10 | 25 | 50
answer: -t/(2*sqrt(e))
tolerance: 0.5%

## A 2 × 2 system matrix has trace {t} and determinant {e}. What's the damping ratio of its poles?

::: right
Right. $s^2 + 2\zeta\omega_ns + \omega_n^2$ with $\omega_n^2 = \det$ and $2\zeta\omega_n = -\text{tr}$: ζ = {answer}.
:::

::: misses
- [-t/sqrt(e)] $2\zeta\omega_n = -\text{tr}$, so divide by $2\omega_n$.
- [any] Not yet. Match the characteristic polynomial to the standard form.
:::
:::

::: check
given: p = 1 | 2; q = 3 | 5; t = 0.5 | 1 | 2
answer: (q*exp(-p*t) - p*exp(-q*t))/(q - p)
tolerance: 0.5%

## $A = \begin{pmatrix} 0 & 1 \\ -\given{p}\cdot\given{q} & -(\given{p} + \given{q}) \end{pmatrix}$ starts at x(0) = (1, 0). What's $x_1$ at t = {t}?

::: right
Right. $\frac{qe^{-pt} - pe^{-qt}}{q - p}$ = {answer}.
:::

::: misses
- [exp(-p*t)] Both modes are present; fit the combination to $x_1(0) = 1$ and $\dot{x}_1(0) = 0$.
- [any] Not yet. $x_1 = \alpha e^{-pt} + \beta e^{-qt}$ with $x_1(0) = 1$ and $\dot{x}_1(0) = 0$.
:::
:::

::: check
given: a = 2 | 6; c = 3 | 10; b = 1 | 5
answer: b/a
tolerance: 0.5%

## A companion-form model $\dot{x}_1 = x_2$, $\dot{x}_2 = -\given{a}x_1 - \given{c}x_2 + \given{b}u$, $y = x_1$. What's its DC gain?

::: right
Right. $G = b/(s^2 + cs + a)$, so G(0) = {answer}.
:::

::: misses
- [b/c] At DC the derivative terms vanish: $a\,y = b\,u$.
- [any] Not yet. $G(0) = -CA^{-1}B$.
:::
:::

::: check
given: a = 4 | 10; b = 1 | 2; k = 2 | 5; t = 0.2 | 1
answer: k*(exp(-b*t) - exp(-a*t))/(a - b)
tolerance: 0.5%

## $A = \begin{pmatrix} -\given{a} & \given{k} \\ 0 & -\given{b} \end{pmatrix}$ starts at x(0) = (0, 1). What's $x_1$ at t = {t}?

::: right
Right. $x_2 = e^{-bt}$ drives $x_1$: $x_1 = k\frac{e^{-bt} - e^{-at}}{a - b}$ = {answer}.
:::

::: misses
- [k*exp(-b*t)] $x_1$ starts at zero and has to build up through its own pole at −a.
- [any] Not yet. Solve $\dot{x}_1 = -ax_1 + ke^{-bt}$.
:::
:::

::: check
given: R = 1 | 3; L = 0.5 | 2; K = 0.03 | 0.08; J = 1e-5 | 5e-5
answer: (R/(L*1e-3))*(1e-5/J) + K^2/(L*1e-3*J)
tolerance: 0.5%

## A motor's state matrix has R = {R} Ω, L = {L} mH, $K_t = K_e$ = {K}, J = {J} kg·m² and b = 10⁻⁵ N·m·s. What's det A?

::: right
Right. $\frac{R}{L}\frac{b}{J} + \frac{K^2}{LJ}$ = {answer} s⁻²: the product of the two poles.
:::

::: misses
- [any] Not yet. det = $a_{11}a_{22} - a_{12}a_{21}$.
:::
:::

::: check
kind: parts
given: R = 5 | 20 | 100; L = 0.1 | 1 | 10; C = 0.1 | 1 | 10

## A series RLC circuit has R = {R} Ω, L = {L} mH and C = {C} µF, with states i and $v_C$.

::: part
answer: 1/sqrt(L*1e-3*C*1e-6)
unit: rad/s
tolerance: 0.5%

### What is $\omega_n$, the square root of the state matrix's determinant?

::: misses
- [any] $\det A = 1/(LC)$.
:::
:::

::: part
answer: R/2*sqrt(C*1e-6/(L*1e-3))
tolerance: 0.5%

### What is ζ, from the trace?

::: misses
- [any] $\zeta = -\text{tr}A/(2\omega_n) = \frac{R}{2}\sqrt{C/L}$.
:::
:::
:::

::: check
kind: derivation
vars: a = -10..-0.1, b = 0.1..10, c = -10..-0.1, d = -10..-0.1

## A system matrix $\begin{pmatrix} a & b \\ c & d \end{pmatrix}$.

::: step
answer: a + d

### What is its trace?
:::

::: step
answer: a*d - b*c

### Its determinant?
:::

::: step
answer: sqrt(a*d - b*c)

### Its poles' $\omega_n$?
:::

::: step
answer: -(a + d)/(2*sqrt(a*d - b*c))

### Their ζ?
:::

::: right
Right. For a 2 × 2 system the characteristic polynomial is $s^2 - (\text{tr}A)s + \det A$.
:::
:::

::: explain
## Why are the eigenvalues of A the same as the poles of the transfer function?

::: model
The transfer function is $C(sI - A)^{-1}B + D$, and the inverse of $sI - A$ is its adjugate divided by $\det(sI - A)$. The adjugate's entries are polynomials in s, so every pole of the transfer function is a root of $\det(sI - A)$, which is exactly the characteristic polynomial whose roots are the eigenvalues. In the other direction, each eigenvalue is the growth rate of a mode $e^{\lambda t}$ that the system follows on its own. The only way an eigenvalue can be missing from the transfer function is if its mode can't be excited by the input or can't be seen at the output, which is what controllability and observability (lessons 34 and 37) are about.
:::
:::

::: practice

::: check
given: t = -3 | -8; e = 4 | 40
answer: -t/(2*sqrt(e))
tolerance: 0.5%

## Damping ratio for trace {t}, determinant {e}?

::: misses
- [any] $-\text{tr}/(2\sqrt{\det})$.
:::
:::

::: check
given: p = 0.5 | 3; q = 4 | 8; t = 0.3 | 1.5
answer: (q*exp(-p*t) - p*exp(-q*t))/(q - p)
tolerance: 0.5%

## $x_1(\given{t})$ from (1, 0) with poles −{p}, −{q} in companion form?

::: misses
- [any] $\frac{qe^{-pt} - pe^{-qt}}{q - p}$.
:::
:::

::: check
given: a = 3 | 12; c = 2 | 7; b = 2 | 9
answer: b/a
tolerance: 0.5%

## DC gain of $\ddot{y} + \given{c}\dot{y} + \given{a}y = \given{b}u$?

::: misses
- [any] b/a.
:::
:::
:::
