◇ OpenCyber Academy
Engineering · Chapter 1 · English

Chapter 1 — Calculus I

Open, free learning for anyone who wants to protect people and technology. No account is required to read this text or its worked answers.

Chapter 1 — Calculus I

Lesson map

Lesson 01 published. Map, example, EX001.

flowchart TD
  N0["Learning outcomes and connection"]
  N1["1.1 Why an infrastructure engineer needs calculus"]
  N2["1.2 Derivatives you will use"]
  N3["1.3 Integrals and accumulated quantities"]
  N4["1.5 Practical activity: Lab 1"]
  N5["Chapter synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5
  N5 --> EX["Worked example"]
  EX --> Q["Exercise EX001"]

Logical drawing

flowchart LR
  N0["Learning outcomes and connection"]
  N1["1.1 Why an infrastructure engineer needs calculus"]
  N2["1.2 Derivatives you will use"]
  N3["1.3 Integrals and accumulated quantities"]
  N4["1.5 Practical activity: Lab 1"]
  N5["Chapter synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX001"]
[Learning outcomes and connection]
    |
    v
[1.1 Why an infrastructure engineer needs calculus]
    |
    v
[1.2 Derivatives you will use]
    |
    v
[1.3 Integrals and accumulated quantities]
    |
    v
[1.5 Practical activity: Lab 1]
    |
    v
[Chapter synthesis]
    |
    v
[Worked example] --> [Exercise EX001]

Learning outcomes and connection

After this chapter you can (1) read a rate of change as the physical quantity an operator watches — cubic metres per hour leaving a reservoir, megawatts ramping on a feeder; (2) compute a derivative and a definite integral for the smooth demand curves used in infrastructure planning; (3) solve "how long until…" problems by integrating a rate and finding the time at which the accumulated quantity reaches a limit; and (4) explain why the average-rate shortcut can overstate hold-up time. The chapter starts the book's design case and prepares Chapter 6, where the same reservoir becomes a differential equation with inflow and control.

1.1 Why an infrastructure engineer needs calculus

Critical services are stocks and flows. A reservoir is a stock of treated water; pumps and consumers are flows. A battery bank is a stock of energy; the load is a flow. A hospital fuel tank, a gas line-pack, a queue of unprocessed telemetry messages: each is an amount that changes at a rate. Security and resilience questions are almost always questions about these quantities under stress. If the pumps stop because their control network is down, how many hours of supply remain? If an attacker can hold a valve open, how fast does the level rise? The answer is never a single number from a data sheet; it is an integral of a rate over time, compared with a limit that matters to people.

The derivative $dV/dt$ is the instantaneous rate at which a quantity $V$ changes. If $V(t)$ is the volume in a reservoir in cubic metres and $t$ is in hours, $dV/dt$ is in m³/h. The definite integral $\int_a^b q(t)\,dt$ of a flow $q$ is the total amount moved between times $a$ and $b$. The fundamental theorem of calculus links the two: if $V' = -q$, then $V(b) - V(a) = -\int_a^b q(t)\,dt$. Every hold-up calculation in this book is that sentence applied to a real stock.

1.2 Derivatives you will use

You need a small toolkit: the derivative of a polynomial ($d/dt\, t^n = n t^{n-1}$), of the exponential ($d/dt\, e^{kt} = k e^{kt}$), of sine and cosine ($d/dt \sin(\omega t) = \omega\cos(\omega t)$), the product and chain rules, and the idea of a stationary point where $f'(t) = 0$. Daily demand on a water network is often approximated by a mean plus a sinusoid with a 24-hour period. If $d(t) = 150 + 60\sin(2\pi t/24)$ m³/h, then $d'(t) = 60\cdot(2\pi/24)\cos(2\pi t/24) \approx 15.7\cos(2\pi t/24)$ m³/h², so demand rises fastest — by about 15.7 m³/h every hour — when the cosine is 1. That slope matters to a pump controller: if the pumps can only ramp at 10 m³/h², they will lag the demand at its steepest.

1.3 Integrals and accumulated quantities

The antiderivative of the demand above is $D(t) = 150t - \frac{60\cdot 24}{2\pi}\cos(2\pi t/24) + C$. The water drawn from time 0 to $T$ is $D(T) - D(0) = 150T - \frac{1440}{2\pi}(\cos(2\pi T/24) - 1)$. Notice what the sinusoid does: over a whole day it cancels, so the daily total is just $150 \times 24 = 3600$ m³; but over part of a day it does not cancel, and when the outage starts changes how long the stock lasts.

To answer "when does the reservoir reach its minimum safe level?", set the drawn volume equal to the usable volume and solve for $T$. Most such equations have no closed-form solution, so engineers solve them numerically. Bisection halves an interval that is known to contain the answer until it is small enough; it is slow but cannot fail if the function is continuous and the starting interval brackets the root.

1.4 Worked example: Hollin Hill hold-up time (synthetic)

This case is synthetic. The book follows the invented Lowmarsh Regional Water Authority (LRWA), which runs the Fenwick water treatment works, six pumping stations (PS1–PS6) and the 4,000 m³ Hollin Hill service reservoir that feeds, among other customers, St Brenna's Hospital. LRWA is starting a Telemetry Modernisation and Resilience Programme (TMRP); you are on the engineering team.

Suppose a fault in the telemetry network stops the pumps feeding Hollin Hill at 06:00 (t = 0), when the reservoir holds 3,400 m³ (85%). Operations policy treats 20% (800 m³) as the floor below which pressure and fire-fighting reserves are at risk. Demand is $d(t)$ above, with t = 0 at 06:00. The usable volume is 2,600 m³. A planner who divides by mean demand gets 2,600/150 = 17.3 hours. Integrating the actual curve gives about 14.6 hours, because the outage begins as demand climbs into its morning and midday peak. The 2.7-hour difference is not rounding; it is the difference between dispatching a generator crew in time and not.

1.5 Practical activity: Lab 1

Run the lab with the Python 3 standard library. It finds the exact time by bisection, compares forward-Euler time-stepping at three step sizes, and prints the average-rate estimate.

# Lab 1 - how long does Hollin Hill reservoir last after the pumps stop? (synthetic, offline)
import math
V0, VMIN = 3400.0, 800.0          # m3: start at 85% of 4000, alarm floor at 20%
def demand(t):                     # m3/h, t in hours after the pumps stop (t=0 is 06:00)
    return 150.0 + 60.0 * math.sin(2 * math.pi * t / 24)
def drawn(t):                      # exact integral of demand from 0 to t
    return 150.0 * t - (60.0 * 24 / (2 * math.pi)) * (math.cos(2 * math.pi * t / 24) - 1)
lo, hi = 0.0, 48.0
for _ in range(60):                # bisection on drawn(t) = V0 - VMIN
    mid = (lo + hi) / 2
    lo, hi = (mid, hi) if drawn(mid) < V0 - VMIN else (lo, mid)
print(f"exact time to 20%: {lo:.2f} h")
for dt in (1.0, 0.1, 0.01):        # forward Euler
    v, t = V0, 0.0
    while v > VMIN:
        v -= demand(t) * dt; t += dt
    print(f"Euler dt={dt:<5} reaches 20% at {t:.2f} h")
print(f"constant-average model (150 m3/h): {(V0 - VMIN) / 150:.2f} h")
print(f"dV/dt at t=6 h: {-demand(6):.1f} m3/h")

Expected output:

exact time to 20%: 14.62 h
Euler dt=1.0   reaches 20% at 15.00 h
Euler dt=0.1   reaches 20% at 14.70 h
Euler dt=0.01  reaches 20% at 14.63 h
constant-average model (150 m3/h): 17.33 h
dV/dt at t=6 h: -210.0 m3/h

Euler with a one-hour step overstates the time by about 0.4 h; at 0.01 h it is within 0.01 h of the exact answer. The derivative at t = 6 h is −210 m³/h: the steepest drain in the window.

Before trusting the lab, check that its numbers agree with the worked example: the exact time should match the integrated hold-up for Hollin Hill, and the average-rate line should reproduce the planner's longer estimate. If you change the start time, keep the floor at 800 cubic metres so the comparison stays fair. A result that only appears at one step size is a property of the method, not of the reservoir.

1.6 Common errors and limits

Exercises — chapter 1

EX001 — Peak slope. Objective: use a derivative to compare demand with equipment limits. Inputs: $d(t)$ from §1.2; pumps that can ramp at most 12 m³/h per hour. Steps: (1) find $d'(t)$; (2) find its maximum and the clock time it occurs if t = 0 is 06:00; (3) decide whether the pumps can follow demand everywhere. Expected evidence: derivation and a one-sentence engineering conclusion. Rubric: 3 = correct derivative, maximum and time, conclusion links slope to ramp limit; 2 = one slip; 1 = derivative only; 0 = none.

EX002 — Hold-up from a different start. Objective: show that start time matters. Inputs: Lab 1. Steps: change the demand so that the outage starts at 18:00 (replace sin(2πt/24) with sin(2π(t+12)/24)), rerun, and compare with the 06:00 result and the average-rate estimate. Expected evidence: three numbers and a 100-word recommendation on which value an emergency plan should quote. Rubric: 3 = correct numbers and a recommendation to plan on the worst credible start time, with the reason; 2 = numbers right, weak recommendation; 1 = not run; 0 = none.

Chapter synthesis

Infrastructure is stocks and flows. A derivative is a rate you can compare with what equipment can do; an integral is an amount you can compare with a limit that protects people. Hold-up time is an integral solved for its upper bound, usually numerically, and it depends on when the disruption starts. Check numerical results against an exact or finer solution, keep units explicit, and never let an average stand in for a curve when the curve is what the outage will meet.

Continue studying — chapter 01 of 50

← Course home · Course chapter index · Chapter 02 →

Continue to the next authored lesson.