Solved reference notebook. See 06_ContinuousSystems_RodsAndBeams_Exercises.ipynb for the
blanked-out version.
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
from scipy.optimize import brentq, fsolve
plt.rcParams["figure.figsize"] = (7, 4.2)
plt.rcParams["axes.grid"] = True6.1 Rods — longitudinal vibration¶

Summing forces on an infinitesimal element of a rod of varying cross-section :
For constant , this is the classical 1-D wave equation:
( is the speed of propagation of the stress wave along the rod.)
Exercise (handwritten) — separation of variables¶
🟥 Writing and substituting:
giving two ODEs: , and , , .
Fixed-free rod (, free end ): , so ; the free-end condition gives , i.e.
c, L = 1.0, 1.0 # non-dimensional speed and length for clarity
n_modes = 3
beta_n = np.array([(2 * n - 1) * np.pi / 2 / L for n in range(1, n_modes + 1)])
omega_n = beta_n * c
x = np.linspace(0, L, 300)
fig, ax = plt.subplots()
for n in range(n_modes):
g = np.sin(beta_n[n] * x)
ax.plot(x, g / np.max(np.abs(g)), label=rf"mode {n+1}, $\beta_{{{n+1}}}L={beta_n[n]*L:.3f}$")
ax.axhline(0, color="k", lw=0.6)
ax.set_xlabel("x / L")
ax.set_ylabel("Normalized mode shape g(x)")
ax.set_title("Fixed-free rod: first 3 longitudinal mode shapes")
ax.legend()
plt.show()
print("beta_n * L :", beta_n * L)
print("omega_n / c:", omega_n / c)
beta_n * L : [1.57079633 4.71238898 7.85398163]
omega_n / c: [1.57079633 4.71238898 7.85398163]
6.2 Beams — Euler-Bernoulli theory¶

The Euler-Bernoulli beam equation is
For free, undamped vibration with constant and :
Assuming and substituting gives , , with general solution
Clamped-free (cantilever) beam¶

BCs: , , (no moment at the free tip), (no shear). Applying conditions collapses the general solution to
and the conditions give a homogeneous system in ; a non-trivial solution requires its determinant to vanish, which reduces (see e.g. Inman, Rao, or Blevins) to the characteristic equation
Exercise “Characteristic.m” — solving the characteristic equation¶
🟩 Two ways to solve : visually (plot against
and read off the crossings) or numerically (scipy.optimize.brentq, the
Python equivalent of MATLAB’s fzero).
betaL = np.linspace(0, 10, 2000)
fig, ax = plt.subplots()
ax.plot(betaL, np.cos(betaL), label=r"$\cos(\beta L)$")
ax.plot(betaL, -1 / np.cosh(betaL), label=r"$-1/\cosh(\beta L)$")
def char_eq(bl):
return np.cos(bl) * np.cosh(bl) + 1
roots = []
for lo, hi in [(1, 3), (4, 5), (7, 8)]:
r = brentq(char_eq, lo, hi)
roots.append(r)
ax.stem([r], [np.cos(r)], linefmt="r-", markerfmt="ro", basefmt=" ")
ax.set_xlabel(r"$\beta L$")
ax.set_ylabel("Solving visually the characteristic equation")
ax.legend()
plt.show()
print("betaL roots:", np.round(roots, 4), " (textbook: 1.8751, 4.6941, 7.8548)")
betaL roots: [1.8751 4.6941 7.8548] (textbook: 1.8751, 4.6941, 7.8548)
Exercise “EX9” — mode shapes for a real cantilever¶
Geometric/material properties: , ,mm, ,mm, ,mm, ,N/m (an aluminium ruler).
rho, L_beam, b, t_beam, E = 2750.0, 0.340, 0.022, 0.002, 7e10
A = b * t_beam
I = b * t_beam**3 / 12
m = rho * A
betaL_roots = np.array(roots)
beta = betaL_roots / L_beam
omega = beta**2 * np.sqrt(E * I / m)
print("Natural frequencies (rad/s):", np.round(omega, 1))
print("(textbook: 88.6, 555.2, 1554.7 rad/s)")
def W_mode(x, beta, L):
"""Normalized (unit tip-shape) clamped-free eigenfunction, up to an arbitrary amplitude."""
bl = beta * L
sigma = (np.sinh(bl) - np.sin(bl)) / (np.cosh(bl) + np.cos(bl))
return (np.cosh(beta * x) - np.cos(beta * x)) - sigma * (np.sinh(beta * x) - np.sin(beta * x))
x = np.linspace(0, L_beam, 300)
fig, ax = plt.subplots()
for i, b_i in enumerate(beta):
W = W_mode(x, b_i, L_beam)
W = W / np.max(np.abs(W))
ax.plot(x * 1000, W, label=rf"mode {i+1}, $f_{i+1}={omega[i]/2/np.pi:.1f}$ Hz")
ax.axhline(0, color="k", lw=0.6)
ax.set_xlabel("x [mm]")
ax.set_ylabel("Normalized mode shape W(x)")
ax.set_title("Clamped-free beam: first 3 transverse mode shapes")
ax.legend()
plt.show()Natural frequencies (rad/s): [ 88.6 555.2 1554.6]
(textbook: 88.6, 555.2, 1554.7 rad/s)

Note the number of internal nodes (zero-crossings) increases with mode number, and the slope at is always zero (clamped condition) while the curvature at is always zero (free condition, zero moment) — a good sanity check on any mode-shape plot.

6.3 Homework 7 — free-free beam and a cantilever with a tip mass¶
🟦 Part 1: free-free beam. By symmetry with the clamped-free case (both ends free: at ), the characteristic equation is (a rigid body mode also exists and is excluded here).
def char_eq_ff(bl):
return np.cos(bl) * np.cosh(bl) - 1
roots_ff = []
for lo, hi in [(4, 5), (7, 8), (10, 11), (14, 15)]:
roots_ff.append(brentq(char_eq_ff, lo, hi))
print("Free-free betaL roots:", np.round(roots_ff, 4), " (textbook/Blevins: 4.730, 7.853, 10.996, 14.137)")Free-free betaL roots: [ 4.73 7.8532 10.9956 14.1372] (textbook/Blevins: 4.730, 7.853, 10.996, 14.137)
🟦 Part 2: clamped-free beam with a tip point mass . Let the tip mass have no rotary inertia. Deriving the natural boundary conditions from Hamilton’s principle (the tip mass adds a kinetic-energy term, which contributes an extra inertia term exactly at ): the moment condition is unaffected, , while the shear condition becomes
(the beam’s internal shear supplies exactly the force needed to accelerate the tip mass). Using and the general solution , we build the full determinant of the two boundary conditions symbolically (safer than hand algebra), after eliminating via the clamped conditions (, ):
L_s, beta_s, EI_s, M_s, m_s, C3, C4 = sp.symbols("L beta EI M m C3 C4", positive=True)
x_s = sp.symbols("x", positive=True)
W_full = (-C3) * sp.sin(beta_s * x_s) + (-C4) * sp.cos(beta_s * x_s) \
+ C3 * sp.sinh(beta_s * x_s) + C4 * sp.cosh(beta_s * x_s)
Wpp_full = sp.diff(W_full, x_s, 2)
Wppp_full = sp.diff(W_full, x_s, 3)
eqM = EI_s * Wpp_full.subs(x_s, L_s) # moment = 0
eqV = EI_s * Wppp_full.subs(x_s, L_s) + M_s * (beta_s**4 * EI_s / m_s) * W_full.subs(x_s, L_s)
Mat = sp.Matrix([[sp.diff(eqM, C3), sp.diff(eqM, C4)],
[sp.diff(eqV, C3), sp.diff(eqV, C4)]])
det_full = sp.simplify(Mat.det())
# non-dimensionalize: lambda = beta*L, gamma = M/(m*L) (tip mass / beam mass);
# m_s is an overall positive scale factor and does not affect the roots, so set it to 1
lam, gam = sp.symbols("lambda gamma", positive=True)
char_expr = sp.simplify(
(det_full / (-2 * EI_s**2 * beta_s**5 / m_s))
.subs(M_s, gam * m_s * L_s).subs(beta_s, lam / L_s).subs(m_s, 1)
)
char_expr # = cos(lam)*cosh(lam) + 1 + gamma*lam*(cos(lam)*sinh(lam) - sin(lam)*cosh(lam))det_func = sp.lambdify((lam, gam), char_expr, "numpy")
def first_root(gamma_val, bracket=(0.01, 3.0), n=6000):
lo, hi = bracket
ls = np.linspace(lo, hi, n)
vals = det_func(ls, gamma_val)
idx = np.where(np.sign(vals[:-1]) != np.sign(vals[1:]))[0][0]
return brentq(lambda l: det_func(l, gamma_val), ls[idx], ls[idx + 1])
gammas = np.array([1e-6, 0.01, 0.1, 0.3, 1, 3, 10, 30, 100])
lam1 = np.array([first_root(g) for g in gammas])
fig, ax = plt.subplots()
ax.semilogx(gammas, lam1, "o-", label=r"first root $\beta_1L$ (exact, from the determinant)")
ax.axhline(1.8751, color="gray", ls=":", label=r"$\gamma\to0$: standard clamped-free (1.8751)")
ax.plot(gammas, (3 / gammas) ** 0.25, "--",
label=r"$\gamma\to\infty$ asymptote: $\beta_1L\approx(3/\gamma)^{1/4}$")
ax.set_xlabel(r"Mass ratio $\gamma=M/(mL)$")
ax.set_ylabel(r"$\beta_1 L$ (fundamental)")
ax.legend(fontsize=8)
ax.set_title("Cantilever with tip mass: fundamental eigenvalue vs. mass ratio")
plt.show()
Comments:
As (no tip mass), we recover the standard clamped-free result .
As (tip mass dominant), : the beam’s own mass becomes negligible and the system behaves like a simple mass-spring oscillator with the cantilever’s static tip stiffness , giving as — exactly the asymptote plotted above, confirming the beam-with-tip-mass eigenvalue problem smoothly bridges the two textbook limits.