How it works
A neuron is a leaky cable
A neuron's branches are thin tubes of salty fluid wrapped in a membrane that leaks. Current injected at one point flows along the inside, and some leaks out through the wall as it goes. That makes a cable, and its voltage obeys the cable equation, worked out for telegraph cables and applied to neurons by Wilfrid Rall [3].
The first term on the right is current flowing along the branch, set by its radius a and the resistance of the fluid inside, Ra. The second is current crossing the membrane. Thin branches carry little current along their length, so a signal in a fine dendrite fades before it gets far.
Channels that make a spike
The membrane current comes from ion channels. Hodgkin and Huxley measured them in the squid giant axon and wrote them down in 1952 [1]: sodium channels that open fast when the voltage rises and let sodium rush in, raising it further; potassium channels that open more slowly and pull it back down; and a small steady leak.
The gates m, h and n each open and close at voltage-dependent rates. Push the voltage past about −55 mV and the sodium gates run away: the membrane fires a spike to about +40 mV and recovers within a few milliseconds. Each patch that fires pushes current into the next and fires it too, so the spike travels without fading.
A click on the cell body gives three times the jolt for twice as long: the body is large and spreads current into every branch, so it takes more to fire it from there. Afterwards the sodium gates stay shut for a few milliseconds and the membrane cannot fire again, however hard it is pushed: the refractory period. At the default speed, 2.5 ms of neuron time per second, that lasts a few seconds on screen, so clicks in quick succession merge into one jolt, and clicks during the recovery fizzle. A spike from a dendrite tip takes 2 to 3 ms to reach the cell body, about a second on screen.
Passive and active dendrites
The cell body and axon here have the full squid-axon channel density. The slider sets the dendrites' density as a share of that. At zero the dendrites are passive cables and a jolt at a tip arrives at the cell body small and smeared out. Turn the channels up and the dendrites fire spikes of their own, and a spike from the cell body also travels back up into them, as it does in many real neurons.
How it is solved
The neuron is cut into short pieces, each about 8 µm long, joined like resistors in a branching tree. The voltages of all of them are solved together, implicitly, so the step can be as large as the channels allow. On a tree that system can be solved in one sweep from the tips to the root and back, Michael Hines's method [2], which is how NEURON and Jaxley [4] do it too. The gates are advanced with an exponential step. One 25 µs step for the whole cell takes a few tens of microseconds in WebAssembly, so the simulation is slowed down for you to see it.
The shape
The neuron is made up by a small program: a cell body, a long branching apical dendrite going up, a skirt of shorter basal dendrites, and a thin axon going down, much like a pyramidal cell in the cortex. Each press of the button grows a different one. Load a real reconstruction as an .swc file, from NeuroMorpho.org for example, to try a real neuron. Branches are drawn thicker than they are, or the finest would be invisible.
References
[1] A. L. Hodgkin and A. F. Huxley, A quantitative description of membrane current and its application to conduction and excitation in nerve, J. Physiol. 117, 500 (1952).
[2] M. Hines, Efficient computation of branched nerve equations, Int. J. Bio-Medical Computing 15, 69 (1984).
[3] W. Rall, Branching dendritic trees and motoneuron membrane resistivity, Experimental Neurology 1, 491 (1959).
[4] M. Deistler et al., Jaxley: differentiable simulation enables large-scale training of detailed biophysical models of neural dynamics, Nature Methods (2025). The differentiable simulator this app takes its method from; it shares no code with it.