◇ OpenCyber Academy
Engineering · Chapter 6 · English

Chapter 6 — Calculus II

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 6 — Calculus II

Lesson map

Lesson 06 published. Map, example, EX016.

flowchart TD
  N0["Learning outcomes"]
  N1["6.1 Accumulating small risks"]
  N2["6.2 Series and the exponential"]
  N3["6.3 Applying it to Ridgeway"]
  N4["Synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4
  N4 --> EX["Worked example"]
  EX --> Q["Exercise EX016"]

Logical drawing

flowchart LR
  N0["Learning outcomes"]
  N1["6.1 Accumulating small risks"]
  N2["6.2 Series and the exponential"]
  N3["6.3 Applying it to Ridgeway"]
  N4["Synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4 --> Q["EX016"]
[Learning outcomes]
    |
    v
[6.1 Accumulating small risks]
    |
    v
[6.2 Series and the exponential]
    |
    v
[6.3 Applying it to Ridgeway]
    |
    v
[Synthesis]
    |
    v
[Worked example] --> [Exercise EX016]

Learning outcomes

You will (1) use series and limits to reason about cumulative risk; (2) model the probability of failure over many trials; (3) apply the approximation 1 - e^-x to security events.

6.1 Accumulating small risks

A single event with tiny probability becomes likely when repeated enough. If each of n independent trials fails with probability p, the chance that none fails is (1 - p)^n. Calculus II gives Aiyana the tool to simplify this: for small p, (1 - p)^n is close to e^(-np), a limit she derives from the series for the exponential function. This approximation appears constantly in cryptography, from nonce collisions to random key reuse, because engineers repeat operations billions of times. A risk of one in a billion per operation is not small for a fleet that performs ten billion operations.

6.2 Series and the exponential

The exponential function can be written as an infinite series, 1 + x + x²/2 + x³/6 and so on. For small x, the first two terms dominate, which is why 1 - e^(-x) is approximately x when x is tiny. Python's math.expm1 computes e^x - 1 accurately even for very small x, avoiding the rounding error of subtracting nearly equal numbers. Aiyana discovers this the hard way when her naive computation of 1 - exp(-1e-18) prints zero. She switches to -expm1(-x) and gets the correct tiny probability, a lesson in numerical care.

6.3 Applying it to Ridgeway

Suppose a faulty meter firmware chooses a 32-bit random identifier for each session, and the server confuses sessions if two identifiers match. With many sessions, the collision chance grows roughly as the square of the number of sessions divided by twice the space, the birthday effect developed further in Chapter 7. Aiyana uses the exponential approximation to show the board that a design acceptable for a pilot of a hundred meters fails for fifty thousand. The calculus tells her when "rare" stops being rare, which guides how many bits identifiers and nonces need.

Worked example

Aiyana derives (1 - p)^n ≈ e^(-np), fixes a rounding bug with math.expm1, and shows that a per-session identifier safe for a pilot is unsafe at full scale.

Synthetic case. The identifier design is invented; the mathematics is standard.

Errors and limits

The approximation assumes independence and small p; correlated failures, such as a shared bad random seed, break it badly. Floating-point subtraction of nearly equal numbers loses precision.

Exercises

Synthesis

Series and limits explain how tiny per-operation risks accumulate at scale, and careful numerics keep those estimates honest.

Continue studying — chapter 06 of 50

← Chapter 05 (draft) · Course chapter index · Chapter 07 (draft) →