Chapter 11
18 min read
Section 101 of 353

Work Done by Variable Forces

Applications in Physics and Engineering (Integration)

Learning Objectives

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

  1. Derive and apply the work integral W=abF(x)dxW = \int_a^b F(x) \, dx for forces that vary with position
  2. Calculate gravitational work at large distances where the constant-g approximation fails
  3. Apply Coulomb's law to compute electrical work moving charged particles
  4. Analyze velocity-dependent forces such as air resistance and fluid drag
  5. Connect work to potential energy for conservative force fields
  6. Recognize the deep analogy between physical work and optimization in machine learning

The Big Picture: When Forces Aren't Constant

"In the real physical world, forces almost always vary—with position, velocity, time, or configuration. The integral is our tool for handling this complexity."

In introductory physics, we often treat forces as constant: the weight of an object near Earth's surface, the tension in a rope, the normal force from a floor. This simplification lets us use W=FdW = Fd. But nature rarely offers such simplicity.

Consider these real-world scenarios where force varies:

Physical SystemForce VariationMathematical Form
Gravity at altitudeWeakens with distanceF = GMm/r²
Electric chargesInverse square lawF = kq₁q₂/r²
SpringsProportional to stretchF = kx
Air resistanceDepends on velocityF = ½ρC_dAv²
Magnetic forceVaries with positionF = qv × B(r)
Molecular bondsComplex potentialF = -dU/dr

In every case, the elementary formula W=FdW = Fd fails because FF changes throughout the motion. We must integrate to account for how force varies along the path.

The Essential Insight

When force varies with position, work becomes an integral: W=abF(x)dxW = \int_a^b F(x) \, dx. This computes the accumulated effect of a continuously changing force—the sum of infinitely many infinitesimal contributions dW=F(x)dxdW = F(x) \, dx.


Historical Development: From Newton to Modern Physics

The concept of work as we understand it today emerged from the interplay of mechanics, thermodynamics, and calculus in the 17th-19th centuries.

Newton and the Inverse Square Law (1687)

Isaac Newton's Principia Mathematica established that gravitational force follows an inverse square law: F=GMmr2F = \frac{GMm}{r^2}. This immediately raised the question: how much work is required to move an object from one distance to another in such a field?

Newton himself developed the tools (calculus) needed to answer this question, showing that:

W=r1r2GMmr2dr=GMm(1r11r2)W = \int_{r_1}^{r_2} \frac{GMm}{r^2} \, dr = GMm \left( \frac{1}{r_1} - \frac{1}{r_2} \right)

Coulomb and Electrical Forces (1785)

Charles-Augustin de Coulomb demonstrated that electrical forces also follow an inverse square law: F=kq1q2r2F = k\frac{q_1 q_2}{r^2}. This meant the same mathematical machinery developed for gravity applied directly to electrostatics.

The Energy Revolution (1840s-1850s)

James Joule, Hermann von Helmholtz, and others established the conservation of energy, showing that work done against a force is stored as potential energy. This profound insight—that W=ΔUW = \Delta U for conservative forces—unified mechanics with thermodynamics.

Why This History Matters

Understanding that W=FdxW = \int F \, dx arose from studying real physical systems (planetary motion, electric charges) helps us appreciate why calculus is the language of physics. The integral isn't an abstract mathematical construct—it's the precise tool needed to describe how nature accumulates effects.


The Work Integral: Mathematical Foundation

Let's establish the work integral rigorously. Consider a force F(x)F(x) acting on an object as it moves along the x-axis from position aa to bb.

Derivation from First Principles

  1. Partition the path: Divide [a,b][a, b] into nn small intervals of width Δx=(ba)/n\Delta x = (b-a)/n
  2. Approximate force as constant on each interval: On the ii-th interval, take F(xi)F(x_i^*) as the force value
  3. Compute work on each piece: ΔWiF(xi)Δx\Delta W_i \approx F(x_i^*) \Delta x
  4. Sum all contributions: Wi=1nF(xi)ΔxW \approx \sum_{i=1}^n F(x_i^*) \Delta x
  5. Take the limit: As nn \to \infty, the Riemann sum becomes a definite integral

The Work Integral

W=abF(x)dxW = \int_a^b F(x) \, dx

Work equals the definite integral of force over the path of motion

Geometric Interpretation

The work integral has a beautiful geometric meaning: work equals the signed area under the force-position curve.

  • When F(x)>0F(x) > 0 and motion is in the positive direction: positive work (force assists motion)
  • When F(x)<0F(x) < 0 and motion is in the positive direction: negative work (force opposes motion)

Gravitational Work at Large Distances

Near Earth's surface, we approximate gravity as constant: F=mgF = mg with g9.8g \approx 9.8 m/s². But for space missions, satellites, and planetary science, we must use Newton's Law of Universal Gravitation:

F(r)=GMmr2F(r) = \frac{GMm}{r^2}

where GG is the gravitational constant, MM is the planet's mass, mm is the object's mass, and rr is the distance from the planet's center

Work to Reach Altitude h

To lift an object from the surface (radius RR) to altitude hh above the surface:

W=RR+hGMmr2drW = \int_R^{R+h} \frac{GMm}{r^2} \, dr
=GMm[1r]RR+h= GMm \left[ -\frac{1}{r} \right]_R^{R+h}
=GMm(1R1R+h)= GMm \left( \frac{1}{R} - \frac{1}{R+h} \right)

Comparison with W = mgh

For small altitudes (hRh \ll R), we can show that this reduces to WmghW \approx mgh. But for hRh \sim R or larger, the full integral is necessary. The approximation W=mghW = mgh overestimates work by increasingly large amounts as altitude grows.

Escape Velocity Derivation

A fascinating application: what velocity is needed to escape a planet's gravity entirely? We need enough kinetic energy to do work against gravity from RR to \infty:

Wescape=RGMmr2dr=GMmRW_{escape} = \int_R^{\infty} \frac{GMm}{r^2} \, dr = \frac{GMm}{R}

Setting 12mvescape2=Wescape\frac{1}{2}mv_{escape}^2 = W_{escape}:

vescape=2GMR=2gRv_{escape} = \sqrt{\frac{2GM}{R}} = \sqrt{2gR}

For Earth, this gives vescape11.2v_{escape} \approx 11.2 km/s—the speed required to leave Earth's gravitational influence without further propulsion.

Interactive: Gravitational Work

Explore how gravitational work varies with altitude. Notice how the constant-g approximation increasingly fails at higher altitudes:

Gravitational Work Visualizer

Calculations:
Work to reach altitude:3.695 GJ
Escape velocity (surface):11.18 km/s
Orbital velocity (at altitude):7.67 km/s
Work per kg:3.695 MJ/kg
Key Formula: W = GMm(1/R - 1/(R+h)) where R is planet radius and h is altitude.

Electromagnetic Work

Electric forces between charged particles follow Coulomb's Law:

F=kq1q2r2F = k\frac{q_1 q_2}{r^2}

where k8.99×109k \approx 8.99 \times 10^9 N·m²/C² is Coulomb's constant

The key difference from gravity: sign matters. Unlike mass (always positive), charge can be positive or negative, leading to both attractive and repulsive forces.

Work Moving a Charge

To move charge q2q_2 from distance r1r_1 to r2r_2 from fixed charge q1q_1:

W=r1r2kq1q2r2dr=kq1q2(1r11r2)W = \int_{r_1}^{r_2} \frac{kq_1 q_2}{r^2} \, dr = kq_1 q_2 \left( \frac{1}{r_1} - \frac{1}{r_2} \right)

Interpretation by charge signs:

ChargesForceMoving ApartMoving Together
Same sign (+/+ or -/-)RepulsiveW > 0 (field helps)W < 0 (work against)
Opposite sign (+/-)AttractiveW < 0 (work against)W > 0 (field helps)

Interactive: Coulomb Force Work

Experiment with different charge configurations and see how the work depends on both the charges and the path:

Coulomb Force Work Visualizer

Results:
Force type:Attractive
Work done:-71.9200 mJ
\u0394PE:+71.9200 mJ
Key Formula: W = kq\u2081q\u2082(1/r\u2081 - 1/r\u2082). Work done BY the field, not against it.

Variable Friction and Drag Forces

Many real-world forces depend on velocity rather than (or in addition to) position. The most important example is fluid drag:

Fdrag=12ρCdAv2F_{drag} = \frac{1}{2} \rho C_d A v^2

where ρ\rho = fluid density, CdC_d = drag coefficient, AA = frontal area, vv = velocity

Why v² Matters

The v2v^2 dependence has profound implications:

  • Doubling speed quadruples the drag force
  • Power required to overcome drag scales as P=Fvv3P = Fv \propto v^3
  • Fuel efficiency at highway speeds is dominated by aerodynamic drag
  • Terminal velocity occurs when drag equals weight: vt=2mg/(ρCdA)v_t = \sqrt{2mg/(\rho C_d A)}

Work Against Drag at Constant Velocity

If an object moves at constant velocity vv for distance dd:

W=Fdragd=12ρCdAv2dW = F_{drag} \cdot d = \frac{1}{2} \rho C_d A v^2 \cdot d

This is the energy that must be supplied (e.g., by an engine) to maintain constant speed against air resistance.

Interactive: Drag Force Work

See how drag force and the work required scale with velocity, drag coefficient, and distance:

Drag Force Work Visualizer

Results:
Drag Force:551.3 N
Work against drag:55.13 kJ
Power required:16.54 kW
Power (horsepower):22.2 hp
Key Formula: F_drag = \u00BD\u03C1C_dAv\u00B2. Note the v\u00B2 dependence!

Work and Potential Energy

For certain special forces—conservative forces—the work done depends only on the starting and ending positions, not on the path taken. This leads to the concept of potential energy.

Conservative Forces

A force is conservative if:

  1. Work done around any closed path is zero: Fdr=0\oint F \cdot dr = 0
  2. Work depends only on endpoints, not the path between them
  3. The force can be written as the gradient of a scalar potential: F=U\vec{F} = -\nabla U

Examples of conservative forces:

ForcePotential Energy U(r)
Gravity (near surface)U = mgh
Gravity (universal)U = -GMm/r
Coulomb (electrostatic)U = kq₁q₂/r
Spring (Hooke’s law)U = ½kx²

The Work-Energy Connection

For conservative forces:

W=ΔU=U(r1)U(r2)W = -\Delta U = U(r_1) - U(r_2)

Work done BY the force equals the DECREASE in potential energy

This is incredibly powerful: instead of computing an integral, we can simply evaluate the potential at the endpoints. The integral is "already done" when we define UU.

Non-Conservative Forces

Friction and drag are not conservative. Work done against them depends on the path length, not just endpoints. Energy "lost" to friction becomes thermal energy—it dissipates into the environment rather than being stored as potential energy.


Machine Learning Connection: Optimization as Physics

There is a profound and beautiful analogy between physical work and machine learning optimization that goes far beyond metaphor.

The Loss-Energy Correspondence

Physics ConceptMachine Learning Analog
Position xParameters θ
Potential energy U(x)Loss function L(θ)
Force F = -∇UNegative gradient -∇L
Work W = ∫F·dxCumulative loss decrease
Equilibrium (F = 0)Optimum (∇L = 0)
Rolling downhillGradient descent
MomentumMomentum optimizer
Friction/dampingLearning rate decay

This isn't just an analogy—modern optimizers like SGD with momentum literally implement the physics equations of motion in parameter space!

Gradient Descent as Energy Minimization

Each gradient descent step moves parameters "downhill" on the loss landscape:

Δθ=ηθL\Delta\theta = -\eta \nabla_\theta L

The "work" done in one step is:

ΔLLΔθ=ηL20\Delta L \approx \nabla L \cdot \Delta\theta = -\eta \|\nabla L\|^2 \leq 0

This guarantees loss decreases (for small enough η\eta)—just like a ball always rolls downhill!

Why This Matters

Understanding optimization as physics helps us:

  • Intuit why momentum helps escape shallow local minima (physical inertia)
  • Understand why learning rate schedules work (controlled cooling, like simulated annealing)
  • Design better optimizers using physics principles
  • Debug training by visualizing "energy landscapes"

Python Implementation

Gravitational Work Analysis

This code compares exact gravitational work calculations with the constant-g approximation:

Gravitational Work Calculation
🐍gravitational_work.py
10Physical Constants

G is Newton&apos;s gravitational constant. These values define Earth&apos;s gravitational field strength at any distance.

17Inverse Square Law

Gravitational force follows the inverse square law: F = GMm/r². This is why gravity weakens with distance.

27Analytical Work Formula

Integrating F = GMm/r² from R to R+h gives W = GMm(1/R - 1/(R+h)). This is exact, unlike the W = mgh approximation.

33Constant g Approximation

Near the surface, g ≈ 9.8 m/s² is nearly constant. The approximation W = mgh works well for h << R.

55Escape Velocity

Setting kinetic energy ½mv² equal to gravitational potential energy GMm/R gives the escape velocity formula.

67 lines without explanation
1import numpy as np
2from scipy import integrate
3import matplotlib.pyplot as plt
4
5def gravitational_work_analysis():
6    """
7    Calculate work done against gravity at varying distances.
8
9    Key insight: Near Earth's surface, F ≈ mg (constant).
10    At large distances, F = GMm/r² varies significantly.
11    """
12    G = 6.674e-11  # Gravitational constant (N·m²/kg²)
13    M_earth = 5.97e24  # Earth mass (kg)
14    R_earth = 6.371e6  # Earth radius (m)
15
16    def gravitational_force(r, m=1000):
17        """Force on mass m at distance r from Earth's center"""
18        return G * M_earth * m / (r ** 2)
19
20    def work_to_altitude(h, m=1000):
21        """
22        Work to lift mass m from surface to altitude h.
23        W = ∫[R to R+h] F(r) dr = GMm(1/R - 1/(R+h))
24        """
25        # Numerical integration
26        result, _ = integrate.quad(gravitational_force, R_earth, R_earth + h, args=(m,))
27        return result
28
29    def work_analytical(h, m=1000):
30        """Analytical solution: W = GMm(1/R - 1/(R+h))"""
31        return G * M_earth * m * (1/R_earth - 1/(R_earth + h))
32
33    # Compare constant g approximation vs exact
34    altitudes = np.linspace(0, 1e7, 100)  # 0 to 10,000 km
35    m = 1000  # 1000 kg payload
36    g_surface = G * M_earth / R_earth**2  # ~9.8 m/s²
37
38    work_exact = [work_analytical(h, m) for h in altitudes]
39    work_approx = [m * g_surface * h for h in altitudes]  # W = mgh
40
41    # Percent error
42    errors = [(exact - approx) / exact * 100
43              for exact, approx in zip(work_exact, work_approx)
44              if exact > 0]
45
46    print("Gravitational Work Analysis")
47    print("=" * 50)
48    print(f"Mass: {m} kg")
49    print(f"Surface gravity: {g_surface:.4f} m/s²")
50    print()
51    print("Altitude (km) | Exact (MJ) | W=mgh (MJ) | Error (%)")
52    print("-" * 50)
53
54    test_altitudes = [100e3, 400e3, 1000e3, 5000e3, 35786e3]  # LEO, ISS, various, GEO
55    for h in test_altitudes:
56        W_exact = work_analytical(h, m) / 1e6
57        W_approx = m * g_surface * h / 1e6
58        error = (W_approx - W_exact) / W_exact * 100
59        print(f"{h/1e3:>10.0f} | {W_exact:>10.2f} | {W_approx:>10.2f} | {error:>8.1f}%")
60
61    # Escape velocity derivation
62    print()
63    print("Escape Velocity Derivation:")
64    print("=" * 50)
65    print("Work to escape = ∫[R to ∞] GMm/r² dr = GMm/R")
66    W_escape = G * M_earth * m / R_earth
67    v_escape = np.sqrt(2 * G * M_earth / R_earth)
68    print(f"Work to escape (1000 kg): {W_escape/1e9:.3f} GJ")
69    print(f"Escape velocity: {v_escape/1000:.3f} km/s")
70    print(f"Verification: ½mv² = {0.5 * m * v_escape**2 / 1e9:.3f} GJ")
71
72gravitational_work_analysis()

Electromagnetic Work

Calculate work for various electrostatic scenarios:

Electromagnetic Work Examples
🐍electromagnetic_work.py
8Coulomb&apos;s Law

The electric force between charges follows the same inverse square law as gravity, but can be attractive or repulsive depending on charge signs.

18Work by Electric Field

When the field does positive work, it means the force and displacement are aligned. The field &apos;helps&apos; the motion.

42Ionization Energy

Moving an electron from the Bohr radius to infinity requires work against the attractive Coulomb force. This equals the binding energy.

50Uniform Field (Capacitor)

In a uniform field (like inside a parallel plate capacitor), work is simply W = qEd, since F = qE is constant.

70 lines without explanation
1import numpy as np
2from scipy import integrate
3
4def electromagnetic_work():
5    """
6    Work done by/against electromagnetic forces.
7
8    Coulomb's Law: F = kq₁q₂/r²
9    Similar to gravity but can be attractive OR repulsive.
10    """
11    k = 8.99e9  # Coulomb constant (N·m²/C²)
12    e = 1.6e-19  # Elementary charge (C)
13
14    def coulomb_force(r, q1, q2):
15        """Force between two point charges"""
16        return k * q1 * q2 / (r ** 2)
17
18    def work_moving_charge(r1, r2, q1, q2):
19        """
20        Work done BY the electric field moving q2 from r1 to r2.
21        W = kq₁q₂(1/r₁ - 1/r₂)
22
23        Note:
24        - If q1·q2 > 0 (repulsive): Moving apart → field does positive work
25        - If q1·q2 < 0 (attractive): Moving apart → field does negative work
26        """
27        return k * q1 * q2 * (1/r1 - 1/r2)
28
29    print("Electromagnetic Work Examples")
30    print("=" * 55)
31
32    # Example 1: Two protons
33    print("\n1. Two protons (repulsive)")
34    q_proton = e
35    r1, r2 = 1e-10, 2e-10  # 1 Å to 2 Å
36    W = work_moving_charge(r1, r2, q_proton, q_proton)
37    print(f"   Moving from {r1*1e10:.1f} Å to {r2*1e10:.1f} Å")
38    print(f"   Work by field: {W:.4e} J = {W/e:.4f} eV")
39    print(f"   (Positive: field pushes protons apart)")
40
41    # Example 2: Electron-proton
42    print("\n2. Electron and proton (attractive)")
43    W = work_moving_charge(r1, r2, q_proton, -e)
44    print(f"   Moving electron from {r1*1e10:.1f} Å to {r2*1e10:.1f} Å")
45    print(f"   Work by field: {W:.4e} J = {W/e:.4f} eV")
46    print(f"   (Negative: must do work AGAINST field to separate)")
47
48    # Example 3: Ionization energy of hydrogen
49    print("\n3. Hydrogen ionization (removing electron to infinity)")
50    r_bohr = 5.29e-11  # Bohr radius
51    W_ionize = work_moving_charge(r_bohr, float('inf'), q_proton, -e)
52    print(f"   Work to remove electron: {-W_ionize:.4e} J = {-W_ionize/e:.2f} eV")
53    print(f"   (13.6 eV is the hydrogen ionization energy)")
54
55    # Example 4: Work in a capacitor
56    print("\n4. Work moving charge in uniform electric field (capacitor)")
57    E = 1e6  # Electric field 1 MV/m
58    d = 0.001  # 1 mm gap
59    q = 1e-9  # 1 nC charge
60    W_capacitor = q * E * d
61    print(f"   Field: {E/1e6} MV/m, Gap: {d*1000} mm, Charge: {q*1e9} nC")
62    print(f"   Work = qEd = {W_capacitor*1e6:.3f} μJ")
63
64    # Connection to potential energy
65    print("\n" + "=" * 55)
66    print("Work-Energy Connection:")
67    print("-" * 55)
68    print("W_by_field = -ΔU (work by field = decrease in potential energy)")
69    print("W_against_field = +ΔU (work against field = increase in PE)")
70    print()
71    print("For electric field: U = kq₁q₂/r")
72    print("For gravity:        U = -GMm/r (note the minus sign convention)")
73
74electromagnetic_work()

Optimization as Physical Work

Explore the deep connection between ML optimization and physical work:

ML Optimization as Physics
🐍optimization_physics.py
10The Deep Analogy

Loss functions behave like potential energy surfaces. Neural network training is like finding the lowest point in a rugged mountain landscape.

29Force = Negative Gradient

Just as physical force points toward lower energy, the negative gradient points toward lower loss. Nature and optimization both seek minima.

47Work in ML

Each gradient step does &apos;work&apos; proportional to ||∇L||². The total work equals the loss decrease—conservation of energy in parameter space!

81Physics-ML Correspondence

This table shows how every physics concept has an ML analog. Momentum optimizers literally use physics momentum equations!

103Non-Convex Optimization

Real neural network losses are highly non-convex. Like in physics with friction, the path matters—different initializations find different minima.

115 lines without explanation
1import numpy as np
2
3def optimization_as_work():
4    """
5    Machine Learning Connection: Optimization as 'Work' in Parameter Space
6
7    Deep analogy between physics and ML:
8    - Loss function L(θ) ↔ Potential energy U(x)
9    - Gradient ∇L ↔ Force F = -∇U
10    - Parameter update Δθ ↔ Displacement dx
11    - Learning = moving 'downhill' in loss landscape
12    """
13    print("Optimization as Physical Work")
14    print("=" * 55)
15
16    # Simple quadratic loss (like mean squared error)
17    def loss(theta):
18        """L(θ) = (θ - θ*)²  where θ* = 2 is optimal"""
19        theta_star = 2.0
20        return (theta - theta_star) ** 2
21
22    def gradient(theta):
23        """∇L = 2(θ - θ*)"""
24        theta_star = 2.0
25        return 2 * (theta - theta_star)
26
27    def force(theta):
28        """'Force' = -∇L (points toward minimum)"""
29        return -gradient(theta)
30
31    # Gradient descent
32    theta = 0.0  # Start far from optimum
33    lr = 0.1  # Learning rate
34
35    print("\nGradient Descent as 'Rolling Downhill':")
36    print("-" * 55)
37    print(f"{'Step':>4} | {'θ':>8} | {'L(θ)':>10} | {'∇L':>10} | {'F=-∇L':>10} | {'Δθ':>8}")
38    print("-" * 55)
39
40    total_work = 0
41    for step in range(10):
42        L = loss(theta)
43        grad = gradient(theta)
44        F = force(theta)
45        delta_theta = -lr * grad  # This is the 'displacement'
46
47        # Work done in this step: W = F · Δx
48        # In ML: 'work' ≈ -∇L · Δθ = lr * ||∇L||²
49        work_step = F * delta_theta  # Actually equals lr * grad²
50        total_work += work_step
51
52        print(f"{step:>4} | {theta:>8.4f} | {L:>10.4f} | {grad:>10.4f} | {F:>10.4f} | {delta_theta:>8.4f}")
53
54        theta = theta + delta_theta
55
56    print("-" * 55)
57    print(f"\nTotal 'work' done (accumulated ΔL): {total_work:.4f}")
58    print(f"Initial loss - Final loss: {loss(0.0) - loss(theta):.4f}")
59    print("(These are approximately equal!)")
60
61    # The deep connection
62    print("\n" + "=" * 55)
63    print("The Physics-ML Correspondence:")
64    print("-" * 55)
65    print()
66    print("Physics                  | Machine Learning")
67    print("-" * 55)
68    print("Position x               | Parameters θ")
69    print("Potential U(x)           | Loss L(θ)")
70    print("Force F = -∇U            | Negative gradient -∇L")
71    print("Work W = ∫F·dx           | Cumulative loss decrease")
72    print("Equilibrium (F=0)        | Optimum (∇L=0)")
73    print("Rolling downhill         | Gradient descent")
74    print("Momentum                 | Momentum optimizer")
75    print("Friction/damping         | Learning rate decay")
76    print()
77    print("Key insight: SGD is simulating physics in parameter space!")
78
79def path_integral_loss():
80    """
81    For non-convex losses, the 'work' depends on the path taken.
82    This is like non-conservative forces in physics.
83    """
84    print("\n" + "=" * 55)
85    print("Path Dependence in Non-Convex Optimization")
86    print("=" * 55)
87
88    # Non-convex loss with multiple minima
89    def loss_2d(x, y):
90        """Rastrigin-like function with multiple local minima"""
91        return x**2 + y**2 + 10*(2 - np.cos(2*np.pi*x) - np.cos(2*np.pi*y))
92
93    def gradient_2d(x, y):
94        """Gradient of the loss"""
95        dx = 2*x + 10 * 2*np.pi * np.sin(2*np.pi*x)
96        dy = 2*y + 10 * 2*np.pi * np.sin(2*np.pi*y)
97        return np.array([dx, dy])
98
99    # Two different starting points, same target
100    starts = [(2.0, 2.0), (-2.0, -2.0)]
101
102    print("\nSame target, different paths:")
103    for start in starts:
104        theta = np.array(start)
105        lr = 0.001  # Small learning rate for this bumpy landscape
106
107        loss_history = [loss_2d(*theta)]
108        for _ in range(500):
109            grad = gradient_2d(*theta)
110            theta = theta - lr * grad
111            loss_history.append(loss_2d(*theta))
112
113        total_decrease = loss_history[0] - loss_history[-1]
114        print(f"  Start: {start} → Final loss: {loss_history[-1]:.4f}, ΔL = {total_decrease:.4f}")
115
116    print("\nIn non-convex landscapes, 'work' (loss decrease) depends on path!")
117    print("This is why initialization and learning rate scheduling matter.")
118
119optimization_as_work()
120path_integral_loss()

Engineering Applications

Aerospace Engineering

Calculating the energy (and fuel) required for orbital maneuvers requires precise gravitational work calculations:

  • Hohmann transfers: Moving between circular orbits requires work against varying gravitational force
  • Delta-v budgets: Mission planning relies on work integrals to compute velocity changes
  • Atmospheric entry: Drag work converts kinetic energy to heat during reentry

Electrical Engineering

  • Particle accelerators: Work done on charged particles by electric fields
  • Electrostatic motors: Work done rotating charged components in electric fields
  • Capacitor energy: W=12CV2W = \frac{1}{2}CV^2 comes from integrating work to move charge

Automotive Engineering

  • Fuel efficiency: Work against drag dominates at highway speeds
  • Regenerative braking: Recapturing kinetic energy by doing negative work
  • Suspension design: Spring work during compression and extension

Common Mistakes to Avoid

Mistake 1: Using W = mgh at Large Distances

Wrong: Using W=mghW = mgh for satellite orbits or space missions.

Correct: Use W=GMm(1/R1/(R+h))W = GMm(1/R - 1/(R+h)) when altitude is comparable to Earth's radius.

Mistake 2: Forgetting Sign Conventions

Wrong: Confusing work done BY a force with work done AGAINST a force.

Correct: Work by the field: Wby=ΔUW_{by} = -\Delta U. Work against the field: Wagainst=+ΔUW_{against} = +\Delta U.

Mistake 3: Ignoring Velocity Dependence

Wrong: Treating drag as constant when velocity changes.

Correct: If velocity varies, you must integrate W=F(v)dxW = \int F(v) \, dx accounting for how vv changes with position.

Mistake 4: Assuming All Forces Are Conservative

Wrong: Trying to define potential energy for friction or drag.

Correct: Non-conservative forces (friction, drag) dissipate energy. Work against them depends on path length, not just endpoints.


Summary

Work done by variable forces requires integration—the fundamental tool for accumulating continuously varying contributions. This concept underlies much of physics and engineering.

Key Formulas

SituationWork Formula
General variable forceW = ∫ F(x) dx
Gravitational (inverse square)W = GMm(1/r₁ - 1/r₂)
Coulomb (electrostatic)W = kq₁q₂(1/r₁ - 1/r₂)
Drag at constant vW = ½ρC_dAv²d
Conservative forceW = -ΔU = U(r₁) - U(r₂)

Key Insights

  1. Integration handles variation: When force changes with position, we break the path into infinitesimal pieces and sum.
  2. Inverse square laws: Gravity and electrostatics share the same mathematical structure, leading to similar work formulas.
  3. Velocity-dependent forces: Drag scales as v2v^2, making high speeds disproportionately expensive.
  4. Conservative forces: For gravity, springs, and electrostatics, work equals potential energy change.
  5. Physics-ML connection: Optimization is "rolling downhill" on a loss landscape—the same math describes both.
The Central Idea:
"Work is the integral of force over path—nature's way of accounting for how effort accumulates when conditions continuously change."
Next: In the following section on Fluid Dynamics: Flow Rate, we'll apply integration to understand how fluids move through pipes and channels—another beautiful application of calculus to the physical world.
Loading comments...