Skip to content
Tactiverge

School/□ Systems Engineer/Week 11

From one second-order equation to two first-order ones

Computers can only take small steps forward. How do you step forward an equation that talks about acceleration?

About 35 min · 3 goals · Checked by automated tests

1.Why should I care?

Every serious simulation tool, flight controller and robotics library works with first-order state equations. Learning this one rewrite lets you simulate almost anything with the same few lines of code.

  • ◇ Rewrite an nth-order differential equation as n first-order equations in state variables.
  • ◇ Write a linear system in the form dx/dt = A·x + B·u and identify A and B.
  • ◇ Relate the eigenvalues of A to growth, decay and oscillation (preview).

2.Predict

For m = 1, c = 0, k = 4, what will the phase-plane path look like?

Guess first. Being wrong here is how the surprise works.

3.Discover

Set c = 0 and k = 4 and check the eigenvalues read 0 ± 2j. Now raise c slowly. Find the value of c where the eigenvalues stop having an imaginary part, and check it against c = 2√(km).

Loading the interactive…

Can't use the interactive? Read a description instead

With damping c = 0 and stiffness 4, the phase-plane path is a closed ellipse and the eigenvalues are 0 ± 2j. As c increases the path becomes an inward spiral and the eigenvalues get a negative real part. At c = 4 (twice the square root of k times m) the imaginary part vanishes and the path slides into the origin without circling.

4.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

In A = [[0, 1], [−k/m, −c/m]], what does the entry −c/m in the bottom-right mean?

5.Understand

Any order, first-order steps

An nth-order equation needs n initial conditions, so it has n states. Define x₁ = y, x₂ = ẏ, …, xₙ = y⁽ⁿ⁻¹⁾. Each state's derivative is the next state, except the last, which comes from the original equation.

The A and B matrices

For linear systems the right-hand sides are weighted sums, so they fit in matrices: dx/dt = A·x + B·u. A says how the states push on each other; B says how the input pushes on each state. The same code steps any system once you supply A and B.

Eigenvalues preview

Each eigenvalue λ of A gives a mode that behaves like e^(λt). Negative real part: decays. Positive: grows. Imaginary part: oscillates. You will use this in week 15; for now, notice that the phase-plane readout's eigenvalues change exactly when the picture changes shape.

Explain it another way

A second-order equation is like a staircase you can't step up in one go. Introducing velocity as a state adds a landing halfway, so each step is a small first-order one.

Derivation: Mass–spring–damper in state-space form
  1. Start from Newton's second law for a mass on a spring with a damper: m·ẍ = F − c·ẋ − k·x.

  2. Choose states x₁ = x (position) and x₂ = ẋ (velocity). Then ẋ₁ = x₂ by definition.

  3. Divide Newton's law by m: ẋ₂ = ẍ = −(k/m)·x₁ − (c/m)·x₂ + F/m.

  4. Stack them: d/dt [x₁; x₂] = [[0, 1], [−k/m, −c/m]]·[x₁; x₂] + [0; 1/m]·F. That is dx/dt = A·x + B·u with u = F.

  5. The eigenvalues of A solve λ² + (c/m)·λ + k/m = 0, the same characteristic equation as the original ODE: λ = −ζωn ± ωn√(ζ² − 1).

Worked example 1

Write L·di/dt + R·i + q/C = V(t) with q the capacitor charge (i = dq/dt) in state-space form.

States x₁ = q, x₂ = i. Then ẋ₁ = x₂ and ẋ₂ = (V − R·x₂ − x₁/C)/L. So A = [[0, 1], [−1/(LC), −R/L]], B = [0; 1/L]. It has the same shape as the mass–spring–damper with m ↔ L, c ↔ R, k ↔ 1/C.

Common mix-ups

  • State-space form is a different model from the differential equation.
    ✓ It is the same model written differently. The characteristic polynomial, and so the behaviour, is identical.

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2

For m = 2 kg and k = 50 N/m, at what damping c (N·s/m) do the eigenvalues become real (critical damping)?

N·s/m

Practice 3

How many states does d³y/dt³ + 2ÿ + 3ẏ + y = u need?

Practice 4

In the mass–spring–damper, why is B = [0; 1/m]?

Practice 5 · a fresh version every time

A mass–spring–damper has m = 10 kg, c = 12.6 N·s/m and k = 400 N/m. What is its damping ratio ζ? (No unit.)

7.Apply it

Write the state-space form of a DC motor with states speed ω and current i: J·dω/dt = kₜ·i − b·ω and L·di/dt = V − R·i − kₑ·ω. Identify A and B and say which entry couples the electrical and mechanical parts.

8.Reflect

Concepts: States and state-space models · Eigenvalues and the stability of dynamic systems