Solved reference notebook. See
07_EngineeringTips_Gershgorin_RayleighRitz_Exercises.ipynb for the blanked-out version.
As a general conclusion, here are a few tips from linear algebra that make vibration problems much easier to reason about and to compute reliably.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
from scipy.linalg import eigh, eig
plt.rcParams["figure.figsize"] = (7, 4.2)
plt.rcParams["axes.grid"] = True
np.set_printoptions(precision=4, suppress=True)7.1 A change of coordinates that symmetrizes the problem¶
For a symmetric, positive-definite mass matrix , its inverse square root is easy to build when is diagonal: $M=\begin{bmatrix}m_1&0\0&m_2\end{bmatrix}\Rightarrow M^{-1/2}=
Let in and premultiply by :
(the mass-normalized stiffness) is symmetric, and generalizes the scalar used throughout the SDOF chapters. Assuming :
so any vibration eigenproblem is secretly a well-behaved real symmetric eigenvalue problem — real eigenvalues, orthogonal eigenvectors, guaranteed by classical linear algebra.
Exercise (handwritten) — worked numeric example¶
🟥 Take and, from Chapter 5’s proportionally-damped example, the stiffness matrix .
M = np.array([[9.0, 0.0], [0.0, 1.0]])
K = np.array([[27.0, -3.0], [-3.0, 3.0]])
M_inv_sqrt = np.diag(1 / np.sqrt(np.diag(M)))
Ktilde = M_inv_sqrt @ K @ M_inv_sqrt
print("Ktilde =\n", Ktilde)
lam_sym, v_sym = eigh(Ktilde)
print("Eigenvalues of Ktilde (=omega^2):", lam_sym)
print("Eigenvectors (orthonormal):\n", v_sym)
print("Orthonormality check v1.v2 =", v_sym[:, 0] @ v_sym[:, 1])Ktilde =
[[ 3. -1.]
[-1. 3.]]
Eigenvalues of Ktilde (=omega^2): [2. 4.]
Eigenvectors (orthonormal):
[[-0.7071 -0.7071]
[-0.7071 0.7071]]
Orthonormality check v1.v2 = -2.2371143170757382e-17
Matches the textbook result exactly: , eigenvalues , , with orthonormal eigenvectors .
7.2 Gershgorin’s theorem¶
For , the eigenvalues of lie in the union of discs in the complex plane:
Sketch of proof. Let be an eigenpair of , and let (the largest-magnitude component). The -th row of gives , so since — i.e. .
This gives fast, cheap bounds on eigenvalue locations without solving the eigenproblem — useful for sanity-checking a numerical result, or for understanding how a design change (which perturbs ’s entries) will move the natural frequencies.
Exercise — Gershgorin discs of a 3-DOF cantilever-like system¶
A 3-DOF system, left end fixed (cantilever-like), throughout:
K3 = np.array([[2.0, -1.0, 0.0], [-1.0, 2.0, -1.0], [0.0, -1.0, 1.0]])
M3 = np.eye(3)
Ktilde3 = M3 # since M=I here, M^{-1/2}=I, so Ktilde = K
Ktilde3 = np.diag(1 / np.sqrt(np.diag(M3))) @ K3 @ np.diag(1 / np.sqrt(np.diag(M3)))
lam3, V3 = eigh(Ktilde3)
print("Eigenvalues of Ktilde (3-DOF):", lam3, " (textbook: 0.1981, 1.5550, 3.2470)")
lam3b, V3b = eig(K3, M3)
print("Cross-check via generalized eig(K,M):", np.sort(lam3b.real))
def gershgorin_discs(A, eigenvalues=None, ax=None):
n = A.shape[0]
if ax is None:
fig, ax = plt.subplots(figsize=(5.5, 5.5))
for i in range(n):
center = A[i, i]
radius = np.sum(np.abs(A[i, :])) - np.abs(A[i, i])
circ = Circle((center, 0), radius, fill=False, edgecolor=f"C{i}", lw=1.5,
label=rf"$D_{i+1}$: center {center:.2f}, radius {radius:.2f}")
ax.add_patch(circ)
if eigenvalues is not None:
ax.scatter(eigenvalues, np.zeros_like(eigenvalues), color="k", zorder=5,
marker="x", label="actual eigenvalues")
all_bounds = [A[i, i] + s * (np.sum(np.abs(A[i, :])) - np.abs(A[i, i]))
for i in range(n) for s in (-1, 1)]
pad = 0.5
ax.set_xlim(min(all_bounds) - pad, max(all_bounds) + pad)
ax.set_ylim(-max(np.abs(np.array(all_bounds))) - pad, max(np.abs(np.array(all_bounds))) + pad)
ax.axhline(0, color="gray", lw=0.5)
ax.set_aspect("equal")
ax.legend(fontsize=8, loc="upper left")
return ax
gershgorin_discs(Ktilde3, eigenvalues=lam3)
plt.title(r"Gershgorin discs of $\tilde K$ bound the (real) eigenvalues")
plt.show()Eigenvalues of Ktilde (3-DOF): [0.1981 1.555 3.247 ] (textbook: 0.1981, 1.5550, 3.2470)
Cross-check via generalized eig(K,M): [0.1981 1.555 3.247 ]

Just from the diagonal and row sums of — no eigenvalue solve at all — we already know the three natural frequencies-squared must lie within these three discs on the real axis, and indeed the true eigenvalues (crosses) all fall inside their respective discs.
7.3 The Rayleigh-Ritz method and Rayleigh’s quotient¶
The Rayleigh-Ritz method approximates a vibration mode as a combination of chosen shape functions, . The Rayleigh quotient
is stationary (its gradient w.r.t. vanishes) exactly at the true eigenvectors, where it equals the corresponding . A key property: the Rayleigh quotient is always an over-estimate of the true fundamental frequency, for any trial vector — so a lower from a better guess is provably a better estimate.
Exercise — comparing three trial vectors¶
Using the 3-DOF system above, compute the Rayleigh quotient for three trial vectors and compare
to the true from eig.
def rayleigh_quotient(X, K, M):
return (X @ K @ X) / (X @ M @ X)
D1 = lam3[0] # true fundamental eigenvalue
trials = {
"X = [1, 2, 3]": np.array([1.0, 2.0, 3.0]),
"X = [1, 1, 1]": np.array([1.0, 1.0, 1.0]),
"X close to true mode": np.array([-0.32, -0.59, -0.73]),
}
errors = {}
for name, X in trials.items():
RR = rayleigh_quotient(X, K3, M3)
err = 100 * (RR - D1) / D1
errors[name] = err
print(f"{name:<22} RR={RR:.4f} true={D1:.4f} error={err:.2f}%")
fig, ax = plt.subplots()
ax.bar(range(len(errors)), list(errors.values()))
ax.set_xticks(range(len(errors)))
ax.set_xticklabels(list(errors.keys()), rotation=15, ha="right", fontsize=8)
ax.set_ylabel(r"Error on $\omega_1^2$ approximation [%]")
ax.set_title("Rayleigh quotient: closer trial vector -> much smaller error")
plt.tight_layout()
plt.show()X = [1, 2, 3] RR=0.2143 true=0.1981 error=8.19%
X = [1, 1, 1] RR=0.3333 true=0.1981 error=68.30%
X close to true mode RR=0.1982 true=0.1981 error=0.06%

Bonus — Rayleigh’s quotient is stationary at every mode, not just the first¶
Using the exact second eigenvector as the trial vector recovers essentially exactly — the stationarity property holds at every eigenvector, not only the fundamental one (though the “always an over-estimate” guarantee is specific to the lowest mode).
X_mode2 = V3[:, 1]
RR2 = rayleigh_quotient(X_mode2, K3, M3)
err2 = 100 * (RR2 - lam3[1]) / lam3[1]
print(f"Rayleigh quotient at the exact 2nd eigenvector: {RR2:.6f} "
f"(true omega_2^2={lam3[1]:.6f}, error={err2:.2e}%)")Rayleigh quotient at the exact 2nd eigenvector: 1.554958 (true omega_2^2=1.554958, error=-7.14e-14%)
Closing note¶
What can we conclude with the Rayleigh-Ritz method? If you can guess a good shape for a mode, you can approximate its natural frequency well — this is exactly the spirit that Finite Element Analysis builds on systematically (using many, low-order, local shape functions instead of a few, global, hand-picked ones) — the subject of VFEA Part 2.
What is missing from this course? Probably experimental modal analysis and system identification — for these, the original notes point to a companion lecture note in French, and our advanced chapters extend the story with the frequency-domain, Lagrangian and plate-vibration material that a first course in vibration theory typically also covers.