Chapter 11
25 min read
Section 109 of 353

Moment of Inertia and Rotational Dynamics

Applications in Physics and Engineering (Integration)

Learning Objectives

By the end of this section, you will be able to:

  1. Understand the physical meaning of moment of inertia as rotational mass
  2. Calculate moments of inertia for discrete point masses and continuous objects
  3. Use integration to derive moment of inertia formulas for various shapes
  4. Apply the parallel and perpendicular axis theorems
  5. Analyze rotational dynamics using Newton's second law for rotation
  6. Connect moment of inertia to covariance matrices and PCA in machine learning

The Big Picture: Resistance to Rotation

"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." — Archimedes

When you push a door, why does it rotate more easily when you push near the handle rather than near the hinges? Why does an ice skater spin faster when pulling their arms in? Why do figure skaters extend their arms to slow down? The answer lies in the moment of inertia — the rotational equivalent of mass.

The Central Insight

Just as mass measures resistance to linear acceleration (F=maF = ma), the moment of inertia measures resistance to angular acceleration. But unlike mass, moment of inertia depends on how the mass is distributed relative to the rotation axis.

τ=Iα\tau = I \alpha

Torque = Moment of Inertia × Angular Acceleration

This is why a hollow cylinder is harder to spin than a solid cylinder of the same mass — the mass is farther from the axis. Integration gives us the tools to calculate exactly how mass distribution affects rotational behavior.


Historical Context: From Huygens to Euler

The concept of moment of inertia emerged from the study of pendulums and rotating bodies in the 17th and 18th centuries.

Christiaan Huygens (1629-1695)

Huygens invented the pendulum clock and studied compound pendulums. He discovered that a physical pendulum's period depends not just on its mass, but on how that mass is distributed. He defined what we now call the radius of gyration — the distance from the axis at which all the mass could be concentrated to give the same moment of inertia.

Leonhard Euler (1707-1783)

Euler formalized the theory of rigid body rotation, introducing the concept of principal axes and showing that the moment of inertia is actually a tensor (a matrix) that captures how a body resists rotation about different axes. This tensor structure is exactly what appears in machine learning as the covariance matrix!


The Linear-Rotational Analogy

Every concept in linear motion has a rotational counterpart. Understanding this analogy makes rotational dynamics intuitive:

Linear MotionSymbolRotational MotionSymbol
PositionxAngleθ
Velocityv = dx/dtAngular velocityω = dθ/dt
Accelerationa = dv/dtAngular accelerationα = dω/dt
MassmMoment of inertiaI
ForceFTorqueτ
Momentump = mvAngular momentumL = Iω
Kinetic energy½ mv²Rotational KE½ Iω²
Newton's 2nd LawF = maRotational versionτ = Iα

The Key Difference

While mass is an intrinsic property of an object, the moment of inertia depends on the choice of axis. The same object has different moments of inertia about different axes!


Discrete Mass Systems

For a collection of point masses m1,m2,,mnm_1, m_2, \ldots, m_n at perpendicular distances r1,r2,,rnr_1, r_2, \ldots, r_n from the rotation axis:

Moment of Inertia (Discrete)

I=i=1nmiri2I = \sum_{i=1}^{n} m_i r_i^2
Sum of (mass × perpendicular distance squared)

Why the Square?

The r2r^2 factor is crucial. It means that mass far from the axis contributes much more to the moment of inertia than mass near the axis. Doubling the distance quadruples the contribution!

  • A 1 kg mass at 1 m contributes 112=11 \cdot 1^2 = 1 kg·m²
  • A 1 kg mass at 2 m contributes 122=41 \cdot 2^2 = 4 kg·m² — 4× more!
  • A 1 kg mass at 3 m contributes 132=91 \cdot 3^2 = 9 kg·m² — 9× more!

This is why figure skaters pull their arms in to spin faster — they reduce their moment of inertia, and by conservation of angular momentum, their angular velocity increases.

Interactive: Moment of Inertia Explorer

Drag the masses and adjust their weights to see how the moment of inertia changes. Notice how moving mass farther from the axis dramatically increasesII:

🌀Moment of Inertia Explorer

Drag masses to see how position affects the moment of inertia. Move mass farther from the axis to increase I.

Moment of Inertia
I = 3.750 kg·m²
I = \u03A3 m\u1D62r\u1D62² where r is distance from axis
2 kg
3 kg
1 kg
Key Insight: The moment of inertia depends on the square of the distance. Moving a mass from 1m to 2m from the axis increases its contribution by 4×, not 2×!

Continuous Mass Distributions

For a continuous object with density ρ\rho (mass per unit length, area, or volume), we replace the sum with an integral:

Moment of Inertia (Continuous)

1D (rod): I=r2dm=r2ρ(x)dxI = \int r^2 \, dm = \int r^2 \rho(x) \, dx
2D (lamina): I=r2dm=r2ρ(x,y)dAI = \iint r^2 \, dm = \iint r^2 \rho(x,y) \, dA
3D (solid): I=r2dm=r2ρ(x,y,z)dVI = \iiint r^2 \, dm = \iiint r^2 \rho(x,y,z) \, dV
where rr is the perpendicular distance from the point to the rotation axis

Example: Uniform Rod About Center

Problem: Find the moment of inertia of a uniform rod of mass MM and length LL about an axis through its center, perpendicular to the rod.

Solution:

Place the rod along the x-axis from L/2-L/2 to L/2L/2, with the axis at the origin.

The linear density is λ=M/L\lambda = M/L. A small element at position xx has mass dm=λdx=(M/L)dxdm = \lambda \, dx = (M/L) dx.

Its perpendicular distance from the axis is r=xr = |x|, but since we integrate r2=x2r^2 = x^2, the sign doesn't matter.

I=L/2L/2x2MLdx=MLx33L/2L/2I = \int_{-L/2}^{L/2} x^2 \cdot \frac{M}{L} \, dx = \frac{M}{L} \cdot \frac{x^3}{3} \Big|_{-L/2}^{L/2}
=ML13[L38(L38)]=MLL312= \frac{M}{L} \cdot \frac{1}{3} \left[\frac{L^3}{8} - \left(-\frac{L^3}{8}\right)\right] = \frac{M}{L} \cdot \frac{L^3}{12}
Icenter=112ML2I_{\text{center}} = \frac{1}{12}ML^2

Common Shapes and Their Moments

Here are the moments of inertia for common shapes, all derived using integration:

ShapeAxisMoment of InertiaNotes
Point massAt distance rI = mr²Definition
Rod (uniform)Through centerI = (1/12)ML²Perpendicular to rod
Rod (uniform)Through endI = (1/3)ML²Perpendicular to rod
Thin ringThrough centerI = MR²Perpendicular to plane
Solid diskThrough centerI = (1/2)MR²Perpendicular to plane
DiskAlong diameterI = (1/4)MR²In plane of disk
Hollow cylinderCentral axisI = MR²All mass at radius R
Solid cylinderCentral axisI = (1/2)MR²Uniform distribution
Solid sphereAny diameterI = (2/5)MR²Uniform density
Hollow sphereAny diameterI = (2/3)MR²Thin shell

Pattern Recognition

Notice the pattern: shapes with mass concentrated at the edge (hollow cylinder, ring, shell) have larger moments than shapes with mass distributed throughout (solid cylinder, disk, sphere). This is the r2r^2 factor at work!


Parallel Axis Theorem

The parallel axis theorem is the most important tool for calculating moments of inertia. It relates the moment about any axis to the moment about a parallel axis through the center of mass:

Parallel Axis Theorem

I=Icm+Md2I = I_{\text{cm}} + Md^2
where dd is the distance between the axes, and IcmI_{\text{cm}} is the moment about the center of mass

Proof (using integration)

Let the center of mass be at the origin, with the desired axis at x=dx = d. For a point mass element at (x,y)(x, y):

I=(xd)2dm=(x22xd+d2)dmI = \int (x-d)^2 \, dm = \int (x^2 - 2xd + d^2) \, dm
=x2dmIcm2dxdm=0+d2dmM=Icm+Md2= \underbrace{\int x^2 \, dm}_{I_{\text{cm}}} - 2d \underbrace{\int x \, dm}_{= 0} + d^2 \underbrace{\int dm}_{M} = I_{\text{cm}} + Md^2

The middle term vanishes because xdm=Mxˉ=0\int x \, dm = M\bar{x} = 0 when the origin is at the center of mass!

Interactive: Parallel Axis Theorem

Move the rotation axis and see how the moment of inertia changes according to the parallel axis theorem:

↔️Parallel Axis Theorem

Move the axis away from the center of mass to see how I increases by Md².

About Center of Mass
Icm = 0.6400 kg·m²
I_cm = (1/2)MR²
About New Axis
I = 0.6400 kg·m²
I = Icm + Md² = 0.6400 + 2 × 0.00²
Parallel Axis Theorem: I = Icm + Md²

The moment about any axis equals the moment about a parallel axis through the center of mass plus Md², where d is the distance between axes.


Perpendicular Axis Theorem

For planar objects (2D laminas), there's another useful theorem:

Perpendicular Axis Theorem (Planar Objects Only)

Iz=Ix+IyI_z = I_x + I_y
where z is perpendicular to the plane, and x, y are in the plane

Proof

For a point at (x,y,0)(x, y, 0):

  • Ix=y2dmI_x = \int y^2 \, dm (moment about x-axis uses distance from x-axis, which is y)
  • Iy=x2dmI_y = \int x^2 \, dm (moment about y-axis uses distance from y-axis, which is x)
  • Iz=r2dm=(x2+y2)dm=Iy+IxI_z = \int r^2 \, dm = \int (x^2 + y^2) \, dm = I_y + I_x

Example: Disk About Diameter

For a uniform disk, we know Iz=12MR2I_z = \frac{1}{2}MR^2 (perpendicular to the disk through center).

By symmetry, Ix=IyI_x = I_y (any two perpendicular diameters are equivalent).

Using the perpendicular axis theorem:

Iz=Ix+Iy=2Ix    Ix=Iz2=14MR2I_z = I_x + I_y = 2I_x \implies I_x = \frac{I_z}{2} = \frac{1}{4}MR^2

Worked Examples

Example 1: Compound Object

Problem: A barbell consists of a rod of mass 2 kg and length 1 m, with two point masses of 5 kg each attached at the ends. Find the moment of inertia about an axis through the center of the rod.

Solution:

We add the contributions from each part:

Rod: Irod=112ML2=112(2)(1)2=16I_{\text{rod}} = \frac{1}{12}ML^2 = \frac{1}{12}(2)(1)^2 = \frac{1}{6} kg·m²

Each mass: At distance r=L/2=0.5r = L/2 = 0.5 m from the axis:

Imasses=2mr2=2(5)(0.5)2=2.5I_{\text{masses}} = 2 \cdot m \cdot r^2 = 2(5)(0.5)^2 = 2.5 kg·m²
Itotal=16+2.5=2.67I_{\text{total}} = \frac{1}{6} + 2.5 = 2.67 kg·m²

Note: The point masses dominate! Even though the rod has a comparable mass (2 kg vs 10 kg total in masses), the masses at the ends contribute much more because they're farther from the axis.

Example 2: Applying Parallel Axis Theorem

Problem: A uniform disk of mass 3 kg and radius 0.4 m rotates about an axis at its edge (tangent to the circle). Find its moment of inertia.

Solution:

First, find the moment about the center:

Icm=12MR2=12(3)(0.4)2=0.24I_{\text{cm}} = \frac{1}{2}MR^2 = \frac{1}{2}(3)(0.4)^2 = 0.24 kg·m²

The new axis is at distance d=R=0.4d = R = 0.4 m from the center.

Apply the parallel axis theorem:

I=Icm+Md2=0.24+(3)(0.4)2=0.24+0.48=0.72I = I_{\text{cm}} + Md^2 = 0.24 + (3)(0.4)^2 = 0.24 + 0.48 = 0.72 kg·m²
I=0.72I = 0.72 kg·m² (3× the central moment!)

Rotational Dynamics in Action

Now let's see how moment of inertia affects rotational motion. The rotational analog of Newton's second law is:

τ=Iα\tau = I \alpha

For a given torque τ\tau, a larger moment of inertia means smaller angular acceleration. Watch how different mass distributions respond to the same applied torque:

🎡Rotational Dynamics: τ = Iα

Apply the same torque to different shapes. Objects with smaller moment of inertia accelerate faster!

Solid Disk
α = 31.25 rad/s²
I = 0.1600 kg·m²
Ring/Hoop
α = 15.62 rad/s²
I = 0.3200 kg·m²
Solid Sphere
α = 39.06 rad/s²
I = 0.1280 kg·m²
Hollow Sphere
α = 23.44 rad/s²
I = 0.2133 kg·m²
Newton's Second Law for Rotation: τ = Iα

For the same torque τ, objects with smaller I have larger angular acceleration α. The solid sphere spins up fastest because it has the smallest moment of inertia (mass closest to axis on average).


Real-World Applications

Flywheels: Energy Storage

Application: Flywheels store kinetic energy in rotation. The energy stored is E=12Iω2E = \frac{1}{2}I\omega^2. For maximum energy storage at a given angular velocity, we want maximum moment of inertia, which means putting mass at the rim.

This is why flywheels are often designed as heavy rings rather than solid disks — more energy storage per unit mass!

Vehicle Design: Crankshafts and Wheels

Application: In engine design, crankshafts need enough moment of inertia to smooth out power pulses from individual cylinders, but not so much that the engine responds sluggishly.

Racing car wheels are made as light as possible (low moment of inertia) for quick acceleration and deceleration. The rotating mass of wheels effectively adds to the car's inertia.

Sports: Ice Skating and Diving

Application: Angular momentum L=IωL = I\omega is conserved when no external torque acts. When a skater pulls in their arms, II decreases, so ω\omega must increase to keep LL constant.

A skater can increase their spin rate by 3-4× just by changing their arm position. Divers use the same principle to control rotation speed during flips.

Structural Engineering: Beams

Application: The second moment of area (area moment of inertia) determines a beam's resistance to bending. I-beams are designed to maximize this moment while minimizing material — by putting material far from the neutral axis.


Machine Learning Connection: Covariance and PCA

The moment of inertia isn't just physics — it's the same mathematical structure that appears in statistics and machine learning as the covariance matrix!

Covariance Matrix = Moment of Inertia Tensor

For data points (xi,yi)(x_i, y_i) with mean at the origin:

Covariance Matrix

Σ=(E[x2]E[xy]E[xy]E[y2])\Sigma = \begin{pmatrix} \text{E}[x^2] & \text{E}[xy] \\ \text{E}[xy] & \text{E}[y^2] \end{pmatrix}

Inertia Tensor

I=(IxxIxyIxyIyy)\mathbf{I} = \begin{pmatrix} I_{xx} & I_{xy} \\ I_{xy} & I_{yy} \end{pmatrix}

The variance E[x2]\text{E}[x^2] measures how spread the data is from the y-axis — exactly like IyyI_{yy} measures mass distribution from the y-axis!

PCA = Finding Principal Axes

In physics, principal axes are directions where the products of inertia (IxyI_{xy}) vanish — the rotation is "pure" about that axis.

In PCA, we find the eigenvectors of the covariance matrix — directions where the data is uncorrelated. These are exactly the same mathematical operation!

The Deep Connection

  • Eigenvalues of covariance = principal moments of inertia
  • Eigenvectors = principal axis directions
  • PCA rotation = rotating to principal axes
  • Variance along PC = moment of inertia about that axis

L2 Regularization

The L2 regularization term λwi2\lambda \sum w_i^2 is the moment of inertia of weights about the origin in weight space! Minimizing L2 regularization keeps the "mass" of weights close to zero — reducing the model's rotational inertia in weight space.


Python Implementation

Computing Moments of Inertia

Moment of Inertia Calculations
🐍moment_of_inertia.py
3Discrete Moment of Inertia

For point masses, I = Σmᵢrᵢ². Each mass contributes proportionally to its mass times the SQUARE of its distance from the axis. This is why masses far from the axis contribute much more to rotational inertia.

25Rod About Center

Using integration: I = ∫(M/L)x² dx from -L/2 to L/2 = (1/12)ML². The density is M/L (mass per unit length), and we sum x² contributions.

28Rod About End

When the axis is at one end: I = ∫(M/L)x² dx from 0 to L = (1/3)ML². This is 4× larger than about the center because mass is farther from the axis.

52Disk About Perpendicular Axis

Using polar coordinates: I = ∬ r² · ρ · r dr dθ. The extra r comes from the area element in polar coordinates. Result: (1/2)MR².

83Solid vs Hollow Sphere

A hollow sphere has (2/3)MR², larger than a solid sphere (2/5)MR² because all mass is at the outer surface, maximizing r² contribution.

97Parallel Axis Theorem

I = I_cm + Md². The moment about any parallel axis equals the moment about the center of mass plus an additional term Md². This is the most important theorem for moment of inertia calculations!

117Custom Integration

For irregular shapes, we numerically compute I = ∬ r²ρ(x,y) dA. The axis_func computes the perpendicular distance from each point to the rotation axis.

172Ring vs Disk Comparison

A thin ring has I = MR² (all mass at distance R), while a solid disk has I = (1/2)MR² (mass distributed from 0 to R). This 2× difference shows why hollow objects are harder to spin.

207 lines without explanation
1import numpy as np
2from scipy import integrate
3import matplotlib.pyplot as plt
4
5def moment_of_inertia_discrete(masses, distances):
6    """
7    Compute moment of inertia for discrete point masses.
8
9    I = Σ mᵢ · rᵢ²
10
11    Parameters:
12    -----------
13    masses : array - Mass values (kg)
14    distances : array - Perpendicular distances from axis (m)
15
16    Returns:
17    --------
18    float : Moment of inertia (kg·m²)
19    """
20    masses = np.array(masses)
21    distances = np.array(distances)
22    return np.sum(masses * distances**2)
23
24def moment_of_inertia_rod(mass, length, axis="center"):
25    """
26    Moment of inertia of a uniform rod.
27
28    About center: I = (1/12) M L²
29    About end: I = (1/3) M L²
30
31    Parameters:
32    -----------
33    mass : float - Total mass (kg)
34    length : float - Length of rod (m)
35    axis : str - "center" or "end"
36
37    Returns:
38    --------
39    float : Moment of inertia (kg·m²)
40    """
41    if axis == "center":
42        # I = ∫_{-L/2}^{L/2} (M/L) x² dx = (1/12) ML²
43        return (1/12) * mass * length**2
44    elif axis == "end":
45        # I = ∫_0^L (M/L) x² dx = (1/3) ML²
46        return (1/3) * mass * length**2
47    else:
48        raise ValueError("axis must be 'center' or 'end'")
49
50def moment_of_inertia_disk(mass, radius, axis="perpendicular"):
51    """
52    Moment of inertia of a uniform disk.
53
54    Perpendicular to disk through center: I = (1/2) MR²
55    Along diameter: I = (1/4) MR²
56
57    Parameters:
58    -----------
59    mass : float - Total mass (kg)
60    radius : float - Radius of disk (m)
61    axis : str - "perpendicular" or "diameter"
62
63    Returns:
64    --------
65    float : Moment of inertia (kg·m²)
66    """
67    if axis == "perpendicular":
68        # Using polar coordinates: I = ∫∫ r² · ρ · r dr dθ
69        return (1/2) * mass * radius**2
70    elif axis == "diameter":
71        return (1/4) * mass * radius**2
72    else:
73        raise ValueError("axis must be 'perpendicular' or 'diameter'")
74
75def moment_of_inertia_sphere(mass, radius, solid=True):
76    """
77    Moment of inertia of a uniform sphere about any diameter.
78
79    Solid sphere: I = (2/5) MR²
80    Hollow sphere: I = (2/3) MR²
81
82    Parameters:
83    -----------
84    mass : float - Total mass (kg)
85    radius : float - Radius of sphere (m)
86    solid : bool - True for solid, False for hollow shell
87
88    Returns:
89    --------
90    float : Moment of inertia (kg·m²)
91    """
92    if solid:
93        return (2/5) * mass * radius**2
94    else:
95        return (2/3) * mass * radius**2
96
97def parallel_axis_theorem(I_cm, mass, d):
98    """
99    Apply the parallel axis theorem.
100
101    I = I_cm + M·d²
102
103    Parameters:
104    -----------
105    I_cm : float - Moment of inertia about center of mass (kg·m²)
106    mass : float - Total mass (kg)
107    d : float - Distance from center of mass to new axis (m)
108
109    Returns:
110    --------
111    float : Moment of inertia about new axis (kg·m²)
112    """
113    return I_cm + mass * d**2
114
115def moment_of_inertia_custom(density_func, region_bounds, axis_func):
116    """
117    Compute moment of inertia via numerical integration.
118
119    I = ∬ r² · ρ(x, y) dA
120
121    where r = distance from point to axis
122
123    Parameters:
124    -----------
125    density_func : callable - Density function ρ(x, y)
126    region_bounds : dict - Integration bounds
127    axis_func : callable - Returns distance to axis for point (x, y)
128
129    Returns:
130    --------
131    tuple : (moment_of_inertia, total_mass)
132    """
133    x_min, x_max = region_bounds["x"]
134    y_func_min, y_func_max = region_bounds["y"]
135
136    # Moment of inertia integrand: r² · ρ
137    def I_integrand(y, x):
138        r = axis_func(x, y)
139        return r**2 * density_func(x, y)
140
141    # Mass integrand
142    def mass_integrand(y, x):
143        return density_func(x, y)
144
145    # Compute integrals
146    I, _ = integrate.dblquad(
147        I_integrand,
148        x_min, x_max,
149        y_func_min, y_func_max
150    )
151
152    M, _ = integrate.dblquad(
153        mass_integrand,
154        x_min, x_max,
155        y_func_min, y_func_max
156    )
157
158    return I, M
159
160# Example demonstrations
161print("=" * 60)
162print("MOMENT OF INERTIA CALCULATIONS")
163print("=" * 60)
164
165# Example 1: Discrete masses
166print("\n1. DISCRETE POINT MASSES")
167print("-" * 40)
168masses = [2, 3, 1, 4]  # kg
169distances = [0.5, 1.0, 1.5, 2.0]  # m from axis
170
171I_discrete = moment_of_inertia_discrete(masses, distances)
172print(f"Masses: {masses} kg")
173print(f"Distances: {distances} m")
174print(f"I = Σ mᵢrᵢ² = {I_discrete:.4f} kg·m²")
175
176# Verify by hand:
177manual = sum(m * r**2 for m, r in zip(masses, distances))
178print(f"Manual check: 2(0.5)² + 3(1.0)² + 1(1.5)² + 4(2.0)²")
179print(f"           = 0.5 + 3.0 + 2.25 + 16.0 = {manual:.2f} kg·m²")
180
181# Example 2: Uniform rod
182print("\n2. UNIFORM ROD (M = 2 kg, L = 1 m)")
183print("-" * 40)
184M_rod, L_rod = 2.0, 1.0
185
186I_center = moment_of_inertia_rod(M_rod, L_rod, "center")
187I_end = moment_of_inertia_rod(M_rod, L_rod, "end")
188
189print(f"About center: I = (1/12)ML² = {I_center:.4f} kg·m²")
190print(f"About end:    I = (1/3)ML² = {I_end:.4f} kg·m²")
191
192# Verify with parallel axis theorem
193I_end_from_center = parallel_axis_theorem(I_center, M_rod, L_rod/2)
194print(f"Verify end via parallel axis: I_cm + M(L/2)²")
195print(f"  = {I_center:.4f} + {M_rod}({L_rod/2})² = {I_end_from_center:.4f} kg·m²")
196
197# Example 3: Disk vs Ring
198print("\n3. DISK VS RING (M = 1 kg, R = 0.5 m)")
199print("-" * 40)
200M_disk, R_disk = 1.0, 0.5
201
202I_disk = moment_of_inertia_disk(M_disk, R_disk, "perpendicular")
203I_ring = M_disk * R_disk**2  # All mass at distance R
204
205print(f"Solid disk:  I = (1/2)MR² = {I_disk:.4f} kg·m²")
206print(f"Thin ring:   I = MR²     = {I_ring:.4f} kg·m²")
207print(f"The ring has 2× the moment because all mass is at maximum distance")
208
209# Example 4: Parallel axis theorem
210print("\n4. PARALLEL AXIS THEOREM")
211print("-" * 40)
212print("Disk rotating about axis 1 m from center:")
213d = 1.0
214I_offset = parallel_axis_theorem(I_disk, M_disk, d)
215print(f"I = I_cm + Md² = {I_disk:.4f} + {M_disk}({d})² = {I_offset:.4f} kg·m²")

Machine Learning Connections

Covariance, PCA, and Moment of Inertia
🐍moment_of_inertia_ml.py
3Covariance as Moment of Inertia

The covariance matrix is EXACTLY the moment of inertia tensor for data! E[x²] measures how spread the data is from the y-axis, just like I_yy measures mass distribution from the y-axis.

37Computing Covariance

np.cov computes the covariance matrix, which captures the same information as the moment of inertia tensor. The diagonal elements are variances, the off-diagonal is covariance.

48Moment Interpretation

I_xx = Σyᵢ²/n uses y-distance because moment about x-axis uses perpendicular distance (which is y). This is why I_xx = Σ_yy (they swap).

73PCA as Principal Axes

PCA finds the principal axes of inertia for data. The eigenvectors point in directions where there is no 'cross-moment' (covariance = 0), just like principal axes eliminate products of inertia.

103Eigenvalues = Principal Moments

The eigenvalues of the covariance matrix ARE the moments of inertia about the principal axes. Larger eigenvalue = more data spread along that axis = larger 'moment' of the data distribution.

138L2 Regularization

The L2 penalty λΣwᵢ² is the moment of inertia of weights about the origin. Minimizing it keeps weights 'close to origin' - like reducing moment of inertia for easier rotation.

166 lines without explanation
1import numpy as np
2from scipy import integrate
3
4def covariance_as_moment_of_inertia():
5    """
6    The COVARIANCE MATRIX is the moment of inertia tensor for data!
7
8    For 2D data centered at origin:
9    - Σ_xx = E[x²] = ∫∫ x² f(x,y) dx dy  (variance in x)
10    - Σ_yy = E[y²] = ∫∫ y² f(x,y) dx dy  (variance in y)
11    - Σ_xy = E[xy] = ∫∫ xy f(x,y) dx dy  (covariance)
12
13    This is EXACTLY the structure of moment of inertia calculations!
14    """
15    print("=" * 60)
16    print("COVARIANCE MATRIX = MOMENT OF INERTIA TENSOR")
17    print("=" * 60)
18
19    # Generate 2D data
20    np.random.seed(42)
21    n_points = 1000
22
23    # Data with correlation (elliptical distribution)
24    cov_true = np.array([[2.0, 0.8],
25                         [0.8, 0.5]])
26    mean = np.array([0, 0])
27    data = np.random.multivariate_normal(mean, cov_true, n_points)
28
29    x, y = data[:, 0], data[:, 1]
30
31    # Compute covariance matrix
32    cov_computed = np.cov(data.T)
33
34    print("\n1. COVARIANCE MATRIX (data analogy)")
35    print("-" * 40)
36    print(f"Σ_xx (variance in x) = E[x²] = {cov_computed[0,0]:.4f}")
37    print(f"Σ_yy (variance in y) = E[y²] = {cov_computed[1,1]:.4f}")
38    print(f"Σ_xy (covariance)    = E[xy] = {cov_computed[0,1]:.4f}")
39
40    print("\n2. MOMENT OF INERTIA INTERPRETATION")
41    print("-" * 40)
42
43    # If we treat each data point as a unit mass:
44    # I_xx = Σ y_i² = moment about x-axis
45    # I_yy = Σ x_i² = moment about y-axis
46    # I_xy = -Σ x_i y_i = product of inertia
47
48    I_xx = np.sum(y**2) / n_points  # = Σ_yy
49    I_yy = np.sum(x**2) / n_points  # = Σ_xx
50    I_xy = -np.sum(x * y) / n_points  # = -Σ_xy
51
52    print(f"I_xx (moment about x-axis) = Σy²/n = {I_xx:.4f}")
53    print(f"I_yy (moment about y-axis) = Σx²/n = {I_yy:.4f}")
54    print(f"I_xy (product of inertia)  = -Σxy/n = {I_xy:.4f}")
55
56    print("\nNotice: I_xx = Σ_yy and I_yy = Σ_xx (swapped!)")
57    print("This is because moment uses perpendicular distance.")
58
59    return cov_computed
60
61def pca_as_principal_axes():
62    """
63    PCA finds the PRINCIPAL AXES of inertia for data!
64
65    Just as a rigid body has principal axes where I_xy = 0,
66    PCA finds directions where covariance = 0 (uncorrelated).
67
68    The eigenvalues are the moments of inertia about each axis.
69    The eigenvectors are the principal axis directions.
70    """
71    print("\n" + "=" * 60)
72    print("PCA = FINDING PRINCIPAL AXES OF INERTIA")
73    print("=" * 60)
74
75    # Generate correlated data
76    np.random.seed(42)
77    n_points = 500
78
79    # Create elongated ellipse
80    t = np.linspace(0, 2*np.pi, n_points)
81    x_base = 3 * np.cos(t) + 0.3 * np.random.randn(n_points)
82    y_base = 1 * np.sin(t) + 0.3 * np.random.randn(n_points)
83
84    # Rotate by 30 degrees
85    theta = np.radians(30)
86    x = x_base * np.cos(theta) - y_base * np.sin(theta)
87    y = x_base * np.sin(theta) + y_base * np.cos(theta)
88
89    data = np.column_stack([x, y])
90
91    # Compute covariance
92    cov = np.cov(data.T)
93
94    # Find principal axes (eigendecomposition)
95    eigenvalues, eigenvectors = np.linalg.eig(cov)
96
97    # Sort by eigenvalue (largest first)
98    idx = np.argsort(eigenvalues)[::-1]
99    eigenvalues = eigenvalues[idx]
100    eigenvectors = eigenvectors[:, idx]
101
102    print("\n1. COVARIANCE MATRIX:")
103    print(f"[[{cov[0,0]:.4f}, {cov[0,1]:.4f}]")
104    print(f" [{cov[1,0]:.4f}, {cov[1,1]:.4f}]]")
105
106    print("\n2. PRINCIPAL AXES (eigenvectors):")
107    print(f"PC1 direction: [{eigenvectors[0,0]:.4f}, {eigenvectors[1,0]:.4f}]")
108    print(f"PC2 direction: [{eigenvectors[0,1]:.4f}, {eigenvectors[1,1]:.4f}]")
109
110    # Convert to angle
111    angle_pc1 = np.degrees(np.arctan2(eigenvectors[1,0], eigenvectors[0,0]))
112    print(f"\nPC1 angle from x-axis: {angle_pc1:.1f}° (should be ~30°)")
113
114    print("\n3. PRINCIPAL MOMENTS (eigenvalues):")
115    print(f"I₁ (along PC1) = {eigenvalues[0]:.4f} (smallest resistance)")
116    print(f"I₂ (along PC2) = {eigenvalues[1]:.4f} (largest resistance)")
117
118    print("\n4. INTERPRETATION:")
119    print("Just like a rigid body:")
120    print("- PC1 = axis of MINIMUM moment of inertia")
121    print("- PC2 = axis of MAXIMUM moment of inertia")
122    print("- Objects 'prefer' to rotate about the axis with largest I")
123    print("- PCA finds the directions where data is most/least spread")
124
125    # Variance explained
126    total_var = np.sum(eigenvalues)
127    print(f"\nVariance explained by PC1: {100*eigenvalues[0]/total_var:.1f}%")
128    print(f"Variance explained by PC2: {100*eigenvalues[1]/total_var:.1f}%")
129
130    return eigenvalues, eigenvectors
131
132def regularization_as_inertia():
133    """
134    L2 regularization relates to moment of inertia!
135
136    L2 penalty = λ Σ wᵢ² = λ · I (moment about origin in weight space)
137
138    Regularization keeps the 'mass' of weights close to origin,
139    just like reducing moment of inertia makes rotation easier.
140    """
141    print("\n" + "=" * 60)
142    print("L2 REGULARIZATION = MOMENT OF INERTIA IN WEIGHT SPACE")
143    print("=" * 60)
144
145    # Compare two weight configurations
146    weights_spread = np.array([5, -4, 3, -3, 2, -2, 1, -1])
147    weights_compact = np.array([0.5, -0.4, 0.3, -0.3, 0.2, -0.2, 0.1, -0.1])
148
149    # L2 norm squared = moment of inertia about origin
150    I_spread = np.sum(weights_spread**2)
151    I_compact = np.sum(weights_compact**2)
152
153    print("\n1. TWO WEIGHT CONFIGURATIONS:")
154    print(f"Spread weights: {weights_spread}")
155    print(f"Compact weights: {weights_compact}")
156
157    print("\n2. L2 PENALTY (= Moment of Inertia about origin):")
158    print(f"I_spread = Σwᵢ² = {I_spread:.2f}")
159    print(f"I_compact = Σwᵢ² = {I_compact:.4f}")
160
161    print(f"\nRatio: {I_spread/I_compact:.1f}× larger for spread weights")
162
163    print("\n3. PHYSICAL INTERPRETATION:")
164    print("- Large weights = mass far from origin")
165    print("- Large L2 penalty = high 'rotational inertia' in weight space")
166    print("- Regularization = minimizing moment, keeping mass close to origin")
167    print("- This makes the model easier to 'spin' (generalize) in new directions")
168
169# Run demonstrations
170cov = covariance_as_moment_of_inertia()
171eigenvalues, eigenvectors = pca_as_principal_axes()
172regularization_as_inertia()

Common Mistakes to Avoid

Mistake 1: Forgetting to square the distance

The formula is I=mr2I = \sum mr^2, not mr\sum mr. The squared distance is crucial — it's why mass far from the axis matters so much more.

Mistake 2: Using the wrong distance

The distance rr must be the perpendicular distance to the axis, not the distance to a point on the axis. For rotation about the z-axis, use r=x2+y2r = \sqrt{x^2 + y^2}, not x2+y2+z2\sqrt{x^2 + y^2 + z^2}.

Mistake 3: Confusing different axes

The same object has different moments of inertia about different axes. A rod has I=112ML2I = \frac{1}{12}ML^2 about its center but I=13ML2I = \frac{1}{3}ML^2 about one end. Always specify the axis!

Mistake 4: Applying perpendicular axis theorem to 3D objects

The perpendicular axis theorem Iz=Ix+IyI_z = I_x + I_y only works for planar objects (2D laminas). It does not apply to 3D solids like spheres or cylinders.

Mistake 5: Misusing the parallel axis theorem

The parallel axis theorem requires that one of the axes passes through the center of mass. You cannot use it to relate moments about two arbitrary parallel axes directly — you must go through the center of mass.


Test Your Understanding

📝Moment of Inertia QuizQuestion 1 of 8
Progress0%

A point mass of 2 kg is located 3 m from the rotation axis. What is its moment of inertia?

Score: 0/0

Summary

The moment of inertia is the rotational analog of mass — it measures how difficult it is to change an object's rotational motion. Unlike mass, moment of inertia depends on the axis of rotation and how mass is distributed.

Key Formulas

ConceptFormulaNotes
Discrete MoII = Σmᵢrᵢ²Sum of mass × distance²
Continuous MoII = ∫r² dmIntegration over object
Parallel AxisI = I_cm + Md²d = distance between axes
Perpendicular AxisI_z = I_x + I_yPlanar objects only
Newton's 2nd (rotation)τ = IαTorque = MoI × angular accel
Angular momentumL = IωConserved without torque
Rotational KEE = ½Iω²Kinetic energy of rotation

Key Takeaways

  1. Moment of inertia is mass × distance², so mass far from the axis contributes much more than nearby mass.
  2. The parallel axis theorem relates moments about different parallel axes through the center of mass.
  3. The perpendicular axis theorem relates moments about three perpendicular axes for flat objects.
  4. Hollow objects have larger moments than solid objects of the same mass because their mass is farther from the axis.
  5. Conservation of angular momentum explains why skaters spin faster when pulling in their arms.
  6. The covariance matrix in ML is mathematically identical to the moment of inertia tensor — PCA finds principal axes!
The Core Insight:
"Moment of inertia tells us how mass distribution affects rotation. The same mathematics appears in statistics as covariance — whether you're spinning a disk or analyzing data, it's all about how things are spread out from a central axis."
Coming Next: In the next chapter, we'll explore Sequences — the foundation for understanding series, convergence, and the mathematical underpinnings of infinite processes.
Loading comments...