The model
A 1 kg cart on a spring and a damper, pushed by a force u. Its state x is two numbers: position x₁ and velocity x₂. The state-space model is ẋ = Ax + Bu and y = Cx + Du.
Newton's law gives ẋ₂ = −2x₁ − 3x₂ + u. So A = [0 1; −2 −3] holds the spring and damper, B = [0; 1] says the force changes velocity, and C = [1 0] picks position as y. D = 0.
To a transfer function
A transfer function lives in the Laplace domain. There, integrating a signal divides it by s, so each integrator becomes a 1/s block. With the cart starting at rest, ẋ = Ax + Bu becomes sX(s) = AX(s) + BU(s).
Move AX to the left: sX − AX = BU. To factor out X, write s as sI, the identity matrix times s: (sI − A)X = BU. Multiply by the inverse: X = (sI − A)⁻¹BU.
Here sI − A = [s −1; 2 s+3]. Inverting a 2×2 matrix divides by its determinant: s(s + 3) − (−1)(2) = s² + 3s + 2. That polynomial becomes the bottom of the transfer function.
B = [0; 1] picks the second column of the inverse: (1, s) over s² + 3s + 2. C = [1 0] keeps the first entry. So G(s) = Y(s)/U(s) = C(sI − A)⁻¹B + D = 1/(s² + 3s + 2).
s² + 3s + 2 = (s + 1)(s + 2), so G(s) has poles at −1 and −2. Those are exactly the eigenvalues of A: det(sI − A) = 0 is the eigenvalue equation. Same numbers, two names.
Push with a steady 1 N. Stepping ẋ = Ax + Bu in 1 ms steps, and the exact step response of G(s), 0.5 − e⁻ᵗ + 0.5e⁻²ᵗ, agree to within 0.10 mm. The cart settles at 0.5 m.
And back
Going back, write G(s) = (b₁s + b₀)/(s² + a₁s + a₀). The controllable canonical form puts −a₀ and −a₁ in the bottom row of A, sets B = [0; 1] and C = [b₀ b₁]. Our round trip lands where it started.
Choose new states z = T⁻¹x, two mixes of position and velocity. Now A = [−1 0; 0 −2], B = [1; −1], C = [1 1]. Different matrices, same G(s), same response. G(s) never says which states you chose.
For any 2×2 model the denominator is s² − (trace of A)s + det A. Our trace is −3 and det A is 2, so both models give s² + 3s + 2. In practice python-control does the general case with ss2tf and tf2ss.
What is happening
# step 1/11 · model # about: Force u, B matrix, ẋ = Ax + Bu, Integrators: state, A matrix, C matrix, Output y m = 1 kg, k = 2 N/m, b = 3 N·s/m state x = (x₁, x₂) = (position, velocity) input u = force (N) output y = position (m) ẋ = A x + B u how the state changes y = C x + D u what we measure Each integrator turns ẋ back into x, so the state is what the integrators hold.
The cart's numbers (1 kg, 2 N/m, 3 N·s/m) are illustrative, chosen so the poles are whole numbers. Every curve and number in the figure is computed from the model. The Python is plain Python 3 with no libraries. python-control's ss2tf(A, B, C, D) and tf2ss(num, den) do the same for any size; tf2ss may return a different, equally valid set of matrices.