Chapter 6 — Calculus II
Lesson map
Lesson 06 published. Map, example, EX011.
flowchart TD
N0["Learning outcomes and connection"]
N1["6.1 Stocks with feedback become differential equatio"]
N2["6.2 The linear first-order solution and the time con"]
N3["6.3 Numerical solution and error"]
N4["6.4 Sensitivity: which assumption matters?"]
N5["6.6 Practical activity"]
N6["Chapter synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6
N6 --> EX["Worked example"]
EX --> Q["Exercise EX011"]
Logical drawing
flowchart LR
N0["Learning outcomes and connection"]
N1["6.1 Stocks with feedback become differential equatio"]
N2["6.2 The linear first-order solution and the time con"]
N3["6.3 Numerical solution and error"]
N4["6.4 Sensitivity: which assumption matters?"]
N5["6.6 Practical activity"]
N6["Chapter synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6 --> Q["EX011"]
[Learning outcomes and connection]
|
v
[6.1 Stocks with feedback become differential equatio]
|
v
[6.2 The linear first-order solution and the time con]
|
v
[6.3 Numerical solution and error]
|
v
[6.4 Sensitivity: which assumption matters?]
|
v
[6.6 Practical activity]
|
v
[Chapter synthesis]
|
v
[Worked example] --> [Exercise EX011]
Learning outcomes and connection
After this chapter you can (1) write a first-order ordinary differential equation (ODE) for a stock with inflow and outflow; (2) solve linear first-order ODEs analytically, including exponential approach to equilibrium and its time constant; (3) solve ODEs numerically and control the step-size error; and (4) use series and sensitivity (partial derivatives) to see which parameter matters most to a resilience margin. It extends Chapter 1 and prepares Chapter 17 (control).
6.1 Stocks with feedback become differential equations
Chapter 1's reservoir had a known outflow and no inflow. Real stocks have flows that depend on the stock itself. Water leaving an open tank through an orifice depends on the head above it; a chlorine residual decays at a rate proportional to its concentration; a battery's terminal voltage falls with its state of charge. When the rate depends on the quantity, you get an equation like $dx/dt = f(x, t)$. The simplest important case is linear: $dx/dt = -kx + u$, with constant $k > 0$ and input $u$.
6.2 The linear first-order solution and the time constant
With constant $u$, the solution is $x(t) = x_\infty + (x_0 - x_\infty)e^{-kt}$, where $x_\infty = u/k$ is the equilibrium. The time constant $\tau = 1/k$ is the time to close about 63% of the gap; after $3\tau$ about 95% is closed, after $5\tau$ about 99%. Engineers use $\tau$ to reason about how fast a system responds to a change — and how fast it responds to an attack. Example: free chlorine in a storage tank decays with a first-order constant; if $k = 0.05$ per hour, $\tau = 20$ h. If dosing stops (by fault or malicious command), the residual halves in $\ln 2/k \approx 13.9$ h. That is the window in which an operator must notice and act before residual falls below the regulatory minimum.
6.3 Numerical solution and error
Most ODEs in practice are non-linear or driven by measured inputs, so you solve them numerically. Forward Euler, $x_{n+1} = x_n + h f(x_n, t_n)$, has global error proportional to the step $h$; halving $h$ roughly halves the error. Heun's method and the classical fourth-order Runge–Kutta method reduce error much faster for the same $h$. Always run a step-size convergence check: if halving $h$ changes the answer you care about by more than your tolerance, the step is too large. For stiff systems — some components much faster than others — explicit methods can become unstable unless $h$ is very small; Euler on $dx/dt = -kx$ is unstable for $h > 2/k$.
6.4 Sensitivity: which assumption matters?
A design margin depends on several parameters: initial level, demand, leak rate, pump capacity. The partial derivative of the margin with respect to each parameter, multiplied by that parameter's plausible range, shows which uncertainty dominates. For hold-up $T = V/q$ with constant demand, $\partial T/\partial V = 1/q$ and $\partial T/\partial q = -V/q^2$; a 10% error in demand moves $T$ about as much as a 10% error in usable volume, but in the opposite direction. Taylor series give the same insight for non-linear models: near a nominal point, $f(x + \Delta) \approx f(x) + f'(x)\Delta$.
6.5 Worked example: chlorine dosing loss (synthetic)
LRWA's Hollin Hill outlet residual is maintained at 0.8 mg/L; the synthetic operating minimum is 0.2 mg/L. With dosing stopped and first-order decay $k = 0.05$ h⁻¹, residual reaches 0.2 mg/L when $0.8e^{-0.05t} = 0.2$, i.e., $t = \ln 4 / 0.05 \approx 27.7$ h. If warm weather raises $k$ to 0.08 h⁻¹, the window shrinks to 17.3 h. The design team writes requirement R9: loss of dosing shall alarm within 15 minutes, independent of the dosing controller's own status reports — because a compromised controller could report normal operation. The ODE turned into a detection-time requirement with margin.
6.6 Practical activity
Modify Lab 1 to include constant inflow 120 m³/h from a single surviving pump and first-order leakage $0.01V$ m³/h. Integrate with Euler at three step sizes, and find the equilibrium level analytically by setting $dV/dt = 0$ with demand replaced by its mean.
Report the equilibrium level and compare it with the reservoir's capacity and floor. With one pump at 120 cubic metres per hour against a mean demand of 150, the stock must still fall unless leakage balances the difference, so check whether your analytic answer is physically possible before trusting it. Then confirm that the Euler runs converge as the step shrinks. The point of the exercise is the combination: an analytic check, a numerical result and a convergence test that agree with each other.
6.7 Common errors and limits
- Using exponential decay where the process is not first-order.
- Reporting a numerical solution without a step-size check.
- Ignoring that parameters (decay rates, demand) drift with temperature and season.
- Sensitivity on one parameter at a time when parameters interact; for strong interactions use global methods (Saltelli et al., 2008).
In the chlorine example, a team that used the cool-weather decay constant all year would believe it had 27.7 hours when summer leaves about 17. R9's 15-minute alarm was chosen with that seasonal range in mind, which is why the requirement does not depend on the exact constant.
Exercises — chapter 6
EX011 — Time constant to requirement. Objective: turn dynamics into a detection-time requirement. Inputs: §6.5. Steps: (1) compute the window at $k = 0.12$ h⁻¹; (2) if operators need 4 h to restore dosing manually, compute the latest acceptable alarm time; (3) write the requirement. Expected evidence: numbers and requirement. Rubric: 3 = correct window, margin and a verifiable requirement independent of the controller; 2 = one slip; 1 = numbers only; 0 = none.
EX012 — Euler stability. Objective: see numerical instability. Inputs: $dx/dt = -kx$, $k = 0.5$, $x_0 = 1$. Steps: compute five Euler steps with $h = 1$, $h = 3$ and $h = 5$ and compare with the exact solution. Expected evidence: table and explanation. Rubric: 3 = correct values and the $h > 2/k$ instability explained; 2 = values right, explanation weak; 1 = one step size only; 0 = none.
Chapter synthesis
When a flow depends on the stock, write an ODE. Linear first-order systems approach equilibrium exponentially with time constant $\tau$; that number becomes a detection and response requirement. Solve numerically with convergence checks and attention to stability. Use sensitivity to find which assumption dominates a margin, and design detection that does not depend on the component under suspicion.
Continue studying — chapter 06 of 50
← Chapter 05 · Course chapter index · Chapter 07 →
Continue to the next authored lesson.