27. Related rates
Two quantities are linked by a geometric or physical relationship. One of them is changing at a known rate. How fast is the other changing?
That's the whole genre, and it's implicit differentiation (§2.9) with respect to time rather than x.
The core idea
If x and y satisfy some equation, differentiating both sides with respect to t relates their rates. Every variable picks up a \frac{d}{dt} factor by the chain rule:
\frac{d}{dt}x^2 = 2x\frac{dx}{dt}, \qquad \frac{d}{dt}(xy) = \frac{dx}{dt}y + x\frac{dy}{dt}
The equation between the quantities becomes an equation between the rates.
The procedure
- Draw it, and label everything that varies with a letter. Do not put numbers on anything that changes.
- Write the equation connecting the variables — usually Pythagoras, a similar-triangles proportion, or an area/volume formula.
- Differentiate with respect to t. Every variable contributes its rate.
- Now substitute the instantaneous values.
- Solve, and check the sign and units.
Step 4 is where this goes wrong. Substituting numbers before differentiating turns a variable into a constant, and constants have zero derivative — so the term you needed silently disappears. If a related-rates answer comes out zero for no reason, this is almost always why.
The ladder
A 10 m ladder leans against a wall. Its base slides away at 1 m/s. How fast is the top sliding down when the base is 6 m out?
Variables. x = distance from wall to base, y = height of the top. Both vary; the ladder's length does not.
Equation. x^2 + y^2 = 100.
Differentiate in t:
2x\frac{dx}{dt} + 2y\frac{dy}{dt} = 0 \implies \frac{dy}{dt} = -\frac{x}{y}\cdot\frac{dx}{dt}
Substitute now. At x = 6: y = \sqrt{100-36} = 8, and \frac{dx}{dt} = 1:
\frac{dy}{dt} = -\frac{6}{8}(1) = -0.75 \text{ m/s}
The top slides down at 0.75 m/s. The minus sign is information: y is decreasing. Getting a sign you didn't expect usually means you mislabelled a direction, so always ask whether it's plausible.
The interesting part is what happens as the ladder falls further. At x=9.5 the top moves at 3 m/s; at x = 9.9, over 7 m/s; as x \to 10, y \to 0 and \frac{dy}{dt} \to -\infty.
An infinite speed is physically impossible, which tells you the model fails before the mathematics does: a real ladder loses contact with the wall and becomes a falling body long before that. Knowing when your model stops describing reality is not a mathematical skill, but calculus is very good at showing you where to look.
The cone
Water flows into a conical tank at 2 m³/min. The cone is 4 m across at the top and 6 m deep, point down. How fast is the level rising when the water is 3 m deep?
Volume of the water cone: V = \frac13\pi r^2 h — but that's two variables, and only h is asked about.
Eliminate one using similar triangles. The water cone always has the same shape as the tank, so \frac rh = \frac{2}{6} = \frac13, giving r = \frac h3.
V = \frac13\pi\left(\frac h3\right)^2 h = \frac{\pi h^3}{27}
Differentiate:
\frac{dV}{dt} = \frac{\pi h^2}{9}\cdot\frac{dh}{dt} \implies \frac{dh}{dt} = \frac{9}{\pi h^2}\cdot\frac{dV}{dt}
At h = 3 with \frac{dV}{dt} = 2:
\frac{dh}{dt} = \frac{9}{9\pi}\cdot2 = \frac{2}{\pi} \approx 0.637 \text{ m/min}
The step that matters is using similar triangles to reduce two variables to one. Without it you'd have an equation with two unknown rates and one equation — underdetermined. Look for that reduction in every cone, ladder, or shadow problem.
Notice too that \frac{dh}{dt} \propto \frac{1}{h^2}: the level rises quickly when shallow and slowly when deep, because each extra centimetre of depth needs more water than the last. Cheap intuition, free from the formula.
Doing it in Python
The ladder, as it falls:
from math import sqrt
L, dxdt = 10.0, 1.0
print(f"{'x (m)':>8} {'y (m)':>10} {'dy/dt (m/s)':>14}")
for x in (2.0, 5.0, 6.0, 8.0, 9.5, 9.9, 9.99):
y = sqrt(L*L - x*x)
print(f"{x:>8} {y:>10.4f} {-x/y * dxdt:>14.4f}")
print("\nthe top's speed runs to infinity as the ladder goes flat.")
print("the mathematics is fine; the model stopped being physics a while back.")
Verifying a related rate by simulating the motion directly:
from math import sqrt
def y_of_t(t, x0=6.0, speed=1.0, L=10.0):
x = x0 + speed * t
return sqrt(L*L - x*x)
dt = 1e-6
numeric = (y_of_t(dt) - y_of_t(-dt)) / (2 * dt)
print(f"related rates : {-6/8 * 1.0:.10f} m/s")
print(f"simulated : {numeric:.10f} m/s")
print("\nsame answer -- related rates is just the chain rule, done once instead of numerically")
The cone, and why the level slows down:
from math import pi
dVdt = 2.0
print(f"{'depth h (m)':>13} {'dh/dt (m/min)':>16} {'surface area (m^2)':>20}")
for h in (0.5, 1.0, 3.0, 5.0, 6.0):
r = h / 3
print(f"{h:>13} {9 / (pi * h*h) * dVdt:>16.4f} {pi * r * r:>20.4f}")
print("\ndh/dt is exactly dV/dt divided by the surface area -- the water")
print("spreads over a wider disc as it deepens, so the level climbs slower")
The classic error, priced:
from math import pi
# substituting h=3 BEFORE differentiating turns V into a constant
print("wrong order: set h=3 first, so V = pi*27/27 = pi, a constant")
print(" then dV/dt = 0, and the problem is unsolvable\n")
print("right order: differentiate V = pi h^3 / 27 to get dV/dt = (pi h^2/9) dh/dt")
print(f" then substitute h=3: dh/dt = {9 / (pi * 9) * 2:.6f} m/min")
Worked example
A streetlight is 5 m tall. A 1.8 m person walks away from it at 1.5 m/s. How fast is the tip of their shadow moving when they are 8 m from the light?
Variables. x = person's distance from the light, s = distance from the light to the shadow's tip. Both vary.
Equation. Similar triangles — the big triangle (light, ground, shadow tip) and the small one (person's head, feet, shadow tip):
\frac{5}{s} = \frac{1.8}{s - x}
Cross-multiply:
5(s-x) = 1.8s \implies 5s - 5x = 1.8s \implies 3.2s = 5x \implies s = \frac{5x}{3.2} = 1.5625x
Differentiate:
\frac{ds}{dt} = 1.5625\frac{dx}{dt} = 1.5625 \times 1.5 = 2.34375 \text{ m/s}
The tip moves at about 2.34 m/s — faster than the person walks, which is right: the tip has to cover the person's distance plus the lengthening shadow.
Notice what didn't appear. The answer doesn't involve x at all, so "when they are 8 m from the light" was irrelevant. That happens whenever the relationship is linear: the rate ratio is constant everywhere. Similar-triangle problems often have this property, and spotting it saves work — but only after you've differentiated, never before.
A follow-up worth doing. How fast is the shadow itself lengthening? Its length is s - x, so
\frac{d}{dt}(s-x) = 2.34375 - 1.5 = 0.84375 \text{ m/s}
Two different questions with two different answers, and reading which one is being asked is half the exercise.
Your turn
1. A spherical balloon is inflated at 100 cm³/s. How fast is the radius growing when r = 10 cm?
2. Two cars leave the same point, one north at 60 km/h and one east at 80 km/h. How fast is the distance between them growing after 2 hours?
3. The area of a square grows at 8 cm²/s. How fast is a side growing when the side is 4 cm?
Solutions
1. V = \frac43\pi r^3. Differentiate:
\frac{dV}{dt} = 4\pi r^2\frac{dr}{dt} \implies \frac{dr}{dt} = \frac{1}{4\pi r^2}\cdot\frac{dV}{dt}
At r = 10:
\frac{dr}{dt} = \frac{100}{4\pi(100)} = \frac{1}{4\pi} \approx \boxed{0.0796 \text{ cm/s}}
Note 4\pi r^2 is the sphere's surface area — the same "derivative of volume is surface area" fact from §0.1. The radius grows at (inflow rate)/(surface area), for exactly the reason the cone's level did.
2. After t hours the cars are at distances y = 60t north and x = 80t east, with separation z where z^2 = x^2+y^2. Differentiate:
2z\frac{dz}{dt} = 2x\frac{dx}{dt} + 2y\frac{dy}{dt} \implies \frac{dz}{dt} = \frac{x\frac{dx}{dt} + y\frac{dy}{dt}}{z}
At t=2: x = 160, y = 120, z = \sqrt{160^2+120^2} = 200.
\frac{dz}{dt} = \frac{160(80) + 120(60)}{200} = \frac{12800 + 7200}{200} = \boxed{100 \text{ km/h}}
Again constant in t — the 3-4-5 triangle just scales up, so the separation rate is \sqrt{60^2+80^2} = 100 from the start. Worth checking: for straight-line motion from a common point, the separation rate is the magnitude of the relative velocity, and it never changes.
3. A = s^2, so
\frac{dA}{dt} = 2s\frac{ds}{dt} \implies \frac{ds}{dt} = \frac{1}{2s}\cdot\frac{dA}{dt} = \frac{8}{8} = \boxed{1 \text{ cm/s}}
Sanity check via the perimeter: growing each side by ds adds a frame of area \approx 4s\,ds... but only two of the four sides move outward if you grow from a corner, giving 2s\,ds. That factor of 2 vs 4 is the same subtlety as §0.1's square-versus-circle discussion.
Check yourself in code
Compute the ladder's rate at several positions.
A 10 m ladder's base slides out at 1 m/s. For x = 2, 5, 8, 9.5, 9.9, print the wall height y = \sqrt{100-x^2} to 4 decimals and \frac{dy}{dt} = -\frac{x}{y} to 4 decimals.
Print exactly this:
x=2.0 y=9.7980 dy/dt=-0.2041 m/s
x=5.0 y=8.6603 dy/dt=-0.5774 m/s
x=8.0 y=6.0000 dy/dt=-1.3333 m/s
x=9.5 y=3.1225 dy/dt=-3.0424 m/s
x=9.9 y=1.4107 dy/dt=-7.0179 m/s
from math import sqrt
for x in (2.0, 5.0, 8.0, 9.5, 9.9):
# y from Pythagoras, then dy/dt = -(x/y) * dx/dt with dx/dt = 1
print(f"x={x:<5} ...")
from math import sqrt
for x in (2.0, 5.0, 8.0, 9.5, 9.9):
y = sqrt(100 - x*x)
print(f"x={x:<5} y={y:.4f} dy/dt={-x/y:.4f} m/s")
Related rates is implicit differentiation with t as the variable: write the equation between the quantities, differentiate it, and read off the equation between the rates. Differentiate before you substitute — putting numbers in early makes variables into constants and deletes the terms you need. Reduce to one variable using similar triangles or a fixed ratio when two appear. And read the sign and the units, because both are checkable and both catch mistakes.
Next: the derivative as an approximation tool — how far you can trust a tangent line, and exactly how the error grows.