3 The Euler-Lagrange Equations

3.1 Theory

In this chapter we show how to define the potential energy for simple mechanical systems and how to define the generalized forces. The Euler-Lagrange equations given in Equation 1.8 can then be used to derive the equations of motion for the system.

3.1.1 Potential Energy

In this book we will be concerned with two sources of potential energy: potential energy due to gravity and potential energy due to springs.

The potential energy of a unit mass m in gravity is given by P=mgy.

Consider a point mass \(m\) in a gravity field that is at position \(y\) as shown in Fig. 3.1. The potential energy is given by \[P = mgy + P_0,\] where \(P_0\) is the potential energy when \(y=0\). Typically, we desire an expression for potential energy that is zero when the configuration variables are zero.

The second source of potential energy is from translational and rotational springs.

A spring stretched by distance z stores potential energy.

The spring shown in Fig. 3.2 is stretched from rest by a distance of \(z\). The potential energy of a linear stretched/compressed spring is given by \[P = \frac{1}{2}k z^2,\] where \(k\) is the spring constant. Similarly, for a rotational spring, the potential energy is given by \(P=\frac{1}{2}k \theta^2\), where \(\theta\) is the rotational angle and \(\theta=0\) is the angle at which the rotational spring is at rest.

3.1.2 Generalized Coordinates and Generalized Forces

The generalized coordinates are the minimum set of configuration variables. For example, for the mass-spring-damper system shown in Fig. 2.6, the generalized coordinates are \(\mathbf{q}=(z_1, z_2)^\top\). For the single-link robot arm shown in Fig. 2.8, the generalized coordinate is \(\mathbf{q}=\theta\). For the spinning dumbbell system shown in Fig. 2.7, and the pendulum on a cart system shown in Fig. 2.9, the generalized coordinates are \(\mathbf{q}=(z, \theta)^\top\). Finally, for the satellite system shown in Fig. 1.4, the generalized coordinates are \(\mathbf{q}=(\theta,\phi)^\top\).

The generalized forces are the nonconservative forces and torques acting along each generalized coordinate. In other words, they are the applied forces and torques on the system. For example, for the mass-spring-damper system shown in Fig. 2.6, the generalized force acting along \(z_1\) is zero and the generalized force acting along \(z_2\) is the applied force \(F\). Therefore, the generalized force is \(\boldsymbol{\tau} = (0, F)^\top\).

3.1.3 Damping Forces and Torques

Friction and applied dampers also exert forces on the system. Damping forces are externally applied forces that are proportional to the velocity or angular velocity of the system. For example, in the mass-spring-damper system shown in Fig. 2.6, the damping force acting along \(z_1\) is due to the first damper and the damper between the two masses and is given by \(-b_1\dot{z}_1-b_2(\dot{z}_1-\dot{z}_2)\). The damping acting along \(z_2\) is given by \(-b_2(\dot{z}_2-\dot{z}_1)\). Therefore, the damping force on the system is given by \[-B\dot{\mathbf{q}} = -\begin{pmatrix} b_1+b_2 & -b_2 \\ -b_2 & b_2 \end{pmatrix} \begin{pmatrix} \dot{z}_1 \\ \dot{z}_2 \end{pmatrix} = \begin{pmatrix} -b_1\dot{z}_1-b_2(\dot{z}_1-\dot{z}_2) \\ -b_2(\dot{z}_2-\dot{z}_1) \end{pmatrix}.\]

3.1.4 Euler-Lagrange Equations

The equations of motion are given by the Euler-Lagrange equations. Let the Lagrangian be given by \[L(\mathbf{q},\dot{\mathbf{q}}) = K(\mathbf{q},\dot{\mathbf{q}}) - P(\mathbf{q}),\] where \(K(\mathbf{q},\dot{\mathbf{q}})\) is the kinetic energy of the system and is, in general, a function of the generalized coordinates and the generalized velocities, and \(P(\mathbf{q})\) is the potential energy which is, in general, a function of the generalized coordinates. As shown in Equation 1.8 the Euler-Lagrange equations are given in vector form as \[\frac{d}{dt}\left(\frac{\partial L(\mathbf{q},\dot{\mathbf{q}})}{\partial \dot{\mathbf{q}}}\right) - \frac{\partial L(\mathbf{q},\dot{\mathbf{q}})}{\partial \mathbf{q}} = \boldsymbol{\tau}-B \dot{\mathbf{q}}.\]

3.2.1 image Example Problem 3.1.6

Find the potential energy for the system.

Define the generalized coordinates.

Find the generalized forces and damping forces.

Derive the equations of motion using the Euler-Lagrange equations.

Referring to Appendices P.1, P.2, and P.3, write a class or s-function that implements the equations of motion. Simulate the system using a variable torque input. The output should connect to the animation function developed in homework A.2.

Design Study A guided exercise

Build the arm equation of motion

Use the kinetic energy from Chapter 2 and gravity potential energy for the center of mass.

Single link robot arm geometry for potential energy.

Use this geometry to relate the center-of-mass height to \(\theta\) before applying Euler-Lagrange.

Step 1. Potential energy

Step 2. Generalized coordinate and force

Step 3. Equation of motion

Enter the multiplier on \(\ddot{\theta}\) in the final equation.

Pseudocode

The complete solution includes a dynamics class and a simulation script. Before opening it, outline each component separately.

These prompts are ungraded. They are intended to connect the Euler-Lagrange equation to the implementation code in the complete solution.

3.3 Design Study B. Inverted Pendulum

3.3.1 image Example Problem 3.2.6

Find the potential energy for the system.

Define the generalized coordinates.

Find the generalized forces and damping forces.

Derive the equations of motion using the Euler-Lagrange equations.

Referring to Appendices P.1, P.2, and P.3, write a class for s-function that implements the equations of motion. Simulate the system using a variable force on the cart as an input. The output should connect to the animation function developed in homework B.2.

Design Study B guided exercise

Assemble the pendulum equations of motion

Use energy, generalized coordinates, and generalized forces to form the coupled nonlinear equations.

Pendulum on
a cart definition figure.

Use this setup to connect gravity, force, cart motion, and pendulum angle before applying Euler-Lagrange.

Step 1. Potential energy

Step 2. Generalized coordinates

Step 3. Coupled dynamics structure

Pseudocode

The complete solution includes a dynamics class and a simulation script. Before opening it, outline each component separately.

These prompts are ungraded. They are intended to connect the derivation to the implementation code in the complete solution.

3.4 Design Study C. Satellite Attitude Control

3.4.1 image Example Problem 3.3.6

Find the potential energy for the system.

Define the generalized coordinates.

Find the generalized forces and damping forces.

Derive the equations of motion using the Euler-Lagrange equations.

Referring to Appendices P.1, P.2, and P.3, write a class or s-function that implements the equations of motion. Simulate the system using a variable torque on the body as an input. The output should connect to the animation function developed in homework C.2.

Design Study C guided exercise

Assemble the satellite equations of motion

Use the torsional spring, relative damping, body torque, and two angular coordinates to form the coupled satellite-panel equations.

Satellite
with flexible solar panels.

The spring and damper act on relative motion between the body and panel, while the actuator torque is applied only to the body.

Step 1. Potential energy

Step 2. Generalized coordinates and input

Step 3. Relative damping

Step 4. Coupled equation structure

Pseudocode

The complete solution includes dynamics code. Before opening it, outline how the code should compute \(\ddot{\theta}\) and \(\ddot{\phi}\) from state and torque.

This prompt is ungraded. It connects the Euler-Lagrange equations to the implementation code in the complete solution.

3.5 Interactive Euler-Lagrange Check

Chapter 3 activity

From energy to Lagrangian terms

Use a one-coordinate mass-spring example to connect kinetic energy, potential energy, the Lagrangian L = K - P, and the spring force term.

q q . k m
Figure 1.2. A one-coordinate mass-spring system with generalized coordinate q and generalized velocity q.

Live equations

P(q) = ½ k q2 = ½()()2 = J

K(q) = ½ m q2 = ½()()2 = J

L(q,q) = K - P = J

dP⁄dq = k q = N

3.6 Knowledge Check

Q1. Lagrangian definition

The Lagrangian is:

Q2. Generalized coordinates

Generalized coordinates should be:

Q3. Spring potential

For k = 4 and displacement q = 2, enter the potential energy P.

Show solution

Answer: 8 because P = ½kq2 = ½(4)(22) = 8.

Q4. Potential derivative

For P = ½kq2, with k = 3 and q = 2, enter dP⁄dq.

Show solution

Answer: 6 because dP⁄dq = kq = (3)(2).

Q5. Toy system: warehouse cart and flywheel

Consider the warehouse cart and flywheel system from Chapter 2 Q5. The cart translates horizontally, and the flywheel rotates relative to the cart. For this Chapter 3 version, assume the cart is attached to a linear spring with displacement z from its relaxed position, and the flywheel is attached to a torsional spring with angle θ from its relaxed angle. Which potential energy expression is correct?




Q6. Toy system: puck and rotor

Consider the puck-and-rotor system from Chapter 2 Q6. The puck slides along a horizontal surface, and the rotor spins on top of the puck. To describe the configuration, use x for the puck's horizontal position and θ for the rotor's angular position. Which set is the best choice of generalized coordinates?

Q7. Toy system: Lagrangian form

For either toy system with translation and rotation, which Lagrangian form is correct?

Q8. Coordinate choice

A slider moves horizontally while a rigid link rotates relative to the slider. Which generalized coordinates are most appropriate?

Q9. Potential energy structure

A point mass has height y and stretches a spring by x from its relaxed length. Which potential-energy structure is correct?

Q10. Generalized force

For q = (θ, x), a positive torque τ is applied directly in the positive θ direction and no direct force is applied in x. What generalized-force vector is consistent with this description?

Q11. Euler-Lagrange term

Which term most directly comes from d/dt(partial L / partial qdot) in a one-coordinate mass-spring model?

Q12. Coupled motion

Why can products such as xdot times thetadot appear in Euler-Lagrange equations for a multi-coordinate mechanical system?

3.7 Notes and References

Derivations of the Euler-Lagrange equations can be found in many sources, including [1, 2]. A simple derivation using only calculus can be found in [3].