The Question Behind the Wire
Connect a battery to a resistor and a capacitor in series and flip the switch. The capacitor doesn't jump to the battery voltage; it climbs along a smooth curve and only asymptotically reaches it. Open the switch on a coil-and-resistor loop and the current doesn't drop to zero instantly; it slides down a curve of its own. Both behaviours look like physics, but they are pure calculus.
Two ingredients are doing all the work: a memory element (a capacitor stores charge; an inductor stores flux) and a dissipative path (the resistor). Together they obey a first-order linear ODE — the exact species we learned to solve in section 21.1. The whole point of this section is to recognise that one ODE everywhere a capacitor or inductor lives.
The two equations of this section
For a series resistor + capacitor driven by a constant source V_s:
For a series resistor + inductor driven by the same kind of source:
Both are first-order, both are linear, and both reduce to the template with or and the eventual steady value. One template, two circuits, infinitely many applications.
Two Memory Elements, Two ODEs
Resistors are amnesiac: the voltage across them depends only on the current right now, by Ohm's law . Capacitors and inductors remember.
| Element | Constitutive law | What it remembers |
|---|---|---|
| Resistor R | v = R i | nothing — it dissipates energy, has no state |
| Capacitor C | i = C · dv/dt | charge on its plates → voltage v across it (the state variable) |
| Inductor L | v = L · di/dt | magnetic flux through its coil → current i through it (the state variable) |
Why the dual structure exists
A capacitor's law turns current into a rate of change of voltage. An inductor's law turns voltage into a rate of change of current. Swap voltage and current and the two laws are mirror images. That symmetry is why RC and RL circuits end up with the same differential equation in different costumes — and why everything you learn about one transfers instantly to the other.
Deriving the RC Equation from Kirchhoff
Walk once around the loop. Kirchhoff's voltage law says the signed sum of voltages must be zero:
Replace each piece by what we know: from Ohm, because the same current that flows through R is what charges C, and is just the capacitor's voltage we are trying to find. Substituting:
Rearrange to put the unknown and its derivative together:
Read the equation, don't just write it
The left side is everything the circuit does on its own; the right side is what the world is pushing on it. When the equation collapses to — the capacitor stops changing. Whenever , the derivative is positive (charging). Whenever , the derivative is negative (discharging back toward the source). The ODE encodes the entire story of pursuit.
Solving the RC Equation from Scratch
We have a first-order linear ODE with constant coefficients and a constant right-hand side. The general solution is particular + homogeneous.
- Particular solution (steady state). Try a constant . Then , so the ODE becomes . Good — the capacitor eventually sits at the source voltage.
- Homogeneous solution (free response). Drop the source and solve , i.e. . We met this in section 21.4 — it is exponential decay with rate : .
- Add them. .
- Match the initial condition. At the capacitor has voltage : , so .
The closed-form drops out:
Sanity-check by differentiating
. Plug into the ODE: ✓.
Two famous special cases
- Charging from empty. ⇒ . The graph starts at 0, rises with slope , and approaches .
- Discharging through R. ⇒ . A pure decay — same equation as radioactive halving, just measured in volts instead of nuclei.
Interactive RC Explorer
Drag , , and . Watch the tangent at the marker: its slope is always . The dotted vertical lines mark — notice how the curve crosses each one at the same fixed fraction of the gap.
Things to try
- Double . The curve gets twice as slow — but the shape is identical. Time-rescaling is the superpower of first-order systems.
- Switch to discharging. The curve flips upside down. Same , opposite direction — because the ODE doesn't care which side of you start on.
- Crank while leaving alone. The curve gets taller but exactly as fast as before — time behaviour decouples from amplitude behaviour. This is the secret signature of a linear system.
The Time Constant — Why τ Is Everything
Plug into the charging solution: . Plug into the discharging solution: .
So one time constant is the time it takes to close 63.2% of the remaining gap. After 2τ the remaining gap is squeezed by another factor of , and again at 3τ. By 5τ the gap is — engineers call that "done."
| At time | Fraction CHARGED | Fraction REMAINING |
|---|---|---|
| t = 0 | 0.00 % | 100.00 % |
| t = τ | 63.21 % | 36.79 % |
| t = 2τ | 86.47 % | 13.53 % |
| t = 3τ | 95.02 % | 4.98 % |
| t = 4τ | 98.17 % | 1.83 % |
| t = 5τ | 99.33 % | 0.67 % |
The shape is universal. Whether is 1 microsecond or 10 minutes, the fraction of the gap remaining at is always . That is the entire reason engineers report τ — once you know it, you know how long any transient will take.
The 5-τ Rule, Visualized
The same percentages stamped on the table above are stamped on the graph below. Slide and notice that only the time axis stretches — the two curves remain identically shaped. Every first-order linear system on Earth lives on these two curves.
RL Circuits: The Same Idea, Swapped
Replace the capacitor with an inductor. Walk the loop again with Kirchhoff:
Rearrange:
Divide through by and you see the same template with and . The solution must have the same shape:
| What you measure | RC circuit | RL circuit |
|---|---|---|
| State variable | v_C(t) (volts) | i(t) (amps) |
| Time constant τ | RC | L / R |
| Steady value | V_s | V_s / R |
| Initial slope | (V_s − v_0) / τ | (V_s − R i_0) / L |
| Energy stored | (1/2) C v² | (1/2) L i² |
Why the inductor briefly looks like an open switch
At the current is whatever it was an instant before (often 0). The inductor enforces this — it cannot change current instantaneously without producing infinite voltage. So all the source voltage appears across at first, exactly like the inductor were briefly an open switch. As time passes the current rises and R takes over the voltage drop.
Interactive RL Explorer
Try opening the switch (decay mode) on a circuit with a big . The current refuses to die instantly — and the inductor briefly produces a voltage spike that can be many times . This is exactly why relays and motor controllers have flyback diodes: without them, opening the switch fries the contacts.
The flyback voltage is a real-world hazard
Set , , and switch to decay. The peak spikes to . In real equipment with bigger inductances (a solenoid, a motor) the spike can reach hundreds of volts. Welding the relay contacts and burning the driver transistor are common failure modes — and they are explained by exactly this ODE.
Worked Example: 9 V into 1 kΩ · 1 mF
A 9 V battery is connected through a 1 kΩ resistor to an empty 1 mF capacitor. Compute: (a) the time constant; (b) the capacitor voltage at s; (c) the time to reach 90% of the supply; (d) the discharge half-life if we then short the supply. Try it on paper, then expand the panel to see the full work.
Show step-by-step solution
Step 1. Compute the time constant. s. One second — easy to hold in your head.
Step 2. Write the charging law. With , V, and s:
Step 3. Evaluate at the requested times.
| t (s) | Computation | v_C (V) |
|---|---|---|
| 0.0 | 9 · (1 − e⁰) | 0.0000 |
| 0.5 | 9 · (1 − e^{-0.5}) = 9 · 0.3935 | 3.5412 |
| 1.0 | 9 · (1 − e^{-1.0}) = 9 · 0.6321 | 5.6891 |
| 2.0 | 9 · (1 − e^{-2.0}) = 9 · 0.8647 | 7.7820 |
| 5.0 | 9 · (1 − e^{-5.0}) = 9 · 0.9933 | 8.9394 |
Notice the row at 1.0 s reads exactly 63.21% of 9 V — the universal "at one tau" benchmark in action.
Step 4. Time to reach 90%. Solve ⇒ ⇒ ⇒ s. This is also written as — a useful rule of thumb to keep in your head.
Step 5. Short the supply ( ) starting from the now-charged V capacitor. The decay law says . The half-life is s. Check: V ✓ — exactly half.
Step 6. Sanity-check on the explorer above. Set , , , marker at s. The displayed should read and the slope panel should read , which is .
Python: Building the RC Solver from the ODE
Before trusting the closed form, let's rebuild it from the equation. We step forward in a loop, then compare against . The approximation should converge as .
Notice the takeaway: forward Euler with a small agrees with the closed form, but a large visibly under- or over-shoots (depending on curve concavity). For RC and RL circuits the analytic solution is so cheap that nobody ever simulates them — but the same Euler skeleton scales to non-linear circuits where no closed form exists.
Python: Recovering τ from a Lab Trace
On the bench you usually know (measured separately) but not — the resistor is fine but the capacitor came from a bin labelled "assorted, 50% tolerance." The trick is the same one we used for exponential growth: take a log.
The right side is linear in , so a single division per sample recovers . Average across samples for a noise-tolerant estimate.
PyTorch: Joint Fit of τ and V_s by Gradient Descent
What if you don't even know ? Two unknowns, one log trick won't do it. PyTorch's autograd handles the joint fit with no extra algebra: write the forward model, define a mean-squared loss, and let Adam push both parameters to the values that minimise the error.
Why this idea matters far beyond circuits
The pattern forward model → loss → backward → step is the entire deep-learning training loop. Here it has two scalar parameters and one physical model. In a neural network it has billions of parameters and a model built from layers — but the loop is identical. Every time you train a model, you are doing parameter recovery on a much fancier ODE.
Where This One ODE Quietly Shows Up
The same first-order linear equation governs more than you 'd guess. The state variable changes; the structure does not.
| System | State variable | Time constant τ | Driving target y∞ |
|---|---|---|---|
| RC circuit | capacitor voltage v_C | RC | source voltage V_s |
| RL circuit | coil current i | L / R | V_s / R |
| Newton cooling | object temperature T | 1 / k_heat | ambient temperature T_amb |
| Drug clearance | blood concentration C | 1 / k_elim | 0 (single-dose) |
| First-order filter (audio) | output voltage | RC of the filter | input signal at low freq |
| Thermistor + scope probe | displayed temp reading | thermal time const. | true temperature |
One ODE, many costumes. Anywhere a system has one kind of memory and a linear way to leak toward a target, you get the equation of this section. The rest is units.
Common Pitfalls
- Mixing units of τ. in ohms times in farads gives seconds. If your resistor is in kΩ and capacitor in μF, then is in ms — not seconds. The single most common debugging mistake on RC circuits is a missing factor of 1000.
- Forgetting the initial condition. is part of the problem; a different gives a different curve. Especially when an experiment is repeated quickly, the capacitor may not have fully discharged between runs.
- Assuming "steady state" too soon. At you are still 36.8% off the target. Always wait at least 5τ before measuring a DC level.
- Treating an inductor as a passive blob. Open the loop on a charged inductor and you get a voltage spike of — which can be huge. Always provide a flyback path (a freewheeling diode, an RC snubber) before unplugging a coil.
- Reading τ off the wrong axis. On a linear-y plot, τ is the time at which a tangent drawn at t = 0 reaches the final value — not the visual half-height. On a log-y plot of the decay, τ is . Pick the right visual and the measurement becomes trivial.
Summary
- A series RC loop satisfies the first-order linear ODE ; a series RL loop satisfies . Both reduce to the template .
- The solution is . The state pursues the target with characteristic time .
- The time constant is for capacitors and for inductors. Units are seconds either way.
- At the remaining gap is of the original — 63.2% closed after 1τ, 99.3% closed after 5τ. Engineers call 5τ "done."
- Fitting from data is one log + one division per sample. Fitting both and simultaneously is two lines of PyTorch.
- The same ODE governs Newton's law of cooling, single-compartment drug clearance, audio low-pass filters, and any other system with one kind of memory leaking toward a fixed target.