ME3120 · Dynamic Modelling
Theme 3 · Energy / Lagrange

Coupled 2-DOF systems

Two coordinates, one recipe. Apply Lagrange twice and the equations stack into a mass matrix — your first look at the shape of the robot equation.

Source: course notes, Week 2 worked example C.

Before you start

What you need first

  • Lagrange's equation, applied once per coordinate (Topic 12).
  • Spring potential energy \(\tfrac12 kx^2\), including a spring between two moving masses.

What you'll be able to do

  • Write \(T\) and \(V\) for a two-mass system.
  • Get two coupled equations and stack them into matrices.
  • Read the mass matrix \(M\), stiffness \(K\), and the coupling.

The recipe does not change

The real power of Lagrange shows up with more than one degree of freedom. Nothing new is needed — you simply apply the master formula once for each coordinate, giving one equation per coordinate.

🔭 Looking ahead: a 2-link robot arm also has two coordinates. Here we use a simpler two-mass system so the algebra stays clean — but the shape of the answer is the same.

Step 1 · the picture

Two masses, two springs

k₁ m₁ k₂ m₂ x₁ x₂
Wall — spring \(k_1\) — mass \(m_1\) — spring \(k_2\) — mass \(m_2\), on a frictionless line. Coordinates \(x_1,x_2\) from each block's rest position.
Two degrees of freedom → two coordinates \(x_1,x_2\) → we will get two equations of motion.

Step 2 · the energies

Kinetic and potential energy

1Kinetic energy — the two blocks move independently:
$$T = \tfrac12 m_1\dot x_1^{2} + \tfrac12 m_2\dot x_2^{2}$$
2Potential energy — spring \(k_1\) stretches by \(x_1\); spring \(k_2\) stretches by the difference \((x_2-x_1)\):
$$V = \tfrac12 k_1 x_1^{2} + \tfrac12 k_2 (x_2-x_1)^{2}$$
The key modelling step is \(k_2\)'s stretch: the middle spring feels the relative motion \((x_2-x_1)\), not \(x_2\) alone. That difference is what ties the two masses together.

Step 3 · Lagrange for \(x_1\)

First equation (coordinate \(x_1\))

1Momentum term:
$$\frac{\partial \mathcal{L}}{\partial \dot x_1}=m_1\dot x_1 \;\Longrightarrow\; \frac{d}{dt}(m_1\dot x_1)=m_1\ddot x_1$$
2Position term (chain rule on \((x_2-x_1)^2\) gives a \(+\) sign):
$$\frac{\partial \mathcal{L}}{\partial x_1}=-k_1 x_1 + k_2 (x_2-x_1)$$
3Assemble \(m_1\ddot x_1 - \partial\mathcal{L}/\partial x_1 = 0\):
$$m_1\ddot x_1 + (k_1+k_2)x_1 - k_2 x_2 = 0$$

Step 4 · Lagrange for \(x_2\)

Second equation (coordinate \(x_2\))

1Momentum term:
$$\frac{\partial \mathcal{L}}{\partial \dot x_2}=m_2\dot x_2 \;\Longrightarrow\; \frac{d}{dt}(m_2\dot x_2)=m_2\ddot x_2$$
2Position term (only \(k_2\)'s spring depends on \(x_2\)):
$$\frac{\partial \mathcal{L}}{\partial x_2}=-k_2 (x_2-x_1)$$
3Assemble:
$$m_2\ddot x_2 + k_2 x_2 - k_2 x_1 = 0$$

Step 5 · stack them

Stack into matrices: \(M\) and \(K\)

$$\underbrace{\begin{bmatrix} m_1 & 0 \\ 0 & m_2 \end{bmatrix}}_{M}\begin{bmatrix}\ddot x_1 \\ \ddot x_2\end{bmatrix} + \underbrace{\begin{bmatrix} k_1+k_2 & -k_2 \\ -k_2 & k_2 \end{bmatrix}}_{K}\begin{bmatrix}x_1 \\ x_2\end{bmatrix} = \begin{bmatrix}0\\0\end{bmatrix}$$

In short, \(M\ddot{\mathbf{x}} + K\mathbf{x} = \mathbf 0\): a mass matrix \(M\) and a stiffness matrix \(K\).

The off-diagonal \(-k_2\) is the coupling — it is what ties \(x_1\) and \(x_2\) together. If \(k_2=0\) the masses uncouple into two separate springs. Coupling lives off the diagonal.
📄 Full line-by-line derivation (printable PDF) — every partial derivative and algebra step, with the setup figure. A pen-and-paper companion; the page above is already complete on its own.

Why this matters for robots

The robot equation has the very same shape — a mass matrix, plus extra terms:

$$M(q)\,\ddot q + C(q,\dot q)\,\dot q + G(q) = \tau$$
Today's 2-mass systemRobot arm
\(M\) (constant)\(M(q)\) — depends on the pose
\(K\mathbf{x}\) (springs)\(G(q)\) — gravity on the links
\(C(q,\dot q)\dot q\) — Coriolis, from moving fast
🔭 Every one of these comes straight out of Lagrange's equation. You now have the engine; Themes 4–5 build the pieces \(M(q)\), \(C\), and \(G\) for a real arm.
📐 Worked example

Write \(M\) and \(K\) for real numbers

Take \(m_1 = 2\ \text{kg}\), \(m_2 = 1\ \text{kg}\), \(k_1 = 100\ \text{N/m}\), \(k_2 = 50\ \text{N/m}\). Write the mass and stiffness matrices and the two equations.

1Mass matrix (the masses on the diagonal):
$$M=\begin{bmatrix} 2 & 0 \\ 0 & 1 \end{bmatrix}\ \text{kg}$$
2Stiffness matrix (\(k_1+k_2=150\) top-left, \(-k_2=-50\) off-diagonal, \(k_2=50\) bottom-right):
$$K=\begin{bmatrix} 150 & -50 \\ -50 & 50 \end{bmatrix}\ \text{N/m}$$
3The two equations of motion:
$$2\ddot x_1 + 150 x_1 - 50 x_2 = 0, \qquad \ddot x_2 + 50 x_2 - 50 x_1 = 0$$
Read the coupling: the \(-50\) terms are how each mass feels the other through the middle spring \(k_2\).

✏️ Try it yourself

For the same chain with \(m_1 = m_2 = 3\ \text{kg}\) and \(k_1 = k_2 = 200\ \text{N/m}\), write the mass matrix \(M\) and stiffness matrix \(K\).

Mass matrix. \(M=\begin{bmatrix} 3 & 0 \\ 0 & 3 \end{bmatrix}\ \text{kg}\) Stiffness matrix. \(K=\begin{bmatrix} k_1+k_2 & -k_2 \\ -k_2 & k_2 \end{bmatrix}=\begin{bmatrix} 400 & -200 \\ -200 & 200 \end{bmatrix}\ \text{N/m}\) Coupling. The off-diagonal \(-200\) ties the two masses together through the middle spring.

Common mistakes to avoid

MistakeFix
Writing \(k_2\)'s energy as \(\tfrac12 k_2 x_2^2\)The middle spring stretches by the difference: \(\tfrac12 k_2 (x_2-x_1)^2\).
Applying Lagrange only onceTwo coordinates → apply it twice, once for \(x_1\) and once for \(x_2\).
Sign slip on the coupling termDifferentiating \((x_2-x_1)^2\) by \(x_1\) gives \(-2(x_2-x_1)\); track the signs carefully.
Putting coupling on the diagonalCoupling lives off the diagonal (\(-k_2\)); the diagonal holds each coordinate's own stiffness.

Recap — the whole topic on one screen

$$M\ddot{\mathbf{x}} + K\mathbf{x} = \mathbf 0, \qquad M=\begin{bmatrix} m_1 & 0 \\ 0 & m_2 \end{bmatrix},\quad K=\begin{bmatrix} k_1+k_2 & -k_2 \\ -k_2 & k_2 \end{bmatrix}$$
IdeaWhat you own now
Two coordinatesApply Lagrange once per coordinate → two equations
The couplingMiddle spring feels \((x_2-x_1)\); appears off-diagonal
Matrix form\(M\ddot{\mathbf x}+K\mathbf x=\mathbf 0\) — mass & stiffness matrices
Robot linkSame shape as \(M(q)\ddot q + C\dot q + G(q)=\tau\)

Next theme

Frames & the rotation matrix

To write \(T\) and \(V\) for a real arm, we first need to say exactly where each link is. Theme 4 — robot geometry — starts with frames and the rotation matrix \(R(\theta)\), the language for describing position in space.

→ Frames & the rotation matrix