00.511.522.53012345t (ms)i (mA)current i(t)i = 5e^(−t/τ)00.511.522.53012345t (ms)q (µC)charge q(t) = area from 0 to tq = 5(1 − e^(−t/τ))SR5 VC0.00 V1from math import exp2def area(n, T=3.0):3 dt, q = T / n, 0.04 for k in range(n):5 q += 5*exp(-k*dt) * dt6 return q0 µC
Circuit: source, switch, R and C; the meter reads the capacitor voltageSlices: rectangles of current × time, each one a little chargeArea so far: the running sum of the slices, in µCPython card: area(n) adds n left-edge slicesAn RC circuit charging: 5 V, 1 kΩ, 1 µF, so τ = RC = 1 ms and the current i(t) = 5e^(−t/τ) mA falls from 5 mA. The charge the capacitor collects is the area under i(t). Six left-edge rectangles give 6.04 µC (too much: the red corners), thinner slices give 4.99 and 4.77 µC, and the limit, the integral, is 4.75 µC. The lower plot is the area so far, q(t); its slope at every moment equals the current. q / C gives the capacitor voltage, 4.75 V.

Current and charge

  1. Close the switch at t = 0. Current i flows from the 5 V source through R into the capacitor C. Current is a rate: 1 mA carries 1 µC of charge every millisecond. How much charge has C collected after 3 ms?

Slicing the area

The integral

Back to the circuit

Try it in the Python prompt

;; step 1/10 · Current is a rate
>>> 5 / 1000            # i = V / R at t = 0, in amps
0.005
>>> 1e-3 * 1e-3         # 1 mA for 1 ms, in coulombs
1e-06

Units multiply like numbers: mA × ms = (10⁻³ A)(10⁻³ s) = 10⁻⁶ C = 1 µC. Keeping units on every number is the quickest check that an area means what you think. Left-edge rectangles overestimate a falling curve and underestimate a rising one. Taking each slice's height at its middle is usually much closer: six midpoint slices give 4.70 µC here.