Applications in Physics and Engineering (Integration)
Learning Objectives
By the end of this section, you will be able to:
Understand the physical meaning of moment of inertia as rotational mass
Calculate moments of inertia for discrete point masses and continuous objects
Use integration to derive moment of inertia formulas for various shapes
Apply the parallel and perpendicular axis theorems
Analyze rotational dynamics using Newton's second law for rotation
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=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α
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 Motion
Symbol
Rotational Motion
Symbol
Position
x
Angle
θ
Velocity
v = dx/dt
Angular velocity
ω = dθ/dt
Acceleration
a = dv/dt
Angular acceleration
α = dω/dt
Mass
m
Moment of inertia
I
Force
F
Torque
τ
Momentum
p = mv
Angular momentum
L = Iω
Kinetic energy
½ mv²
Rotational KE
½ Iω²
Newton's 2nd Law
F = ma
Rotational 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,…,mn at perpendicular distances r1,r2,…,rn from the rotation axis:
Moment of Inertia (Discrete)
I=∑i=1nmiri2
Sum of (mass × perpendicular distance squared)
Why the Square?
The r2 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 1⋅12=1 kg·m²
A 1 kg mass at 2 m contributes 1⋅22=4 kg·m² — 4× more!
A 1 kg mass at 3 m contributes 1⋅32=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 increasesI:
🌀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 ρ (mass per unit length, area, or volume), we replace the sum with an integral:
Moment of Inertia (Continuous)
1D (rod): I=∫r2dm=∫r2ρ(x)dx
2D (lamina): I=∬r2dm=∬r2ρ(x,y)dA
3D (solid): I=∭r2dm=∭r2ρ(x,y,z)dV
where r 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 M and length L about an axis through its center, perpendicular to the rod.
Solution:
Place the rod along the x-axis from −L/2 to L/2, with the axis at the origin.
The linear density is λ=M/L. A small element at position x has mass dm=λdx=(M/L)dx.
Its perpendicular distance from the axis is r=∣x∣, but since we integrate r2=x2, the sign doesn't matter.
I=∫−L/2L/2x2⋅LMdx=LM⋅3x3−L/2L/2
=LM⋅31[8L3−(−8L3)]=LM⋅12L3
Icenter=121ML2
Common Shapes and Their Moments
Here are the moments of inertia for common shapes, all derived using integration:
Shape
Axis
Moment of Inertia
Notes
Point mass
At distance r
I = mr²
Definition
Rod (uniform)
Through center
I = (1/12)ML²
Perpendicular to rod
Rod (uniform)
Through end
I = (1/3)ML²
Perpendicular to rod
Thin ring
Through center
I = MR²
Perpendicular to plane
Solid disk
Through center
I = (1/2)MR²
Perpendicular to plane
Disk
Along diameter
I = (1/4)MR²
In plane of disk
Hollow cylinder
Central axis
I = MR²
All mass at radius R
Solid cylinder
Central axis
I = (1/2)MR²
Uniform distribution
Solid sphere
Any diameter
I = (2/5)MR²
Uniform density
Hollow sphere
Any diameter
I = (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 r2 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+Md2
where d is the distance between the axes, and Icm 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=d. For a point mass element at (x,y):
I=∫(x−d)2dm=∫(x2−2xd+d2)dm
=Icm∫x2dm−2d=0∫xdm+d2M∫dm=Icm+Md2
The middle term vanishes because ∫xdm=Mxˉ=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+Iy
where z is perpendicular to the plane, and x, y are in the plane
Proof
For a point at (x,y,0):
Ix=∫y2dm (moment about x-axis uses distance from x-axis, which is y)
Iy=∫x2dm (moment about y-axis uses distance from y-axis, which is x)
Iz=∫r2dm=∫(x2+y2)dm=Iy+Ix
Example: Disk About Diameter
For a uniform disk, we know Iz=21MR2 (perpendicular to the disk through center).
By symmetry, Ix=Iy (any two perpendicular diameters are equivalent).
Using the perpendicular axis theorem:
Iz=Ix+Iy=2Ix⟹Ix=2Iz=41MR2
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=121ML2=121(2)(1)2=61 kg·m²
Each mass: At distance r=L/2=0.5 m from the axis:
Imasses=2⋅m⋅r2=2(5)(0.5)2=2.5 kg·m²
Itotal=61+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=21MR2=21(3)(0.4)2=0.24 kg·m²
The new axis is at distance d=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.72 kg·m²
I=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α
For a given torque τ, 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=21Iω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ω is conserved when no external torque acts. When a skater pulls in their arms, I decreases, so ω must increase to keep L 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) with mean at the origin:
Covariance Matrix
Σ=(E[x2]E[xy]E[xy]E[y2])
Inertia Tensor
I=(IxxIxyIxyIyy)
The variance E[x2] measures how spread the data is from the y-axis — exactly like Iyy measures mass distribution from the y-axis!
PCA = Finding Principal Axes
In physics, principal axes are directions where the products of inertia (Ixy) 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 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
Explanation(8)
Code(215)
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
45defmoment_of_inertia_discrete(masses, distances):6"""
7 Compute moment of inertia for discrete point masses.
89 I = Σ mᵢ · rᵢ²
1011 Parameters:
12 -----------
13 masses : array - Mass values (kg)
14 distances : array - Perpendicular distances from axis (m)
1516 Returns:
17 --------
18 float : Moment of inertia (kg·m²)
19 """20 masses = np.array(masses)21 distances = np.array(distances)22return np.sum(masses * distances**2)2324defmoment_of_inertia_rod(mass, length, axis="center"):25"""
26 Moment of inertia of a uniform rod.
2728 About center: I = (1/12) M L²
29 About end: I = (1/3) M L²
3031 Parameters:
32 -----------
33 mass : float - Total mass (kg)
34 length : float - Length of rod (m)
35 axis : str - "center" or "end"
3637 Returns:
38 --------
39 float : Moment of inertia (kg·m²)
40 """41if axis =="center":42# I = ∫_{-L/2}^{L/2} (M/L) x² dx = (1/12) ML²43return(1/12)* mass * length**244elif axis =="end":45# I = ∫_0^L (M/L) x² dx = (1/3) ML²46return(1/3)* mass * length**247else:48raise ValueError("axis must be 'center' or 'end'")4950defmoment_of_inertia_disk(mass, radius, axis="perpendicular"):51"""
52 Moment of inertia of a uniform disk.
5354 Perpendicular to disk through center: I = (1/2) MR²
55 Along diameter: I = (1/4) MR²
5657 Parameters:
58 -----------
59 mass : float - Total mass (kg)
60 radius : float - Radius of disk (m)
61 axis : str - "perpendicular" or "diameter"
6263 Returns:
64 --------
65 float : Moment of inertia (kg·m²)
66 """67if axis =="perpendicular":68# Using polar coordinates: I = ∫∫ r² · ρ · r dr dθ69return(1/2)* mass * radius**270elif axis =="diameter":71return(1/4)* mass * radius**272else:73raise ValueError("axis must be 'perpendicular' or 'diameter'")7475defmoment_of_inertia_sphere(mass, radius, solid=True):76"""
77 Moment of inertia of a uniform sphere about any diameter.
7879 Solid sphere: I = (2/5) MR²
80 Hollow sphere: I = (2/3) MR²
8182 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
8788 Returns:
89 --------
90 float : Moment of inertia (kg·m²)
91 """92if solid:93return(2/5)* mass * radius**294else:95return(2/3)* mass * radius**29697defparallel_axis_theorem(I_cm, mass, d):98"""
99 Apply the parallel axis theorem.
100101 I = I_cm + M·d²
102103 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)
108109 Returns:
110 --------
111 float : Moment of inertia about new axis (kg·m²)
112 """113return I_cm + mass * d**2114115defmoment_of_inertia_custom(density_func, region_bounds, axis_func):116"""
117 Compute moment of inertia via numerical integration.
118119 I = ∬ r² · ρ(x, y) dA
120121 where r = distance from point to axis
122123 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)
128129 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"]135136# Moment of inertia integrand: r² · ρ137defI_integrand(y, x):138 r = axis_func(x, y)139return r**2* density_func(x, y)140141# Mass integrand142defmass_integrand(y, x):143return density_func(x, y)144145# Compute integrals146 I, _ = integrate.dblquad(147 I_integrand,148 x_min, x_max,149 y_func_min, y_func_max
150)151152 M, _ = integrate.dblquad(153 mass_integrand,154 x_min, x_max,155 y_func_min, y_func_max
156)157158return I, M
159160# Example demonstrations161print("="*60)162print("MOMENT OF INERTIA CALCULATIONS")163print("="*60)164165# Example 1: Discrete masses166print("\n1. DISCRETE POINT MASSES")167print("-"*40)168masses =[2,3,1,4]# kg169distances =[0.5,1.0,1.5,2.0]# m from axis170171I_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²")175176# Verify by hand:177manual =sum(m * r**2for m, r inzip(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²")180181# Example 2: Uniform rod182print("\n2. UNIFORM ROD (M = 2 kg, L = 1 m)")183print("-"*40)184M_rod, L_rod =2.0,1.0185186I_center = moment_of_inertia_rod(M_rod, L_rod,"center")187I_end = moment_of_inertia_rod(M_rod, L_rod,"end")188189print(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²")191192# Verify with parallel axis theorem193I_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²")196197# Example 3: Disk vs Ring198print("\n3. DISK VS RING (M = 1 kg, R = 0.5 m)")199print("-"*40)200M_disk, R_disk =1.0,0.5201202I_disk = moment_of_inertia_disk(M_disk, R_disk,"perpendicular")203I_ring = M_disk * R_disk**2# All mass at distance R204205print(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")208209# Example 4: Parallel axis theorem210print("\n4. PARALLEL AXIS THEOREM")211print("-"*40)212print("Disk rotating about axis 1 m from center:")213d =1.0214I_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
Explanation(6)
Code(172)
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
34defcovariance_as_moment_of_inertia():5"""
6 The COVARIANCE MATRIX is the moment of inertia tensor for data!
78 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)
1213 This is EXACTLY the structure of moment of inertia calculations!
14 """15print("="*60)16print("COVARIANCE MATRIX = MOMENT OF INERTIA TENSOR")17print("="*60)1819# Generate 2D data20 np.random.seed(42)21 n_points =10002223# 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)2829 x, y = data[:,0], data[:,1]3031# Compute covariance matrix32 cov_computed = np.cov(data.T)3334print("\n1. COVARIANCE MATRIX (data analogy)")35print("-"*40)36print(f"Σ_xx (variance in x) = E[x²] = {cov_computed[0,0]:.4f}")37print(f"Σ_yy (variance in y) = E[y²] = {cov_computed[1,1]:.4f}")38print(f"Σ_xy (covariance) = E[xy] = {cov_computed[0,1]:.4f}")3940print("\n2. MOMENT OF INERTIA INTERPRETATION")41print("-"*40)4243# If we treat each data point as a unit mass:44# I_xx = Σ y_i² = moment about x-axis45# I_yy = Σ x_i² = moment about y-axis46# I_xy = -Σ x_i y_i = product of inertia4748 I_xx = np.sum(y**2)/ n_points # = Σ_yy49 I_yy = np.sum(x**2)/ n_points # = Σ_xx50 I_xy =-np.sum(x * y)/ n_points # = -Σ_xy5152print(f"I_xx (moment about x-axis) = Σy²/n = {I_xx:.4f}")53print(f"I_yy (moment about y-axis) = Σx²/n = {I_yy:.4f}")54print(f"I_xy (product of inertia) = -Σxy/n = {I_xy:.4f}")5556print("\nNotice: I_xx = Σ_yy and I_yy = Σ_xx (swapped!)")57print("This is because moment uses perpendicular distance.")5859return cov_computed
6061defpca_as_principal_axes():62"""
63 PCA finds the PRINCIPAL AXES of inertia for data!
6465 Just as a rigid body has principal axes where I_xy = 0,
66 PCA finds directions where covariance = 0 (uncorrelated).
6768 The eigenvalues are the moments of inertia about each axis.
69 The eigenvectors are the principal axis directions.
70 """71print("\n"+"="*60)72print("PCA = FINDING PRINCIPAL AXES OF INERTIA")73print("="*60)7475# Generate correlated data76 np.random.seed(42)77 n_points =5007879# Create elongated ellipse80 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)8384# Rotate by 30 degrees85 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)8889 data = np.column_stack([x, y])9091# Compute covariance92 cov = np.cov(data.T)9394# Find principal axes (eigendecomposition)95 eigenvalues, eigenvectors = np.linalg.eig(cov)9697# Sort by eigenvalue (largest first)98 idx = np.argsort(eigenvalues)[::-1]99 eigenvalues = eigenvalues[idx]100 eigenvectors = eigenvectors[:, idx]101102print("\n1. COVARIANCE MATRIX:")103print(f"[[{cov[0,0]:.4f}, {cov[0,1]:.4f}]")104print(f" [{cov[1,0]:.4f}, {cov[1,1]:.4f}]]")105106print("\n2. PRINCIPAL AXES (eigenvectors):")107print(f"PC1 direction: [{eigenvectors[0,0]:.4f}, {eigenvectors[1,0]:.4f}]")108print(f"PC2 direction: [{eigenvectors[0,1]:.4f}, {eigenvectors[1,1]:.4f}]")109110# Convert to angle111 angle_pc1 = np.degrees(np.arctan2(eigenvectors[1,0], eigenvectors[0,0]))112print(f"\nPC1 angle from x-axis: {angle_pc1:.1f}° (should be ~30°)")113114print("\n3. PRINCIPAL MOMENTS (eigenvalues):")115print(f"I₁ (along PC1) = {eigenvalues[0]:.4f} (smallest resistance)")116print(f"I₂ (along PC2) = {eigenvalues[1]:.4f} (largest resistance)")117118print("\n4. INTERPRETATION:")119print("Just like a rigid body:")120print("- PC1 = axis of MINIMUM moment of inertia")121print("- PC2 = axis of MAXIMUM moment of inertia")122print("- Objects 'prefer' to rotate about the axis with largest I")123print("- PCA finds the directions where data is most/least spread")124125# Variance explained126 total_var = np.sum(eigenvalues)127print(f"\nVariance explained by PC1: {100*eigenvalues[0]/total_var:.1f}%")128print(f"Variance explained by PC2: {100*eigenvalues[1]/total_var:.1f}%")129130return eigenvalues, eigenvectors
131132defregularization_as_inertia():133"""
134 L2 regularization relates to moment of inertia!
135136 L2 penalty = λ Σ wᵢ² = λ · I (moment about origin in weight space)
137138 Regularization keeps the 'mass' of weights close to origin,
139 just like reducing moment of inertia makes rotation easier.
140 """141print("\n"+"="*60)142print("L2 REGULARIZATION = MOMENT OF INERTIA IN WEIGHT SPACE")143print("="*60)144145# Compare two weight configurations146 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])148149# L2 norm squared = moment of inertia about origin150 I_spread = np.sum(weights_spread**2)151 I_compact = np.sum(weights_compact**2)152153print("\n1. TWO WEIGHT CONFIGURATIONS:")154print(f"Spread weights: {weights_spread}")155print(f"Compact weights: {weights_compact}")156157print("\n2. L2 PENALTY (= Moment of Inertia about origin):")158print(f"I_spread = Σwᵢ² = {I_spread:.2f}")159print(f"I_compact = Σwᵢ² = {I_compact:.4f}")160161print(f"\nRatio: {I_spread/I_compact:.1f}× larger for spread weights")162163print("\n3. PHYSICAL INTERPRETATION:")164print("- Large weights = mass far from origin")165print("- Large L2 penalty = high 'rotational inertia' in weight space")166print("- Regularization = minimizing moment, keeping mass close to origin")167print("- This makes the model easier to 'spin' (generalize) in new directions")168169# Run demonstrations170cov = 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=∑mr2, not ∑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 r 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+y2, not x2+y2+z2.
Mistake 3: Confusing different axes
The same object has different moments of inertia about different axes. A rod has I=121ML2 about its center but I=31ML2 about one end. Always specify the axis!
Mistake 4: Applying perpendicular axis theorem to 3D objects
The perpendicular axis theorem Iz=Ix+Iy 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
Concept
Formula
Notes
Discrete MoI
I = Σmᵢrᵢ²
Sum of mass × distance²
Continuous MoI
I = ∫r² dm
Integration over object
Parallel Axis
I = I_cm + Md²
d = distance between axes
Perpendicular Axis
I_z = I_x + I_y
Planar objects only
Newton's 2nd (rotation)
τ = Iα
Torque = MoI × angular accel
Angular momentum
L = Iω
Conserved without torque
Rotational KE
E = ½Iω²
Kinetic energy of rotation
Key Takeaways
Moment of inertia is mass × distance², so mass far from the axis contributes much more than nearby mass.
The parallel axis theorem relates moments about different parallel axes through the center of mass.
The perpendicular axis theorem relates moments about three perpendicular axes for flat objects.
Hollow objects have larger moments than solid objects of the same mass because their mass is farther from the axis.
Conservation of angular momentum explains why skaters spin faster when pulling in their arms.
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.