📐 Week 11 (Part III: Transcendental Calculus & Optimization) • Student Lecture Materials
🐍 Download Notebook (.ipynb) 📑 Download Blank Slides (PDF) 📊 Download Dataset (.csv)

Week 11 — Linearization, Differentials (\(df\)) & Newton-Raphson Root-Finding

Engineering Focus: Uncertainty Propagation in Machined Spheres & Flowmeters, Linearizing Nonlinear Sensors & Solving Implicit Transcendental Equations (\(\tan x = x\), Colebrook Pipe Friction) Companion Dataset: Week11_Colebrook_Pipe_Friction_and_Orifice_Calibration_Data.csv


1. “Calculus Made Easy” Intuition: Every Smooth Curve Looks Straight Under a Microscope

Zoom out on the Earth and it looks round; stand on a football field and it feels completely flat. Every smooth curve looks like a straight tangent line if you only wander a tiny distance \(\Delta x = x - x_0\) away from anchor \(x_0\): \[f(x) \approx L(x) = f(x_0) + f'(x_0)(x - x_0)\] Even more compactly, write the tiny change in output \(df\) caused by a tiny tolerance or measurement error \(dx\) as: \[\mathbf{df = f'(x_0)\,dx}\] Divide \(df\) by \(f\) to see relative uncertainty—for instance, if a ball-bearing diameter is measured within \(\pm 0.5\%\) tolerance (\(dr/r = 0.005\)), its volume \(V = \frac{4}{3}\pi r^3\) automatically inherits \(\frac{dV}{V} = 3\frac{dr}{r} = \mathbf{\pm 1.5\%}\) error!

Turning the Tangent Line Into a Root-Finding Rocket (Newton–Raphson)

What if you must solve an equation algebra cannot isolate, such as Euler column buckling \(\tan x = x\) or Colebrook turbulent pipe friction? Suppose you want \(g(x) = 0\), and guess \(x_k\):

  1. Stand at \((x_k, g(x_k))\), draw the local straight tangent line, and ask: “Where does this straight line hit the horizontal floor (\(y = 0\))?” \[0 = g(x_k) + g'(x_k)(x_{k+1} - x_k) \implies \mathbf{x_{k+1} = x_k - \frac{g(x_k)}{g'(x_k)}}\]

  2. Because smooth curves bend away very little near a root, the number of accurate decimal digits roughly doubles on every single iteration (quadratic convergence: \(1 \to 2 \to 4 \to 8 \to 16\) digits in just 4 steps)!

2. Complete Mathematical Derivations & Reference Guide

2.1 Step-by-Step Uncertainty Propagation & Taylor Linearization Table

Method Formula When to Use
Tangent Linearization \(L(x) = f(x_0) + f'(x_0)(x - x_0)\) Fast embedded microcontroller linear lookups
Differential Tolerance \(\Delta f \approx f'(x_0)\,\Delta x,\quad \frac{\Delta f}{f} \approx n\frac{\Delta x}{x}\) Gage tolerances & sensor error budgets
Newton–Raphson Root \(x_{k+1} = x_k - \frac{g(x_k)}{g'(x_k)}\) Implicit equations (\(\tan x = x\), Colebrook, Kepler’s equation)
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. Implicit Colebrook Pipe Friction & Orifice Tolerance Analysis

We read Week11_Colebrook_Pipe_Friction_and_Orifice_Calibration_Data.csv, containing turbulent pipe Reynolds numbers and relative roughnesses where Darcy friction factor \(f\) satisfies the implicit Colebrook equation: \[\frac{1}{\sqrt{f}} = -2\log_{10}\!\left(\frac{\varepsilon/D}{3.7} + \frac{2.51}{\mathrm{Re}\sqrt{f}}\right)\] By letting \(u = 1/\sqrt{f}\), Newton–Raphson converges to \(10^{-12}\) precision in just 3 iterations!

df = load_week_csv("Week11_Colebrook_Pipe_Friction_and_Orifice_Calibration_Data.csv")
print("Week 11 Colebrook & Orifice Data (first 6 rows):")
print(df.head(6).to_string(index=False))

# Solve Colebrook equation at each dataset row using 4 steps of Newton-Raphson on u = 1/sqrt(f)
def solve_colebrook_newton(Re, eps_D):
    u = 6.0  # initial guess for 1/sqrt(f)
    ln10 = np.log(10.0)
    for _ in range(5):
        arg = eps_D / 3.7 + 2.51 * u / Re
        g = u + 2.0 * np.log10(arg)
        gp = 1.0 + (2.0 / ln10) * (2.51 / Re) / arg
        u = u - g / gp
    return 1.0 / (u**2)

f_nr = [solve_colebrook_newton(r, e) for r, e in zip(df["Reynolds_Re"], df["Rel_Roughness_eps_D"])]
max_f_diff = np.max(np.abs(np.array(f_nr) - df["Darcy_Friction_f"].values))
print(f"\n[Newton-Raphson Verification] Max Colebrook residual vs dataset = {max_f_diff:.3e}")

# Visualize Tangent Steps on Euler Column Buckling tan(x) - x = 0
x_g = np.linspace(3.5, 4.65, 300)
g_fn = lambda x: np.tan(x) - x
gp_fn = lambda x: (1.0 / np.cos(x))**2 - 1.0
xk = 4.60
pts = [xk]
for _ in range(4):
    xk = xk - g_fn(xk) / gp_fn(xk)
    pts.append(xk)

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.8, 4.3))
ax1.plot(df["Reynolds_Re"] / 1e5, df["Darcy_Friction_f"], "o-", color="#0284c7", lw=2.0, label="Newton-Raphson Colebrook $f$")
ax1.set_title("Turbulent Pipe Friction Solved via Newton-Raphson")
ax1.set_xlabel("Reynolds Number Re [$\\times 10^5$]")
ax1.set_ylabel("Darcy Friction Factor $f$")
ax1.legend(fontsize=8.6)

ax2.plot(x_g, g_fn(x_g), color="#1e293b", lw=2.2, label=r"$g(x) = \tan(x) - x$")
ax2.axhline(0, color="#64748b", lw=1.0)
for i in range(2):
    x0 = pts[i]; y0 = g_fn(x0); sl = gp_fn(x0)
    xt = np.linspace(pts[i+1] - 0.05, x0 + 0.03, 50)
    ax2.plot(xt, y0 + sl*(xt - x0), "--", lw=1.5, label=f"Tangent Step {i+1}: x={pts[i+1]:.4f}")
ax2.scatter([pts[-1]], [0], color="#dc2626", s=65, zorder=5, label=f"Buckling Root = {pts[-1]:.6f}")
ax2.set_ylim(-2, 6)
ax2.set_title("Newton-Raphson Tangent Steps on Buckling Root")
ax2.set_xlabel("$x$ [rad]")
ax2.set_ylabel("$\\tan(x) - x$")
ax2.legend(fontsize=8.0)

plt.tight_layout()
plt.show()
# Verified Output:
Week 11 Colebrook & Orifice Data (first 6 rows):
 Reynolds_Re  Rel_Roughness_eps_D  Darcy_Friction_f
     10000.0               0.0004          0.031494
     14600.0               0.0004          0.028730
     21317.0               0.0004          0.026367
     31123.0               0.0004          0.024351
     45440.0               0.0004          0.022639
     66343.0               0.0004          0.021198

[Newton-Raphson Verification] Max Colebrook residual vs dataset = 4.586e-07
Week 11 Engineering Plot

4. Three Unabridged Worked Engineering Problems

Worked Example 1 — Linearizing \(\sqrt[3]{x}\) Without a Calculator & Checking Error

Problem: A nozzle throat factor involves \(f(x) = \sqrt[3]{x}\). Build the linear tangent model \(L(x)\) anchored cleanly at \(x_0 = 8\), use it to estimate \(\sqrt[3]{8.12}\), and compute the exact percent approximation error.

Unabridged Hand Solution:

  1. Anchor height: \(f(8) = 8^{1/3} = 2.0\).

  2. Derivative: \(f'(x) = \frac{1}{3}x^{-2/3} \implies f'(8) = \frac{1}{3(8^{2/3})} = \frac{1}{3\cdot 4} = \frac{1}{12}\).

  3. Linearization formula: \[L(x) = 2 + \frac{1}{12}(x - 8)\]

  4. Plug in \(x = 8.12\) (\(\Delta x = +0.12\)): \[\sqrt[3]{8.12} \approx 2 + \frac{0.12}{12} = \mathbf{2.010000}\] Compared to exact \((8.12)^{1/3} = 2.0099502\), the error is only \(0.0025\%\)!


Worked Example 2 — Tolerance Budgeting for a Precision Steel Ball Bearing

Problem: A ball bearing has nominal radius \(r_0 = 25.0\text{ mm}\) and caliper machining tolerance \(dr = \pm 0.05\text{ mm}\). Using differentials \(dV = V'(r_0)\,dr\), estimate the maximum absolute error \(\Delta V\) (\(\text{mm}^3\)) and percentage volume/mass uncertainty \(\Delta V / V_0\).

Unabridged Hand Solution:

  1. Volume \(V(r) = \frac{4}{3}\pi r^3 \implies V'(r) = 4\pi r^2\).

  2. Nominal volume: \(V_0 = \frac{4}{3}\pi(25)^3 = 65{,}449.8\text{ mm}^3\).

  3. Differential uncertainty bound: \[dV = 4\pi(25.0)^2(\pm 0.05) = \pm 125\pi \approx \mathbf{\pm 392.7\text{ mm}^3}\]

  4. Percentage check: \(\frac{dV}{V} = 3\frac{dr}{r} = 3\left(\frac{\pm 0.05}{25.0}\right) = 3(\pm 0.20\%) = \mathbf{\pm 0.60\%}\)!


Worked Example 3 — Three Hand Iterations of Newton-Raphson on Pinned-Fixed Column Buckling (\(\tan x = x\))

Problem: Solve \(g(x) = \tan x - x = 0\) on \((4.0, 4.7)\) starting from \(x_0 = 4.50\), showing all numbers at each step!

Unabridged Hand Solution:

  1. Derivative: \(g'(x) = \sec^2 x - 1 = \tan^2 x\) (look how clean that trig identity makes \(g'(x)\)!).
  2. Iteration Formula: \(x_{k+1} = x_k - \frac{\tan x_k - x_k}{\tan^2 x_k}\).
    • \(k=0\) (\(x_0 = 4.50\)): \(\tan(4.50) = 4.63733\), \(g = +0.13733\), \(g' = 21.5048\): \[x_1 = 4.50 - \frac{0.13733}{21.5048} = \mathbf{4.49361}\]

    • \(k=1\) (\(x_1 = 4.49361\)): \(\tan(4.49361) = 4.49811\), \(g = +0.00450\), \(g' = 20.233\): \[x_2 = 4.49361 - \frac{0.00450}{20.233} = \mathbf{4.493409}\] Already 6 accurate digits in just two steps!

# Verification of Worked Examples 1, 2, 3
lin_est = 2.0 + (8.12 - 8.0) / 12.0
exact_cr = 8.12**(1.0/3.0)
print(f"[Example 1] Linear est = {lin_est:.6f} vs Exact = {exact_cr:.6f} (Rel Err = {abs(lin_est-exact_cr)/exact_cr*100:.5f}%)")

dV_mm3 = 4.0 * np.pi * (25.0**2) * 0.05
print(f"[Example 2] Sphere volume tol = +/- {dV_mm3:.2f} mm^3 (+/- {3*(0.05/25.0)*100:.2f}%)")

xk = 4.50
for k in range(4):
    xk_next = xk - (np.tan(xk) - xk) / (np.tan(xk)**2)
    print(f"[Example 3] Iter {k+1}: x = {xk_next:.10f} (|tan(x)-x| = {abs(np.tan(xk_next)-xk_next):.2e})")
    xk = xk_next
# Verified Output:
[Example 1] Linear est = 2.010000 vs Exact = 2.009950 (Rel Err = 0.00247%)
[Example 2] Sphere volume tol = +/- 392.70 mm^3 (+/- 0.60%)
[Example 3] Iter 1: x = 4.4936139027 (|tan(x)-x| = 4.13e-03)
[Example 3] Iter 2: x = 4.4934096550 (|tan(x)-x| = 3.98e-06)
[Example 3] Iter 3: x = 4.4934094579 (|tan(x)-x| = 3.69e-12)
[Example 3] Iter 4: x = 4.4934094579 (|tan(x)-x| = 8.88e-16)

5. Engineering Practice Problems (Self-Study Exercises)

Practice Problem 1 — Orifice Flow Uncertainty Propagation (\(Q = C\sqrt{\Delta P}\))

In a Venturi flowmeter, flow rate depends on differential pressure via \(Q = k\,\Delta P^{1/2}\). If the pressure transducer has \(\pm 4.0\%\) measurement error, what is the induced percentage uncertainty in calculated flow rate \(Q\)?

🔍 Click to View Complete Step-by-Step Solution
  1. Take power-law differential relation: \(\frac{dQ}{Q} = \frac{1}{2}\frac{d(\Delta P)}{\Delta P}\).
  2. Thus \(\frac{dQ}{Q} = \frac{1}{2}(\pm 4.0\%) = \mathbf{\pm 2.0\%}\) (square roots always cut relative uncertainty in half!).

Practice Problem 2 — Linearizing \(\cos\theta\) Near \(0\) vs. Near \(\pi/6\)

Find the tangent linearization \(L(\theta)\) of \(\sin\theta\) around \(\theta_0 = \pi/6\) (\(30^\circ\)), and use it to approximate \(\sin(32^\circ)\) by converting the \(2^\circ\) offset to radians!

🔍 Click to View Complete Step-by-Step Solution
  1. \(f(\pi/6) = \sin(\pi/6) = 0.50\); slope \(f'(\pi/6) = \cos(\pi/6) = \frac{\sqrt{3}}{2} \approx 0.86603\).
  2. Convert \(+2^\circ\) offset to radians: \(\Delta\theta = 2^\circ \times \frac{\pi}{180^\circ} = 0.034907\text{ rad}\).
  3. \(\sin(32^\circ) \approx 0.50 + 0.86603(0.034907) = \mathbf{0.53023}\) (exact \(\sin 32^\circ = 0.52992\)!).

Practice Problem 3 — One Step of Newton’s Method on Square Root (\(\sqrt{10}\))

Formulate \(g(x) = x^2 - 10 = 0\) starting at guess \(x_0 = 3.0\) and perform 2 manual Newton iterations to approximate \(\sqrt{10}\).

🔍 Click to View Complete Step-by-Step Solution
  1. Notice \(x_{k+1} = x_k - \frac{x_k^2 - 10}{2x_k} = \frac{1}{2}\left(x_k + \frac{10}{x_k}\right)\) (the ancient Babylonian average!).
  2. \(x_1 = \frac{1}{2}(3 + 10/3) = \frac{19}{6} = 3.16667\).
  3. \(x_2 = \frac{1}{2}(3.16667 + 10/3.16667) = \mathbf{3.1622807}\) (exact \(\sqrt{10} = 3.1622777\)!).

Practice Problem 4 — Newton-Raphson on Transcendental Heat Radiation Balance (\(e^{-x} = x\))

Solve \(g(x) = x - e^{-x} = 0\) starting from \(x_0 = 0.50\), carrying out 2 hand steps!

🔍 Click to View Complete Step-by-Step Solution
  1. \(g'(x) = 1 + e^{-x}\).

  2. Step 1 (\(x_0 = 0.50\)): \(e^{-0.5} = 0.60653\), \(g = -0.10653\), \(g' = 1.60653\): \[x_1 = 0.50 - \frac{-0.10653}{1.60653} = 0.56631\]

  3. Step 2 (\(x_1 = 0.56631\)): \(e^{-0.56631} = 0.56762\), \(g = -0.00131\), \(g' = 1.56762\): \[x_2 = 0.56631 + \frac{0.00131}{1.56762} = \mathbf{0.56714}\]

References

🎬 Visual Intuition Animation — Newton Raphson Buckling Cobweb