๐Ÿ“ Week 07 (Part II: Limits & Derivative Rules) โ€ข Student Lecture Materials
๐Ÿ Download Notebook (.ipynb) ๐Ÿ“‘ Download Blank Slides (PDF) ๐Ÿ“Š Download Dataset (.csv)

Week 07 โ€” The Chain Rule (Gear-Train Ripples & Related Rates)

Engineering Focus: Four-Stroke Engine Piston Velocity \(v_p = \frac{dx}{d\theta}\omega\), Multi-Stage Gear Trains & Conical Hopper Filling Rates Companion Dataset: Week07_IC_Engine_Slider_Crank_Kinematics_Data.csv


1. โ€œCalculus Made Easyโ€ Intuition: The Magic of an Ordinary Gearbox

Open the hood of any car or bicycle and you immediately understand the Chain Rule.

Suppose pedal crank \(x\) turns middle gear \(u\) at \(3\) turns per pedal (\(du/dx = 3\)), and middle gear \(u\) turns the rear wheel \(y\) at \(4\) turns per middle gear (\(dy/du = 4\)). How many turns does the rear wheel make per pedal stroke? You do not need a calculus textbook to know the answer: \(4 \times 3 = \mathbf{12}\)! \[\mathbf{\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}}\] Look at Leibnizโ€™s genius notation \(\frac{dy}{dx} = \frac{dy}{du}\frac{du}{dx}\): because \(dy\), \(du\), and \(dx\) are genuine tiny differentials (โ€œlittle bitsโ€), the intermediate \(du\) acts just like fraction cancellation, passing the motion rippling cleanly down the chain!

How to Peel an Onion with the Chain Rule

Every composite function like \(y = \left(3x^2 + 5\right)^9\) or \(y = \sin(\omega t + \phi)\) is wrapped like an onion:

  1. Outer skin: \((\text{stuff})^9\) or \(\sin(\text{stuff})\).
  2. Inner core: \(\text{stuff} = u = 3x^2 + 5\) or \(\omega t + \phi\).

Never differentiate the inside while differentiating the outside! Freeze the inside \(\text{stuff}\) untouched when taking the outer derivative, then multiply by the derivative of the inside \(\text{stuff}\): \[\frac{d}{dx}\left[(\text{stuff})^9\right] = 9(\text{stuff})^8 \cdot \frac{d(\text{stuff})}{dx}\]

2. Complete Mathematical Derivations & Reference Guide

Whenever an inner function \(u = g(x)\) is raised to power \(n\): \[\frac{d}{dx}\left[u(x)^n\right] = n\left[u(x)\right]^{n-1} u'(x)\] And if three or four physical variables link in series (\(y \to w \to u \to x\)), the Chain Rule extends to any number of links: \[\frac{dy}{dx} = \frac{dy}{dw}\cdot\frac{dw}{du}\cdot\frac{du}{dx}\]

Sometimes nature hands you a constraint tying two moving quantities togetherโ€”like a \(L = 5\text{ m}\) ladder sliding down a wall (\(x^2 + y^2 = L^2\)) or water filling a cone (\(V = \frac{1}{3}\pi r^2 h\)). Simply differentiate every term with respect to time \(t\), remembering to slap \(\frac{dx}{dt}\) or \(\frac{dy}{dt}\) onto each variable via the Chain Rule: \[\frac{d}{dt}(x^2 + y^2) = \frac{d}{dt}(L^2) \implies 2x\frac{dx}{dt} + 2y\frac{dy}{dt} = 0\] Zero messy square roots needed!

Chain Rule Pattern Exact Derivative Engineering Application
2-Link Chain \(\frac{dy}{dx} = \frac{dy}{du}\frac{du}{dx}\) Piston speed \(v = \frac{dx}{d\theta}\omega\)
Power-Chain Rule \(\frac{d}{dx}[u^n] = n u^{n-1} u'\) Pythagorean length \(L = \sqrt{x^2 + y^2}\)
Sqrt-Chain Shortcut \(\frac{d}{dx}[\sqrt{u}] = \frac{u'}{2\sqrt{u}}\) Laser slant range & fluid pipe head
Time-Rate Chain \(\frac{dV}{dt} = \frac{dV}{dh}\frac{dh}{dt}\) Tank water level rise rate \(\dot{h}\)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sympy as sp
from pathlib import Path

plt.rcParams.update({
    "figure.dpi": 150,
    "font.size": 10,
    "axes.grid": True,
    "grid.alpha": 0.30,
    "axes.spines.top": False,
    "axes.spines.right": False,
})

def load_week_csv(filename):
    for p in [Path("datasets") / filename, Path("../datasets") / filename]:
        if p.exists():
            return pd.read_csv(p)
    raise FileNotFoundError(f"Dataset not found: {filename}")

3. Real-World 3600-RPM IC Engine Slider-Crank Kinematics

We load Week07_IC_Engine_Slider_Crank_Kinematics_Data.csv, logging piston position \(x(\theta)\) and piston speed \(v_p = \frac{dx}{d\theta}\omega\) across a full \(0^\circ\)โ€“\(360^\circ\) engine crank revolution at \(3600\text{ RPM}\) (\(r = 45\text{ mm}\), rod \(l = 150\text{ mm}\)). Notice where peak piston speed occursโ€”NOT at \(90^\circ\), because the finite connecting rod tilts through the Chain Rule factor \(\frac{\cos\theta}{\sqrt{l^2 - r^2\sin^2\theta}}\)!

df = load_week_csv("Week07_IC_Engine_Slider_Crank_Kinematics_Data.csv")
print("Week 07 IC Engine Slider-Crank Log (first 6 rows):")
print(df.head(6).to_string(index=False))

# Exact analytical Chain Rule check on x(theta) = r*cos(th) + sqrt(l^2 - r^2 sin^2(th))
r_mm, l_mm = 45.0, 150.0
omega = 2.0 * np.pi * 3600.0 / 60.0  # 376.99 rad/s
th_rad = np.radians(df["Crank_Angle_deg"].values)
dx_dth_mm = -r_mm*np.sin(th_rad) - (r_mm**2 * np.sin(th_rad)*np.cos(th_rad)) / np.sqrt(l_mm**2 - (r_mm*np.sin(th_rad))**2)
v_chain_ms = (dx_dth_mm / 1000.0) * omega
err_vp = np.max(np.abs(v_chain_ms - df["Piston_Velocity_m_s"].values))
idx_pk = np.argmax(np.abs(df["Piston_Velocity_m_s"].values))
print(f"\n[Chain Rule Piston Speed] Max residual vs telemetry = {err_vp:.4e} m/s")
print(f"[Peak Speed] |v_p|_max = {abs(df['Piston_Velocity_m_s'].iloc[idx_pk]):.2f} m/s at crank angle = {df['Crank_Angle_deg'].iloc[idx_pk]:.1f} deg")

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.8, 4.3))
ax1.plot(df["Crank_Angle_deg"], df["Piston_Pos_x_mm"], color="#0284c7", lw=2.2, label=r"Piston Pin Height $x(\theta)$")
ax1.set_title("Slider-Crank Piston Position $x(\\theta)$")
ax1.set_xlabel("Crank Angle $\\theta$ [deg]")
ax1.set_ylabel("Position from Crank Center $x$ [mm]")
ax1.legend(fontsize=8.6)

ax2.plot(df["Crank_Angle_deg"], df["Piston_Velocity_m_s"], color="#dc2626", lw=2.2, label=r"Exact Chain Rule $v_p = \frac{dx}{d\theta}\omega$")
ax2.axhline(0, color="#64748b", lw=1.0)
ax2.set_title("Piston Velocity at 3600 RPM ($v_p = (dx/d\\theta)\\cdot\\omega$)")
ax2.set_xlabel("Crank Angle $\\theta$ [deg]")
ax2.set_ylabel("Piston Velocity $v_p$ [m/s]")
ax2.legend(fontsize=8.5)

plt.tight_layout()
plt.show()
# Verified Output:
Week 07 IC Engine Slider-Crank Log (first 6 rows):
 Crank_Angle_deg  Piston_Pos_x_mm  Piston_Velocity_m_s
             0.0          195.000               -0.000
            20.0          191.494               -7.447
            40.0          181.657              -13.459
            60.0          167.349              -16.974
            80.0          151.118              -17.618
           100.0          135.490              -15.796

[Chain Rule Piston Speed] Max residual vs telemetry = 3.9909e-04 m/s
[Peak Speed] |v_p|_max = 17.62 m/s at crank angle = 80.0 deg
Week 07 Engineering Plot

4. Three Unabridged Worked Engineering Problems

Worked Example 1 โ€” Multi-Stage Chain & Power Rule on a Radial Envelope

Problem: Differentiate \(y(x) = \left(4x^3 - 7x + 1\right)^5\) and \(z(t) = \frac{12}{\sqrt{t^2 + 9}}\) cleanly without expanding the 5th power!

Unabridged Hand Solution:

  1. For \(y(x)\): Let inner \(u = 4x^3 - 7x + 1\), so \(u' = 12x^2 - 7\). Outer skin is \(u^5 \to 5u^4\): \[y'(x) = 5\left(4x^3 - 7x + 1\right)^4 \cdot \left(12x^2 - 7\right)\]

  2. For \(z(t)\): Rewrite as \(z(t) = 12(t^2 + 9)^{-1/2}\). Outer derivative gives \(12\left(-\frac{1}{2}\right)(t^2 + 9)^{-3/2} = -6(t^2 + 9)^{-3/2}\); inner derivative gives \(2t\): \[z'(t) = -6(t^2 + 9)^{-3/2}\cdot(2t) = \mathbf{-\frac{12t}{(t^2 + 9)^{3/2}}}\]


Problem: Crushed iron ore pours into an inverted conical hopper of top radius \(R = 3.0\text{ m}\) and total height \(H = 6.0\text{ m}\) at volumetric flow rate \(\frac{dV}{dt} = 1.5\text{ m}^3/\text{min}\). Find how fast the ore depth \(h\) is rising at the instant \(h = 2.0\text{ m}\).

Unabridged Hand Solution:

  1. Notice \(V = \frac{1}{3}\pi r^2 h\) currently has two changing variables (\(r\) and \(h\)). Eliminate \(r\) using similar triangles! \[\frac{r}{h} = \frac{R}{H} = \frac{3.0}{6.0} = \frac{1}{2} \implies r = \frac{h}{2}\]

  2. Substitute \(r = h/2\) into \(V\): \[V(h) = \frac{1}{3}\pi\left(\frac{h}{2}\right)^2 h = \frac{\pi}{12}h^3\]

  3. Apply the Chain Rule \(\frac{dV}{dt} = \frac{dV}{dh}\frac{dh}{dt}\): \[\frac{dV}{dt} = \frac{\pi}{4}h^2\,\frac{dh}{dt}\]

  4. Plug in \(h = 2.0\text{ m}\) and \(\frac{dV}{dt} = 1.5\): \[1.5 = \frac{\pi}{4}(4)\,\frac{dh}{dt} = \pi\frac{dh}{dt} \implies \frac{dh}{dt} = \frac{1.5}{\pi} = \mathbf{0.4775\text{ m/min}}\]


Worked Example 3 โ€” Slider-Crank Piston Speed via Exact Chain Rule

Problem: With crank radius \(r = 0.045\text{ m}\) and rod length \(l = 0.150\text{ m}\) spinning at \(\omega = 376.99\text{ rad/s}\) (\(3600\text{ RPM}\)), piston distance from crank center is: \[x(\theta) = r\cos\theta + \sqrt{l^2 - r^2\sin^2\theta}\] Derive \(v_p = \frac{dx}{dt}\) using the Chain Rule and evaluate \(v_p\) at \(\theta = 90^\circ\) (\(\pi/2\text{ rad}\))!

Unabridged Hand Solution:

  1. First compute \(\frac{dx}{d\theta}\) using \(\frac{d}{d\theta}\sqrt{u} = \frac{u'}{2\sqrt{u}}\) where \(u = l^2 - r^2\sin^2\theta\), so \(u' = -2 r^2 \sin\theta\cos\theta\): \[\frac{dx}{d\theta} = -r\sin\theta - \frac{r^2\sin\theta\cos\theta}{\sqrt{l^2 - r^2\sin^2\theta}}\]

  2. Multiply by \(\omega = \frac{d\theta}{dt}\) via Chain Rule \(v_p = \frac{dx}{d\theta}\omega\): At \(\theta = \pi/2\): \(\sin(\pi/2) = 1\), \(\cos(\pi/2) = 0\) (so the whole second fraction vanishes cleanly!). \[v_p(\pi/2) = (-0.045 \times 1 - 0)(376.991) = \mathbf{-16.965\text{ m/s}}\] (downward toward BDC!).

# SymPy Check for Examples 1, 2, 3
x_s, t_s, h_s = sp.symbols("x t h", real=True, positive=True)
y_ex1 = (4*x_s**3 - 7*x_s + 1)**5
z_ex1 = 12 / sp.sqrt(t_s**2 + 9)
print("[Example 1] dy/dx =", sp.factor(sp.diff(y_ex1, x_s)))
print("[Example 1] dz/dt =", sp.simplify(sp.diff(z_ex1, t_s)))

dh_dt = 1.5 / (sp.pi * (2.0**2) / 4.0)
print(f"[Example 2] Cone dh/dt at h=2m = {float(dh_dt.evalf()):.4f} m/min")
print(f"[Example 3] Piston speed at theta=90 deg = {-0.045 * (2*np.pi*3600/60):.3f} m/s")
# Verified Output:
[Example 1] dy/dx = 5*(12*x**2 - 7)*(4*x**3 - 7*x + 1)**4
[Example 1] dz/dt = -12*t/(t**2 + 9)**(3/2)
[Example 2] Cone dh/dt at h=2m = 0.4775 m/min
[Example 3] Piston speed at theta=90 deg = -16.965 m/s

5. Engineering Practice Problems (Self-Study Exercises)

Practice Problem 1 โ€” Nested Double Chain Rule

Differentiate \(g(x) = \left(1 + \sqrt{x^2 + 1}\right)^3\) step-by-step.

๐Ÿ” Click to View Complete Step-by-Step Solution
  1. Peel outer cube \((\text{stuff})^3\): \(3\left(1 + \sqrt{x^2 + 1}\right)^2 \cdot \frac{d}{dx}\left(1 + \sqrt{x^2 + 1}\right)\).
  2. Peel middle square root \(\sqrt{x^2 + 1}\): \(\frac{2x}{2\sqrt{x^2+1}} = \frac{x}{\sqrt{x^2 + 1}}\).
  3. Multiply both links: \[g'(x) = \mathbf{\frac{3x\left(1 + \sqrt{x^2+1}\right)^2}{\sqrt{x^2+1}}}\]

A ground radar station sits \(d = 300\text{ m}\) horizontally from a launchpad. A drone climbs straight up at \(\frac{dh}{dt} = 12\text{ m/s}\). How fast is the straight-line slant range \(s = \sqrt{300^2 + h^2}\) increasing when the drone reaches altitude \(h = 400\text{ m}\)?

๐Ÿ” Click to View Complete Step-by-Step Solution
  1. Use \(s^2 = 300^2 + h^2\) and differentiate implicitly with respect to \(t\): \[2s\frac{ds}{dt} = 0 + 2h\frac{dh}{dt} \implies \frac{ds}{dt} = \frac{h}{s}\frac{dh}{dt}\]

  2. At \(h = 400\text{ m}\), \(3\text{-}4\text{-}5\) triangle gives \(s = \sqrt{300^2 + 400^2} = 500\text{ m}\).

  3. Substitute: \(\frac{ds}{dt} = \frac{400}{500}(12) = \mathbf{9.60\text{ m/s}}\).


Practice Problem 3 โ€” Multi-Stage Gearbox Angular Speed Rate

Motor shaft A spins at \(x(t) = 100t^2\) turns, driving intermediate shaft \(u = 2.5 x\), which drives wheel \(y = 0.4 u^{3/2}\). Using \(\frac{dy}{dt} = \frac{dy}{du}\frac{du}{dx}\frac{dx}{dt}\), find \(\frac{dy}{dt}\) when \(t = 2.0\text{ s}\).

๐Ÿ” Click to View Complete Step-by-Step Solution
  1. At \(t = 2.0\text{ s}\): \(x = 400\), \(u = 2.5(400) = 1000\), \(\frac{dx}{dt} = 200(2) = 400\text{ turns/s}\).
  2. Compute links: \(\frac{du}{dx} = 2.5\) and \(\frac{dy}{du} = 0.4 \cdot \frac{3}{2}u^{1/2} = 0.6\sqrt{1000} = 18.9737\).
  3. Multiply chain: \(\frac{dy}{dt} = 18.9737 \times 2.5 \times 400 = \mathbf{18{,}973.7\text{ turns/s}}\).

Practice Problem 4 โ€” Adiabatic Air Compression Temperature Rate

Air compresses in a cylinder via \(T(V) = T_0(V_0 / V)^{0.4}\). If \(T = 600\text{ K}\) when \(V = 0.4\text{ L}\) and the piston shrinks volume at \(\frac{dV}{dt} = -2.0\text{ L/s}\), compute \(\frac{dT}{dt}\)!

๐Ÿ” Click to View Complete Step-by-Step Solution
  1. Chain Rule on \(T = (T_0 V_0^{0.4}) V^{-0.4}\): \[\frac{dT}{dV} = -0.4\,\frac{T}{V} \implies \frac{dT}{dt} = -0.4\frac{T}{V}\frac{dV}{dt}\]

  2. Plug in values: \[\frac{dT}{dt} = -0.4\left(\frac{600}{0.4}\right)(-2.0) = \mathbf{+1200\text{ K/s}}\]

References

๐ŸŽฌ Visual Intuition Animation โ€” Three Layer Chain Rule Ripple