I fell into a neuroscience rabbit hole a few weeks ago. It started with a simple question. How does a single neuron fire?
Not the hand-wavy textbook version. Not "electrical signals travel along nerves." The actual mechanism. What physically happens. What equations describe it.
And I found the answer in a pair of equations from 1952 that I genuinely think might be the most beautiful piece of applied mathematics I've ever encountered.
Alan Hodgkin and Andrew Huxley figured out how neurons generate electrical spikes using nothing but careful experiments on squid axons and differential equations. No electron microscopes. No x-ray crystallography. No molecular biology. Just voltage clamps, math, and an unreasonable amount of patience.
And here's the part that still gets me. Their equations predicted the molecular structure of ion channels decades before anyone could actually see those molecules. The math came first. Reality confirmed it later.
Let me take you through the whole thing from scratch.
a tiny bag of water
Start with the simplest possible picture of a neuron.
It's a bag. A tiny bag filled with salty water, floating in a sea of slightly different salty water. The thin membrane separating inside from outside is where everything interesting happens.
Both the inside and outside are full of dissolved particles called ions. Sodium, potassium, chloride, calcium. Some carry positive charge, some negative. And here's the crucial fact. The composition of ions on both sides is different.
The inside of the cell has more negative charge than the outside.
This charge imbalance creates a voltage across the membrane. Same idea as a battery. Separated charges create electrical potential. The voltage across a resting neuron is about -65 millivolts. Negative inside relative to outside.
That's our state variable. That's what we're tracking. Everything that follows is about understanding how this voltage changes.
stored energy that wants to escape
Think of the charge imbalance as water held behind a dam.
The water wants to flow downhill. The dam holds it back. As long as the dam is intact, the energy stays stored as potential energy. The higher the water level, the more energy is stored.
This is capacitance.
The neuron's membrane is thin, maybe 5 nanometers thick. It separates two conducting solutions. That's basically a capacitor. And the fundamental equation of a capacitor is:
Q = C × V
Charge equals capacitance times voltage. Simple enough.
But we care about how things change. Taking the time derivative of both sides:
dQ/dt = C × dV/dt
The rate of change of charge equals capacitance times the rate of change of voltage. And since current is literally defined as the rate of change of charge (I = dQ/dt), this becomes:
C × dV/dt = I
This is the foundation. The rate of change of membrane voltage is proportional to the current flowing across the membrane.
but the walls leak
Here's where it gets interesting. Real membranes aren't perfect insulators.
The membrane is studded with protein channels. Molecular machines that can open and close, creating pathways for specific ions to flow through. Some let sodium through. Some let potassium through. Some are always open. Some only open under certain conditions.
When ions flow through these channels, they create electrical current. That current changes the charge distribution. Which changes the voltage.
So we update our equation:
C × dV/dt = -I_Na - I_K - I_leak + I_external
The voltage changes based on the sum of all ionic currents flowing through the membrane, plus any external current we inject. The negative signs are there because when positive ions flow into the cell, they increase the voltage (make it less negative), and we define the currents in a way that accounts for this.
This is the master equation. Everything else in the Hodgkin-Huxley model is about figuring out what those ionic currents actually are.
two forces, one ion
So what makes ions move through channels?
Two forces. And they often fight each other.
Diffusion. Particles naturally spread from high concentration to low concentration. Random motion. If there are more potassium ions inside the cell than outside, they'll tend to drift outward through any available channel. Same reason a drop of food coloring spreads through water.
Electrical attraction. Ions carry charge. Positive ions are pulled toward negative charge and repelled by positive charge. Since the inside of the cell is more negative, positive ions are electrically attracted inward.
For potassium, these two forces oppose each other. Diffusion pushes potassium out (lots of it inside, less outside). Electrical force pulls it in (inside is negative, potassium is positive).
There's a special voltage where these two forces exactly cancel out. It's called the equilibrium potential. For potassium, it's about -77 mV. For sodium, it's about +50 mV.
When the membrane voltage is different from the equilibrium potential, there's a net driving force. The further away from equilibrium, the stronger the force.
Play with this:
Ion Driving Force Explorer
Drag the voltage slider and watch how the driving force on each ion changes. At resting potential, Na⁺ is desperate to flow in. At the peak of a spike, K⁺ takes over and pushes the voltage back down.
The current for each ion follows Ohm's law:
I_ion = g_ion × (V - E_ion)
Where V - E_ion is the driving force and g_ion is the conductance (how many channels are open and how easily ions flow through them). Simple. Elegant.
But that g is where the real magic lives.
the spike
Before diving into the math of conductance, let's get the big picture of what happens when a neuron fires.
An action potential takes about 2-3 milliseconds. That's it. In that tiny window:
- Something pushes the membrane voltage slightly above threshold (around -55 mV)
- Sodium channels start opening. Positive sodium ions rush into the cell
- This makes the voltage even more positive, which opens even more sodium channels
- The voltage rockets up to about +30 mV in less than a millisecond
- Sodium channels inactivate. They close and stay closed briefly
- Potassium channels (which are slower to open) are now fully open
- Positive potassium ions flow out of the cell
- The voltage drops back down, undershooting to about -80 mV
- Potassium channels close. Everything resets
Step 3 is the critical one. It's positive feedback. More depolarization opens more sodium channels, which causes more depolarization. This is what makes the spike all-or-nothing. Below threshold, nothing happens. Above threshold, the positive feedback loop takes over and the full spike fires regardless of how strong the stimulus was.
But here's the question that bugged me. Nobody is orchestrating this. There's no timer saying "ok sodium channels, you open now, and potassium channels, wait 0.5 milliseconds." There's no conductor.
So how does it work?
the orchestra with no conductor
The answer is voltage-dependent conductance.
Remember that g in Ohm's law? For some channels, it's not a constant. It depends on the current membrane voltage.
g_ion(V) = g_max × P(V)
The conductance at any moment equals the maximum possible conductance (if every channel were open) times P, the fraction of channels that are actually open.
g_max is fixed. It's determined by how many channels the cell has. Doesn't change with time.
P is the interesting part. It's a number between 0 and 1 representing what fraction of channels are open. And it depends on voltage.
Each ion channel is a protein machine. It changes shape in response to the electric field across the membrane. Inside each channel are charged regions, think of them as gates, that can flip between two positions: permissive (open) and non-permissive (closed).
A channel only conducts when ALL its gates are in the permissive position. Like a lock where multiple pins all need to be aligned for the door to open.
Let's call n the probability that a single gate is in its permissive position. How does it change over time?
dn/dt = α(V) × (1 - n) - β(V) × n
The first term: gates that are currently non-permissive (there are 1 - n of them) switching to permissive at rate α. The second term: gates that are currently permissive (there are n of them) switching to non-permissive at rate β.
Both α and β depend on voltage. This is where the voltage sensitivity enters. When the membrane depolarizes, α increases for sodium activation gates, making them more likely to open. It's all encoded in the rates.
Hodgkin and Huxley figured out the exact mathematical forms of α(V) and β(V) by fitting curves to their experimental data. These are not pretty closed-form expressions derived from first principles. They're empirical. Exponentials and linear terms mashed together to fit the squid axon data. But they work.
gates inside gates
Now the really clever part.
For potassium channels, Hodgkin and Huxley found that the conductance was proportional to n⁴. Not n, not n². The fourth power.
g_K = g_K_max × n⁴
If n is the probability of a single gate being permissive, and the channel has four independent gates, then by probability theory the chance that ALL four gates are permissive simultaneously is n × n × n × n = n⁴.
This is pure math. They didn't know the molecular structure. They just fit curves to current traces from voltage clamp experiments and found that the fourth power worked best.
Decades later, x-ray crystallography revealed that potassium channels have exactly four identical subunits that all need to be in the correct conformation for the channel to conduct.
The math predicted the molecule. I still can't get over this.
For sodium, the story is slightly different. The conductance follows:
g_Na = g_Na_max × m³ × h
Two types of gates. Three m gates (activation) and one h gate (inactivation). The m gates open fast when voltage rises, letting sodium rush in. The h gate closes slowly when voltage stays high, shutting the channel down.
This is the choreography. No conductor needed. The m gates respond fast to voltage. The h gate responds slowly. The n gates for potassium respond at an intermediate speed. The different time constants create the precise sequence of events that produces the action potential.
All from voltage-dependent rate constants. All self-organized.
see the whole system
Here is a live numerical simulation of the full Hodgkin-Huxley equations. This is running a 4th-order Runge-Kutta integrator on all four coupled differential equations in your browser right now.
Click stimulate and watch what happens. Then try a sub-threshold current and notice that nothing fires. That's the all-or-nothing threshold emerging naturally from the equations.
🧠 Hodgkin-Huxley Neuron Simulator
Inject current into a virtual neuron and watch the action potential unfold in real time. The top panel shows membrane voltage. The bottom shows the three gating variables that orchestrate the spike. Try sub-threshold vs supra-threshold currents.
What to watch for: At ~10 µA/cm², the green voltage trace spikes sharply. Watch m (red) shoot up first, opening Na⁺ channels. Then h (yellow) drops, inactivating them. Meanwhile n (blue) rises slowly, opening K⁺ channels to bring the voltage back down. Try 3 µA/cm² and notice that nothing fires. That's the threshold at work.
Watch the gating variables carefully during a spike. Red (m) shoots up first, because sodium activation gates respond fastest to depolarization. This is what drives the voltage upward. Yellow (h) drops a moment later, inactivating sodium channels. Blue (n) rises slowly, opening potassium channels that bring the voltage back down.
Nobody told these gates when to open and close. The voltage changed, the rate constants changed, and the gates followed. The dance emerges from the math itself.
they predicted the molecule
I keep coming back to this because it's genuinely one of the most satisfying results in the history of biology.
In 1952, Hodgkin and Huxley published their model. They said potassium conductance goes as the fourth power of a gating variable. They didn't know why. It just fit the data best.
In 2003, Roderick MacKinnon won the Nobel Prize for determining the crystal structure of potassium channels. Each channel has four identical subunits arranged symmetrically around a central pore. Four subunits. Four gates. n⁴.
Fifty-one years between prediction and confirmation. The math was right the whole time.
what this leaves out
Everything I've described treats the neuron as a single point. One voltage, one set of channels. That's called a "point neuron" or "space-clamp" model.
Real neurons have dendrites that receive signals, an axon that transmits them, and complex branching geometry. The voltage can be different at different locations along the cell. To handle this, you chop the neuron into small segments, apply the HH equations to each segment, and add terms describing how current flows between neighbors.
The result is a cable equation. A system of coupled PDEs instead of coupled ODEs. The math gets heavier but the core insight is identical. Ions flowing through voltage-dependent channels. Just with the added question of how those currents spread through the neuron's elaborate shape.
The HH model also uses four coupled differential equations. One for voltage, three for gating variables. You can't easily visualize four-dimensional dynamics. In computational neuroscience, people often simplify to two dimensions (voltage plus one combined gating variable) to see the system's behavior in a phase plane. That reduction reveals beautiful geometric structure. Limit cycles, bifurcations, excitability transitions. But that's a story for another post.
the math for the nerds who stayed
Here's the full system.
The voltage equation:
C_m × dV/dt = I_ext - g_Na × m³ × h × (V - E_Na)
- g_K × n⁴ × (V - E_K)
- g_L × (V - E_L)
The gating variable equations:
dm/dt = α_m(V) × (1 - m) - β_m(V) × m
dh/dt = α_h(V) × (1 - h) - β_h(V) × h
dn/dt = α_n(V) × (1 - n) - β_n(V) × n
Rate functions (voltage in mV, shifted convention with V_rest ≈ -65):
α_n(V) = 0.01 × (V + 55) / (1 - exp(-(V + 55)/10))
β_n(V) = 0.125 × exp(-(V + 65)/80)
α_m(V) = 0.1 × (V + 40) / (1 - exp(-(V + 40)/10))
β_m(V) = 4.0 × exp(-(V + 65)/18)
α_h(V) = 0.07 × exp(-(V + 65)/20)
β_h(V) = 1 / (1 + exp(-(V + 35)/10))
Standard parameter values (squid giant axon at 6.3°C):
| Parameter | Value | Meaning |
|---|---|---|
| C_m | 1 µF/cm² | Membrane capacitance |
| g_Na | 120 mS/cm² | Max sodium conductance |
| g_K | 36 mS/cm² | Max potassium conductance |
| g_L | 0.3 mS/cm² | Leak conductance |
| E_Na | +50 mV | Sodium reversal potential |
| E_K | -77 mV | Potassium reversal potential |
| E_L | -54.4 mV | Leak reversal potential |
| V_rest | -65 mV | Resting membrane potential |
Steady-state values at rest (V = -65 mV):
n_∞ = α_n / (α_n + β_n) ≈ 0.318
m_∞ = α_m / (α_m + β_m) ≈ 0.053
h_∞ = α_h / (α_h + β_h) ≈ 0.596
Time constants at rest:
τ_n = 1 / (α_n + β_n) ≈ 5.5 ms
τ_m = 1 / (α_m + β_m) ≈ 0.24 ms
τ_h = 1 / (α_h + β_h) ≈ 8.5 ms
Notice the time constants. m is 20x faster than n, and 35x faster than h. That's why the spike sequence works. m responds almost instantly to depolarization, creating the fast upstroke. h responds slowly, creating the delayed inactivation. n sits in between, creating the delayed repolarization.
The whole action potential is a race between fast activation and slow inactivation. No conductor. No clock. Just differential equations with different time constants, all driven by the same voltage, all feeding back into that voltage.
Four equations. One Nobel Prize. The foundations of computational neuroscience.
~ Ashish Kumar Verma