Solved reference notebook. See 05_MDOF_EigenProblem_ModalAnalysis_Exercises.ipynb for the
blanked-out version.
import numpy as np
import matplotlib.pyplot as plt
from scipy.linalg import eigh
from scipy.integrate import solve_ivp
plt.rcParams["figure.figsize"] = (7, 4.2)
plt.rcParams["axes.grid"] = True
np.set_printoptions(precision=4, suppress=True)5.1 The linear vibrating system as an eigenvalue problem¶
Real systems have many degrees of freedom. Using matrices, the -DOF equation of motion is
where are symmetric matrices (note: bold capitals now, not scalars as in the SDOF chapters!).

For the two-mass system above (springs/dampers , in the same topology):
First consider undamped, unforced vibration: . Assuming a harmonic solution :
This is a generalized eigenvalue problem (): , non-trivial solutions exist only where . Solving this determinant equation gives the (natural pulsations / eigenvalues); substituting each back gives the corresponding (mode shapes / eigenvectors). Eigenvectors are defined up to a constant — only their shape (direction), not their magnitude, is unique.
Exercise (handwritten) — Lagrange’s method preview¶
For a conservative system, and . Write and in compact quadratic form to identify and directly (a full worked derivation is in the advanced chapter on Lagrange’s equations).
5.2 Exercise “EX4” — solving the eigenproblem numerically¶
Numerical example: , ,kg, ,kg, ,N/m, ,N/m.
M = np.array([[5.0, 0.0], [0.0, 10.0]])
K = np.array([[4.0, -2.0], [-2.0, 6.0]])
def eigsort(K, M):
"""Generalized eigenproblem K u = lambda M u, sorted by ascending natural frequency."""
lam, U = eigh(K, M) # scipy's eigh handles the symmetric generalized eigenproblem directly
order = np.argsort(lam)
lam, U = lam[order], U[:, order]
wn = np.sqrt(np.abs(lam))
return U, wn
U, wn = eigsort(K, M)
print("Natural frequencies (rad/s):", wn)
print("Mode shapes (columns):\n", U)Natural frequencies (rad/s): [0.6325 1. ]
Mode shapes (columns):
[[-0.2582 -0.3651]
[-0.2582 0.1826]]
This matches the textbook result , ,rad/s, with mode shapes (in-phase) and (out-of-phase).

fig, axes = plt.subplots(1, 2, figsize=(9, 3.5))
for ax, i in zip(axes, range(2)):
shape = U[:, i] / np.max(np.abs(U[:, i])) # normalize for display only
ax.plot([0, 1, 2], [0, shape[0], shape[1]], "o-")
ax.axhline(0, color="k", lw=0.6)
ax.set_title(rf"Mode {i+1}, $\omega_{i+1}={wn[i]:.4f}$ rad/s")
ax.set_xticks([0, 1, 2])
ax.set_xticklabels(["wall", "$m_1$", "$m_2$"])
plt.tight_layout()
plt.show()
5.3 Orthogonality of the modes — Exercise “EX4B”¶
Modes are orthogonal with respect to both and : , . The modal mass and modal stiffness are , .
u1, u2 = U[:, 0], U[:, 1]
is_it_zero = u1 @ M @ u2
m1_modal, m2_modal = u1 @ M @ u1, u2 @ M @ u2
k1_modal, k2_modal = u1 @ K @ u1, u2 @ K @ u2
print("u1^T M u2 (should be ~0):", is_it_zero)
print("Modal masses:", m1_modal, m2_modal)
print("Modal stiffnesses:", k1_modal, k2_modal)
print("Check k_i = m_i * wn_i^2:", m1_modal * wn[0] ** 2, m2_modal * wn[1] ** 2)u1^T M u2 (should be ~0): -7.412481864385805e-17
Modal masses: 1.0000000000000002 1.0000000000000002
Modal stiffnesses: 0.4000000000000001 1.0000000000000002
Check k_i = m_i * wn_i^2: 0.39999999999999997 1.0
scipy.linalg.eigh(K, M) actually already returns mass-normalized eigenvectors
() by convention — one of the four normalization choices discussed in the
original notes (unit modal mass / largest element set to 1 / a chosen element set to 1 / unit
Euclidean norm). Let’s verify:
print("Modal mass with scipy's own normalization:", np.diag(U.T @ M @ U))
print("Modal stiffness (should be diag(wn^2)):", np.diag(U.T @ K @ U))Modal mass with scipy's own normalization: [1. 1.]
Modal stiffness (should be diag(wn^2)): [0.4 1. ]
5.4 Modal matrix and modal coordinates — Exercise “EX4C”¶
The modal matrix decouples the system via . Substituting into the EoM and premultiplying by uses the orthogonality relations to produce diagonal (decoupled) modal mass and stiffness matrices.
P = U # already mass-normalized by eigh
print("P^T M P =\n", P.T @ M @ P)
print("P^T K P =\n", P.T @ K @ P)P^T M P =
[[ 1. -0.]
[-0. 1.]]
P^T K P =
[[ 0.4 -0. ]
[-0. 1. ]]
Both are diagonal, as expected — the coupled 2-DOF system in physical coordinates becomes two independent SDOF systems in modal coordinates: , with (mass-normalized modes).

5.5 Modal time response to initial conditions — Exercise “EX4D”¶
Calculate the free response to , using modal analysis: transform initial conditions to modal coordinates, solve each uncoupled SHM equation, then transform back with .
x0 = np.array([1.0, 1.0])
xdot0 = np.array([0.0, 0.0])
q0 = P.T @ M @ x0 # modal initial displacement (mass-normalized modes)
qdot0 = P.T @ M @ xdot0 # modal initial velocity
t = np.arange(0, 100.1, 0.1)
q1 = q0[0] * np.cos(wn[0] * t) + qdot0[0] / wn[0] * np.sin(wn[0] * t)
q2 = q0[1] * np.cos(wn[1] * t) + qdot0[1] / wn[1] * np.sin(wn[1] * t)
q = np.vstack([q1, q2])
x = P @ q
fig, ax = plt.subplots()
ax.plot(t, x[0], label="$x_1(t)$")
ax.plot(t, x[1], label="$x_2(t)$")
ax.set_xlabel("Time [s]")
ax.set_ylabel("Displacement")
ax.set_title("Modal superposition: free response to initial displacement")
ax.legend()
plt.show()
Cross-check against direct numerical integration of the coupled system¶
def mdof_free_ode(t, y, M, K):
n = M.shape[0]
x, v = y[:n], y[n:]
a = np.linalg.solve(M, -K @ x)
return np.concatenate([v, a])
sol = solve_ivp(mdof_free_ode, [0, 100], np.concatenate([x0, xdot0]), args=(M, K),
t_eval=t, rtol=1e-10, atol=1e-12)
print("Max abs difference, x1:", np.max(np.abs(x[0] - sol.y[0])))
print("Max abs difference, x2:", np.max(np.abs(x[1] - sol.y[1])))Max abs difference, x1: 7.663050194395282e-10
Max abs difference, x2: 7.663064627294602e-10
5.6 Proportional damping & modal analysis of the forced response — Exercise “EX4E”¶
Damping is hard to characterize exactly, so a common simplifying model is proportional (Rayleigh) damping: . Caughey (1960) showed that and commuting is necessary and sufficient for the system to be completely decoupled by the same modal matrix used for the undamped problem.
Numerical example (Inman, Engineering Vibration, Ex. 4.6.1): ,kg, ,kg, ,N/m, ,N/m, , forcing , ,N.
M = np.diag([9.0, 1.0])
K = np.array([[27.0, -3.0], [-3.0, 3.0]])
alpha, beta = 0.0, 0.1
C = alpha * M + beta * K
print("C =\n", C) # matches [2.7, -0.3; -0.3, 0.3] from the original notes
U, wn = eigsort(K, M)
P = U
Mm = np.diag(P.T @ M @ P)
Cm = np.diag(P.T @ C @ P)
Km = np.diag(P.T @ K @ P)
zeta = Cm / (2 * wn) # since Cm_i = 2*zeta_i*wn_i (mass-normalized modes: Mm_i=1)
print("P =\n", P)
print("Modal mass :", Mm)
print("Modal damping:", Cm)
print("Modal stiffness (=wn^2):", Km)
print("Modal damping ratios:", zeta)
print("Damped natural frequencies:", wn * np.sqrt(1 - zeta**2))C =
[[ 2.7 -0.3]
[-0.3 0.3]]
P =
[[-0.2357 -0.2357]
[-0.7071 0.7071]]
Modal mass : [1. 1.]
Modal damping: [0.2 0.4]
Modal stiffness (=wn^2): [2. 4.]
Modal damping ratios: [0.0707 0.1 ]
Damped natural frequencies: [1.4107 1.99 ]
Steady-state forced response via modal superposition¶
Each modal coordinate obeys with . For , the steady-state solution of each decoupled equation is a phase-shifted cosine; transforming back with gives the physical steady-state response.
Omega, F2amp = 2.0, 3.0
f_amp = np.array([0.0, F2amp])
N_amp = P.T @ f_amp # modal forcing amplitudes
t = np.linspace(0, 60, 6000)
q_ss = np.zeros((2, len(t)))
for i in range(2):
denom = np.sqrt((wn[i] ** 2 - Omega**2) ** 2 + (2 * zeta[i] * wn[i] * Omega) ** 2)
Qamp = N_amp[i] / denom
phi = np.arctan2(2 * zeta[i] * wn[i] * Omega, wn[i] ** 2 - Omega**2)
q_ss[i] = Qamp * np.cos(Omega * t - phi)
x_ss = P @ q_ss
fig, ax = plt.subplots()
ax.plot(t, x_ss[0], label="$x_1(t)$ steady-state (modal superposition)")
ax.plot(t, x_ss[1], label="$x_2(t)$ steady-state (modal superposition)")
ax.set_xlabel("Time [s]")
ax.set_ylabel("Displacement")
ax.legend()
ax.set_title("Forced response via modal superposition with proportional damping")
plt.show()
Cross-check against direct numerical integration of the full (coupled, damped) system¶
def mdof_forced_ode(t, y, M, C, K, f_amp, Omega):
n = M.shape[0]
x, v = y[:n], y[n:]
f = f_amp * np.cos(Omega * t)
a = np.linalg.solve(M, f - C @ v - K @ x)
return np.concatenate([v, a])
sol = solve_ivp(mdof_forced_ode, [0, 60], [0, 0, 0, 0], args=(M, C, K, f_amp, Omega),
t_eval=t, rtol=1e-10, atol=1e-12)
fig, ax = plt.subplots()
ax.plot(t, x_ss[0], label="Modal superposition (steady-state only)")
ax.plot(sol.t, sol.y[0], "--", alpha=0.7, label="Full numerical integration (incl. transient)")
ax.set_xlabel("Time [s]")
ax.set_ylabel("$x_1(t)$")
ax.legend()
ax.set_title("Modal superposition matches the numerical steady state once the transient decays")
plt.show()
print("Max abs difference over the last 20s (steady-state window):",
np.max(np.abs(x_ss[0][t > 40] - sol.y[0][t > 40])))
Max abs difference over the last 20s (steady-state window): 0.004292169285680658