Current and charge
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?
At first C is empty, so all 5 V sits across R and i = 5 V / 1 kΩ = 5 mA. As C charges, i falls: i(t) = 5e^(−t/τ) mA, where τ = RC = 1 ms is the time constant.
Slicing the area
Over a short time the current barely changes, so charge = current × time: the area of a thin rectangle under the plot. Slice 1 is 0.5 ms wide and 5 mA tall: 5 mA × 0.5 ms = 2.5 µC.
Cut 0 to 3 ms into six slices. Make each one as tall as the current at its left edge, and add the areas. This is a Riemann sum. The six slices hold 6.04 µC.
Check it: 6.04 µC on a 1 µF capacitor would mean 6.04 V, more than the 5 V source can give. The current falls inside every slice, so each rectangle pokes above the curve. Those red corners are the error.
Use more, thinner slices and the corners shrink. Thirty slices of 0.1 ms give 4.99 µC. Three hundred slices of 0.01 ms give 4.77 µC, and 3000 give 4.75 µC. The sums settle on one number.
The integral
The number the sums approach as the slices get infinitely thin is the definite integral: q = ∫₀³ i(t) dt = 4.75 µC, the exact area under the curve. The ∫ sign is a stretched S for sum; dt is the shrinking slice width.
Now let the right edge move. The area from 0 up to any time t is the charge collected so far, q(t). Plotted, it is a second curve that climbs fast at first, then flattens as the current dies away.
The fundamental theorem of calculus: area grows at the rate of the curve, so dq/dt = i. We need a q whose slope is 5e^(−t): q(t) = 5(1 − e^(−t)) µC, t in ms. At 3 ms, q = 4.75 µC.
Back to the circuit
A capacitor's voltage is its charge over its capacitance: vC = q / C = 4.75 µC ÷ 1 µF = 4.75 V. After three time constants C holds 95% of the 5 V. This is the RC charging curve.
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.