From Vector Calculus to the LIF Neuron
This article walks the chain from vector calculus to the spiking neuron: the operators and theorems needed to read Maxwell’s equations, the four equations themselves in differential and integral form, their collapse to Ohm and capacitance and the RC equation when applied in matter, the same RC equation specialised to a cell membrane plus the threshold-and-reset rule that makes it spike, and five worked examples that exercise the chain end-to-end. The destination is the conductance-based leaky integrate-and-fire (COBA) neuron used throughout the pinglab models and notebooks.
Vector Calculus
A short primer on the vector calculus needed to read Maxwell’s equations in both their differential and integral forms. We work in with Cartesian coordinates . Scalar fields take a point to a number; vector fields take a point to a vector. The operators below are the alphabet for talking about how those fields change in space, and the two theorems at the end are what turn the local (differential) story into the global (integral) one.
Operators
Inner product
Takes two vectors and returns a scalar.
where is the angle between them. It measures how much projects onto ; it is zero exactly when the two are perpendicular. Dot products of the form and are what pick out the component of a field along a surface normal or path tangent — the building block of flux and circulation.
Intuitively: how much of one arrow lies along the other — a shadow length.
Cross product
Takes two vectors and returns a vector perpendicular to both, with magnitude equal to the area of the parallelogram they span.
The direction follows the right-hand rule. Unlike the dot product, this one is anti-symmetric: . We use it implicitly via the curl operator below.
Intuitively: a vector pointing along the axle of the rotation that would carry onto , with length equal to the area of the parallelogram they span.
Gradient
Takes a scalar field to a vector field.
At every point it gives the direction of steepest increase of and a magnitude equal to the rate of that increase. The symbol is a formal vector of partial-derivative operators; the gradient is what you get when you apply it to a scalar.
Intuitively: standing on a hilly landscape with as the altitude — the arrow pointing straight up the steepest path.
Jacobian
Takes a vector field to a matrix of partial derivatives at each point. For ,
The entry is the rate at which the -th output component changes with respect to the -th input variable. Special cases: when is scalar-valued () the Jacobian is a row vector — the transpose of the gradient. When is a coordinate transformation (), is the local volume-scaling factor and appears as the Jacobian determinant in change-of-variables integrals.
The use that matters most in nb033 is linearisation: near a point , . For a dynamical system with a fixed point at (where ), the linearised dynamics are , and the eigenvalues of determine stability and oscillation frequency in the neighbourhood of the fixed point. This is the engine of bifurcation analysis.
Intuitively: the Jacobian is the multivariable derivative — the best linear approximation to a vector-valued function at a point.
Divergence
Takes a vector field to a scalar field.
It measures the net outflow of per unit volume at a point — positive at sources (lines fan outward), negative at sinks (lines converge), zero where the field passes through cleanly.
Intuitively: a tiny soap bubble dropped into the field — divergence is the rate at which it expands (positive) or shrinks (negative) at that point.
Curl
Takes a vector field to a vector field.
At every point it measures the local rotation of — its magnitude is the rate of circulation per unit area, its direction is the axis about which the field swirls (right-hand rule).
Intuitively: a paddle wheel placed at this point in a flowing fluid — curl is the axis it spins around and how fast.
Flux
The flux of a vector field through a surface is the integral of its normal component across that surface.
where is the unit normal to at each point and is the scalar area element. In 2D the surface degenerates to a curve and , the arclength element. Each infinitesimal patch contributes — the projection of the field onto the surface’s normal, times the patch area. Positive contributions are field lines crossing out; negative ones are field lines crossing in. The integral sums them with sign.
The choice of which way points is part of the orientation conventions below. Flipping flips the sign of the integral, so the meaning of “out” has to be fixed up front — outward normal for closed surfaces, user-chosen for open ones.
Intuitively: how many field lines net-cross the surface, counted positively in the chosen direction and negatively the other way.
Orientation conventions
Flux and the integral theorems below all carry signs that depend on how you orient the surface or boundary, and getting these wrong is what makes minus signs in physical laws look mysterious. Two conventions, applied consistently:
- Closed surfaces (a wrapping a volume ) carry the outward normal. The surface element points away from the enclosed volume, so counts flux leaving as positive and flux entering as negative. This is what makes the divergence theorem a “net outflow” statement.
- Open surfaces with boundary (an bounded by a curve ) carry a normal that the user picks, and the boundary curve is then oriented by the right-hand rule — curl your right-hand fingers around , and your thumb points along . Flip and the direction of integration around also flips, so both sides of Stokes’ theorem change sign in lockstep.
These conventions are what make signs in the physical laws non-arbitrary. In Maxwell’s equations, the minus in Faraday’s law is the canonical example: once the right-hand rule fixes relative to , Lenz’s law (the induced current opposes the change in flux) forces that sign — get the convention wrong and you’d derive perpetual motion.
Integral theorems
The two theorems below convert a local statement about a field’s divergence or curl into a global statement about flux or circulation across a boundary. They are what let the differential and integral forms of physical conservation laws be two sides of the same coin.
Divergence theorem
For a vector field defined on a volume with closed boundary surface , the integral of the divergence over the volume equals the flux through the boundary.
Intuitively: whatever the field is sourcing inside the volume has to flow out through the boundary. It is a conservation statement about field lines — every line that originates inside has to cross on its way out.
Stokes’ theorem
For a vector field on an oriented surface with boundary curve , the flux of the curl through equals the line integral around .
Intuitively: if the field is swirling across the surface, that swirl has to add up to something circulating around the edge — like measuring a whirlpool by walking its rim rather than counting eddies across its face.
Vector identities
A short reference list of identities that come up repeatedly when manipulating the operators above. Throughout, and are scalar fields and , , are vector fields. The first group are pure-algebra identities about dot/cross products; the rest are differential identities about how combines with itself or distributes through products.
Triple products.
The scalar triple product is cyclically invariant: it equals the signed volume of the parallelepiped spanned by the three vectors. Swapping any two arguments flips the sign.
The vector triple product, mnemonic “BAC − CAB”. The cross product is non-associative; this identity tells you exactly how it fails.
Second-derivative identities. The Laplacian is the divergence of the gradient of a scalar field.
The curl of any gradient is zero. Equivalently, any field that is the gradient of a scalar potential is automatically curl-free — the basis for the electric scalar potential under electrostatics.
The divergence of any curl is zero. Equivalently, any field that is the curl of another vector is automatically divergence-free — the basis for the magnetic vector potential when .
The curl-of-curl identity. This is what turns Maxwell’s two curl equations into the wave equation: taking of Faraday and substituting Ampère–Maxwell on the right invokes this identity on the left, and in vacuum kills the first term.
Product rules. The differential operators distribute through products in patterns analogous to the ordinary calculus product rule.
The last of these is what proves Poynting’s theorem in electromagnetism: applied to it produces an energy-flux conservation law.
Maxwell’s Equations
The four Maxwell equations are the backbone of classical electromagnetism. They come in two equivalent forms — differential, which states how the fields behave at every point, and integral, which states how they behave across surfaces and along loops. Both forms use the operators and integral theorems collected in Vector Calculus above.
Differential form
Here and are the electric and magnetic fields, is the charge density, the current density, and , the vacuum permittivity and permeability. Two of the equations involve a divergence and two a curl, and that split is what lets the two integral theorems convert each pair into the integral form below.
Integral form
Here is the total charge enclosed by the closed surface , is the total current passing through the open surface , and the orientation conventions for and are the ones from the vector-calculus primer.
Linking the two forms
The two forms are linked by the integral theorems from Integral theorems:
- The divergence theorem turns the two equations into the two flux statements through closed surfaces. Applied to , it converts into the enclosed-charge version of Gauss’s law; the same move applied to gives the magnetic Gauss law with zero on the right.
- Stokes’ theorem turns the two equations into the two circulation-vs-flux-derivative statements. Applied to , it converts Faraday’s into the integral form above (and the minus sign carries over directly); applied to , it does the same for the Ampère–Maxwell law.
The minus sign on Faraday’s law is the canonical example of orientation conventions doing real work: once the right-hand rule fixes relative to , Lenz’s law forces that sign, and the differential and integral forms agree on it automatically.
Gauss’s law
Charges are the sources of the electric field. The strength of the source at every point is the local charge density.
Differential form.
Integral form.
The two forms say the same thing at different scales. The differential form is a local identity: at every point in space, the divergence of the electric field equals the charge density there, divided by the vacuum permittivity. The integral form is the global consequence: for any closed surface you draw, the total outward flux of across it is the total charge inside, divided by . The link between the two is the divergence theorem applied to .
Intuitively: electric field lines start on positive charges and end on negative charges. Wrap any closed surface around a chunk of space and count the lines crossing it — positive when leaving, negative when entering — and you’ve measured the net charge inside. No charges inside, no net flux. The shape of the surface doesn’t matter; only what’s enclosed.
Symbols and units (SI):
| symbol | name | units |
|---|---|---|
| electric field | V/m (volts per metre) | |
| charge density | C/m³ (coulombs per cubic metre) | |
| charge enclosed by | C (coulombs) | |
| closed surface (boundary of a volume ) | m² when integrated | |
| outward-pointing surface element | m² (vector, normal to ) | |
| vacuum permittivity | F/m (farads/m, equivalent C²/(N·m²)) |
The constant is what sets the scale: a single point charge produces a total flux of — large because a coulomb is a lot of charge. In everyday terms, encodes “how stiffly the vacuum opposes electric field lines”: a small would mean a tiny charge produces an enormous field.
Gauss’s law of magnetism
The magnetic field has no sources or sinks. Every magnetic field line that enters a region eventually leaves it — there is no magnetic equivalent of an isolated charge.
Differential form.
Integral form.
The two forms again say the same thing at different scales, linked by the divergence theorem. The differential form says the divergence of is zero everywhere — no points act as sources or sinks. The integral form says that for every closed surface, the net magnetic flux through it is zero — exactly as many field lines leave as enter. The right-hand side of Gauss’s law had a term; here, there is no equivalent, because no magnetic monopole has ever been observed.
Intuitively: magnetic field lines form closed loops. Wrap any closed surface around a chunk of space and the loops crossing into it must also cross out — net flux is zero.
Symbols and units (SI):
| symbol | name | units |
|---|---|---|
| magnetic field | T (tesla, equivalent V·s/m² or N/(A·m)) | |
| closed surface | m² when integrated | |
| outward-pointing surface element | m² (vector, normal to ) |
No constant appears on the right-hand side — the law’s content is the equation . If a magnetic monopole were ever discovered, it would acquire a -style term and stop being structurally simpler than its electric cousin. Until then, the magnetic side of Maxwell’s equations is “missing” exactly one of the four source terms electricity carries.
Faraday’s law of induction
A changing magnetic field induces a circulating electric field. The faster the magnetic flux changes through a loop, the larger the induced electric circulation around its boundary.
Differential form.
Integral form.
The two forms are linked by Stokes’ theorem. The differential form is a local identity: the curl of at every point equals the negative time-derivative of there. The integral form is the global consequence: the total -circulation around any closed loop equals the negative rate of change of the -flux through any surface spanning that loop. The minus sign is Lenz’s law: the induced electric field drives currents that oppose the change in magnetic flux — a self-stabilising sign forced by the right-hand rule relating to .
Intuitively: shove a magnet through a wire loop and the loop pushes back. The pushing is the induced electric field, the direction it circulates is whichever way opposes whatever you were doing.
Symbols and units (SI):
| symbol | name | units |
|---|---|---|
| electric field | V/m | |
| magnetic field | T | |
| closed boundary curve of | m when integrated | |
| tangent line element to | m (vector, right-hand-oriented relative to ) | |
| open surface bounded by | m² when integrated | |
| surface element on | m² (vector, normal to ) | |
| partial derivative in time | per second |
No constants appear on the right-hand side beyond the minus sign — the relation between and is exact, with no scale factor. The whole content of the law sits in that minus sign and the geometric pairing .
Ampère–Maxwell law
The magnetic field circulates around both real currents and changing electric fields. The “displacement-current” term — Maxwell’s addition to Ampère’s original law — is what completes the symmetry with Faraday’s law and makes self-propagating electromagnetic waves possible.
Differential form.
Integral form.
The two forms are linked by Stokes’ theorem, exactly mirroring Faraday’s law but with the electric and magnetic roles swapped (and no minus sign). The differential form says the curl of at every point has two sources: a real current density , and a changing electric field . The integral form says the -circulation around a loop equals times the current piercing any surface spanning it, plus times the rate of change of -flux through the same surface.
The displacement-current term was Maxwell’s invention; without it, the original Ampère law is inconsistent with charge conservation (taking of both sides would imply always, which is false whenever charge density changes in time). Adding the term not only patches that inconsistency but also produces the wave equation when combined with Faraday’s law in vacuum — the propagation speed comes out as , which is the speed of light.
Intuitively: every current is wrapped by a magnetic field, and so is every region of changing electric field. The second part is what lets light exist: an oscillating generates a circulating which generates a circulating , and the pair propagates through empty space at speed .
Symbols and units (SI):
| symbol | name | units |
|---|---|---|
| magnetic field | T | |
| current density | A/m² (amperes per square metre) | |
| electric field | V/m | |
| current piercing | A (amperes) | |
| boundary curve of | m when integrated | |
| tangent line element | m | |
| open surface bounded by | m² when integrated | |
| surface element on | m² | |
| vacuum permeability | N/A² (henries/m) | |
| vacuum permittivity | F/m |
The two constants and encode how the vacuum responds to magnetism and electricity respectively, and they appear here as a product. Their reciprocal-square-root is the speed of light: . That “the speed of light falls out of Maxwell’s equations” is the historical moment electromagnetism and optics merged into one subject.
From Fields to Circuits
Maxwell’s equations describe electromagnetism at every point in space, but for a single wire or capacitor that spatial resolution is overkill. Applied in matter, two of the four equations collapse onto two circuit-level constitutive laws — Ohm and Q=CV — which together give the RC equation, the simplest first-order voltage dynamics in physics. This section walks that collapse end-to-end. The destination is
the equation an RC circuit obeys and the same equation a single point-neuron’s membrane obeys between spikes.
Ohm’s law in matter
In free space Maxwell’s equations relate , , and . In a conductor there is one extra relation, supplied by the material rather than by Maxwell: an electric field pushes the free charges around, and the rate at which they move per unit area, per unit time, is the current density . To linear order,
where is the conductivity of the material (siemens per metre, ). This is a constitutive law — not derivable from Maxwell alone, it tells you how a specific material responds to a field, in the same role the relation plays for dielectrics.
What conductivity actually is
A field exerts a force on every mobile charge carrier, accelerating it. In a true vacuum that carrier would keep accelerating forever; in a real material it scatters off the lattice (or the surrounding fluid) on a short timescale , the mean free time between collisions. Between collisions it picks up a velocity , then loses it again. Averaged over many collisions, every carrier acquires a steady drift velocity
where is the mobility of that carrier (units ). With carriers per unit volume, each carrying charge , the current density is just , so
Conductivity is therefore a product of “how many carriers there are” (), “how much charge each one carries” (), and “how easily each one drifts in a field” (, or equivalently ). A metal has near-free electrons and , giving . Salt water has dissolved ions of charge , but the mobility of an ion in water is roughly six orders of magnitude smaller than an electron in a metal, so . A neuron’s cytoplasm and the extracellular fluid sit in the same ballpark. The lipid bilayer at the membrane is the opposite extreme: essentially no mobile ions at all, . That is why the membrane behaves as a capacitor in the next section and the fluids on either side behave as wires.
Intuitively: measures how responsive a material is to a field — how many carriers it offers up, multiplied by how easily each one moves. A field exerts a force per carrier; collisions limit the velocity; the product is the current.
Voltage
To get from the differential statement to the familiar we first need to nail down what voltage means. Voltage (or potential difference) between two points and is the work done per unit charge to carry a test charge from to against the electric field:
Units: joules per coulomb volts (). The minus sign is bookkeeping: when is at higher potential than , so a positive charge would want to fall from to — like a ball wanting to roll downhill.
Two consequences make voltage a useful circuit-level concept:
- Path-independence. In the electrostatic limit, (no time-varying ), so the line integral above depends only on the endpoints, not on the path taken between them. This is what justifies talking about “the voltage at a node” rather than “the voltage along this particular wire.”
- Kirchhoff’s voltage law. Path-independence is equivalent to saying the integral around any closed loop is zero: → around the loop. (When is not zero through the loop, Faraday’s law modifies this — but for the membrane circuits we care about the time-varying magnetic field is negligible.)
For a uniform-cross-section wire of length with constant along it, the integral collapses to — the special case the textbook starts with.
Ohm’s law in integral form
Substituting and into for the uniform wire gives
with the wire’s resistance (ohms, ). For neurons the two relevant values of — high for the fluids, zero for the membrane — are what make the rest of this section’s RC picture justified.
Capacitance
A thin insulator sandwiched between two conductors can hold separated charge: positive on one plate, negative on the other. To get the relation between stored charge and voltage, walk Gauss’s law and the voltage definition through a parallel-plate geometry.
Take two plates of area separated by a gap , holding charge and . The integral form of Gauss’s law applied to a pillbox surface straddling one plate gives a uniform field between the plates of magnitude
Integrating that field across the gap gives the voltage between the plates, . Rearranging,
where is the capacitance (farads, ). The relation is the load-bearing piece: capacitance is the proportionality between stored charge and the voltage that charge creates.
Differentiating in time gives the current flowing onto the plates,
This is the “current-through-a-capacitor” rule. Charge moving onto the plates is the current; the voltage rises in lockstep, at a rate set by how big the capacitor is.
Intuitively: a capacitor is a tank. Pouring charge in (current) raises its level (voltage) at a rate determined by how big the tank is (capacitance).
The RC equation
Wire a resistor in parallel with a capacitor , with one end of both held at a reference voltage and the other driven by an external current source . Kirchhoff’s current law at the top node says the input current splits between charging the capacitor and leaking through the resistor,
Rearranging gives the RC equation:
With the voltage relaxes exponentially toward on the timescale . With a steady the steady-state shifts to . Whatever the input, the dynamics is always a first-order linear ODE — the same form that appears in the COBA derivation on the models page, where and become functions of the open conductances.
The RC equation is also already most of the way to the LIF neuron. The only thing missing for LIF is a threshold + reset rule on top: when crosses some firing level , emit a spike and snap back to a reset value. The subthreshold dynamics between spikes is exactly the RC equation.
Intuitively: an RC circuit is the simplest dynamical voltage in physics — one state variable, one timescale, one rest level. Everything more elaborate (cable equations, Hodgkin–Huxley, COBA) is decoration on top of this skeleton.
The LIF Neuron
The leaky integrate-and-fire (LIF) neuron is the simplest model of a spiking cell that still preserves the two things that make neurons interesting: a continuous voltage that integrates inputs in time, and a discrete spike output emitted when that voltage crosses a threshold. Subthreshold, an LIF cell is exactly the RC circuit derived in the previous section — Maxwell’s equations applied to a thin insulator between two conducting fluids. The active ingredient is just one extra rule: when the membrane voltage reaches a firing level, emit a spike and reset.
This section walks the construction in four steps. First, the membrane equation — the RC circuit specialised to a cell, with ion channels playing the role of resistors. Second, the reversal potentials at the end of those channels, via the Nernst equation. Third, the threshold-and-reset rule that completes the LIF model. Fourth, the two ways of wiring synaptic inputs in — current-based (CUBA) and conductance-based (COBA) — which together turn one cell into the building block of the pinglab models and notebooks.
The cell membrane as an RC circuit
A neuron’s membrane is a lipid bilayer, nm thick, separating an inside compartment (axoplasm, high , low ) from an outside one (extracellular fluid, high , low ). Electrically:
- The bilayer is an insulator. No free charge crosses it without help. By Ohm’s law in matter, its conductivity is essentially zero.
- Both the inside and outside fluids are conductors with — many orders of magnitude higher than the bilayer’s.
- That makes the membrane a capacitor in the parallel-plate sense, with capacitance per unit area .
- Embedded ion channels open and close to let specific ions through. While open, each channel contributes a conductance across the membrane.
Stacking all of this for a small patch of membrane and applying Kirchhoff’s current law gives
where the sum is over the channel types that are currently open, is the total open conductance of that type, and is the channel’s reversal potential — the voltage at which the net current of ion through its channel is zero. The driving term makes each open channel pull toward its own at a rate set by .
Collapse all the channels into a single passive “leak” conductance with reversal and the equation reduces to the canonical RC form,
with membrane time constant and steady state . This is the subthreshold dynamics of an LIF neuron — the equation it integrates whenever it is not currently spiking. The only remaining question before we can write down the full model is where the reversal potential comes from — and for that we need to leave electromagnetism for a moment and visit thermodynamics.
Ion gradients and the Nernst equation
Each ion species sits at a different concentration inside and outside the cell, actively maintained by pumps that burn ATP. Two forces act on an ion that crosses the membrane:
- Diffusion drives the ion from high concentration to low, by random thermal motion — the same statistical mechanics that produced the Maxwell–Boltzmann distribution in Particles in a Box. Fick’s law gives a flux .
- Drift acts because the ion has charge , so it feels the electric field across the membrane: , with the ionic mobility.
For each ion species at equilibrium, these two fluxes cancel. Setting , using the Einstein relation to link diffusion and mobility, and integrating across the membrane gives the Nernst equation:
This is the voltage at which the field-driven drift of ion exactly cancels its concentration-driven diffusion — its equilibrium, or reversal, potential. For mammalian body temperature (), the typical values are
| ion | inside (mM) | outside (mM) | |
|---|---|---|---|
| 140 | 5 | ||
| 15 | 145 | ||
| 10 | 110 | ||
| 1.2 |
The leak conductance used in the previous section is a mixture of mostly and channels, so the effective for the leak sits in the neighbourhood of — the cell’s resting potential. Mixed-cation excitatory channels (AMPA receptors) end up with a reversal near ; chloride-selective inhibitory channels (GABA-A receptors) sit near — exactly the values used in the COBA model. They are not free parameters; they fall out of the ion concentrations the cell maintains with its pumps.
Intuitively: every ion feels two restoring forces — thermal diffusion pushing toward equal concentrations, and the electric field across the membrane. The voltage at which they balance is that ion’s reversal potential. The cell spends ATP to keep the concentrations away from equilibrium, and the reversal potentials are the price of that maintenance.
Threshold and reset
The membrane equation derived above is passive: it leaks toward , never crosses any threshold, never spikes. A real neuron does fire — when its membrane voltage rises above a cascade of voltage-gated and channels opens, drives the membrane up to and back down in about a millisecond, and emits an action potential. The full mechanism is captured by the Hodgkin–Huxley model, which adds four nonlinear gating variables to the membrane equation.
The LIF idealisation throws all of that out. Instead of modelling the spike-shape dynamics, it just declares: when reaches a fixed threshold , an instantaneous spike is emitted and is snapped back to a reset voltage . Optionally, the cell enters a brief refractory period during which it is unresponsive — modelling the few-ms recovery time after a biological spike.
This is the only nonlinearity in LIF. The model is otherwise a linear ODE; the spike rule is what makes it neuron-like rather than just a leaky integrator.
Typical biophysical settings:
| symbol | name | typical value |
|---|---|---|
| spike threshold | ||
| post-spike reset | (often = ) | |
| refractory period | ||
| membrane time const |
The choice of where to put the reset is a modelling decision. Two common conventions:
- Hard reset: is a fixed value, usually . Any overshoot above threshold is discarded.
- Subtract reset: . Preserves overshoot, useful when integrating very fast inputs across long timesteps.
These choices show up explicitly in the pinglab CUBA implementation — reset_mode = “zero” vs reset_mode = “subtract”.
The full LIF model
Putting it all together — the subthreshold RC dynamics, the reversal-potential leak, and the threshold-and-reset rule — gives the canonical LIF neuron:
with and . Inputs come from synapses (other neurons’ spikes filtered through receptor channels) plus any experimental injection. The output is the spike train — the sequence of times at which crossed the threshold.
That is everything. Every term has a physical pedigree traceable back to Maxwell or to thermodynamics:
- from the bilayer’s geometry (Gauss’s law + parallel-plate capacitance).
- from the open leak channels (Ohm’s law in matter, with the channels playing the role of resistors).
- from the ion gradients (Nernst, equilibrium of diffusion and drift).
- , , from the biological behaviour of voltage-gated channels, abstracted into three numbers.
Intuitively: an LIF neuron is a leaky bucket with a trip lever. Input pours water in; the bucket leaks back to a baseline level ; if the water reaches a lip , the bucket tips, emits a “drop” (the spike), refills to , and starts again.
Synaptic input
A single LIF cell driven by an arbitrary is useful for analysis but not yet a part of a network. In a real circuit (or a simulation of one), every cell’s input comes from the spikes of other cells, filtered through synapses. A presynaptic spike at time does not deliver an instantaneous kick — postsynaptic receptor channels need a few milliseconds to open and close. The standard kernel is an exponential synapse: a brief jump at the spike time followed by exponential decay,
with on the order of milliseconds ( ms for AMPA, ms for GABA-A) and the synaptic weight (in conductance units). The state variable is then plugged into the membrane equation — but how it enters is what separates the two main families of synapse model.
Current-based synapses (CUBA)
In a CUBA synapse, is treated as a current and added directly to the membrane:
where the sum runs over all synapses, with positive for excitatory and negative for inhibitory. Each obeys its own exponential-synapse ODE.
The big advantage of CUBA is that the membrane equation stays linear in : each synapse contributes a fixed-shape post-synaptic potential (PSP) regardless of where the membrane currently sits. That makes the dynamics easy to analyse (sums of exponentials) and fast to simulate. The disadvantage is biological realism: a real synapse’s effect on the membrane does depend on — but a CUBA synapse contributes the same kick whether the cell is at rest, near threshold, or already saturated.
Conductance-based synapses (COBA)
In COBA, is treated as it actually is — a conductance — and the current it produces depends on the membrane’s distance from the synapse’s reversal potential:
Each synapse type has its own conductance obeying its own exponential synapse, and its own reversal potential set by the Nernst equation. In a typical excitatory / inhibitory split:
| family | transmitter | ||
|---|---|---|---|
| excitatory | AMPA (mixed cations) | ms | mV |
| inhibitory | GABA-A (chloride) | ms | mV |
Stacking the leak channel and the two synapse families gives the conductance-based LIF, i.e. the COBA subthreshold equation:
The same threshold-and-reset rule from the LIF section sits on top of this. The two synaptic conductances and each evolve via the exponential-synapse ODE, driven by spikes from upstream excitatory or inhibitory cells.
This is the model used throughout the pinglab COBANet implementation and every PING / COBA experiment in the notebooks.
What COBA gives you that CUBA doesn’t
Three things follow from the driving force in COBA that CUBA’s additive currents miss:
- Synaptic saturation. As approaches mV the excitatory driving force shrinks toward zero, so the same conductance produces less current. A cell can’t be driven above by excitation alone, no matter how much pours in.
- Shunting inhibition. Open inhibitory channels don’t just pull toward — they also raise the total conductance , which shortens the effective time constant and dampens the membrane’s response to every other input. CUBA has no equivalent because its inputs are additive.
- State-dependent coupling. The effective gain between a presynaptic spike and the postsynaptic voltage change depends on . This is what makes phase-locked phenomena like PING work — the gamma rhythm uses exactly this dependence to keep its phase tight.
Choice between them
A pragmatic guide:
- CUBA is the right choice when you want linearity, when firing rates are modest, when the membrane stays close to most of the time, or when you just need a fast network simulation. Most tutorial SNN code uses CUBA.
- COBA is the right choice when realism matters: any model studying gamma rhythms, balanced E/I networks, shunting, or biological calibration. The COBA, PING, and standard-snn rungs in the pinglab models page are the corresponding implementations.
Worked Examples
Five problems that span the previous sections. Each one uses material from one or more of Vector Calculus, Maxwell’s Equations, From Fields to Circuits, and The LIF Neuron.
Problem 1: Field of a uniformly charged sphere
Setup. A solid ball of radius carries total charge spread with uniform volume density . Find the electric field everywhere — inside and outside the ball — and verify that the differential form of Gauss’s law holds on the interior.
Strategy. Exploit spherical symmetry. Apply the integral form of Gauss’s law to two concentric spherical Gaussian surfaces — one outside the ball () and one inside (). Then differentiate the inside answer and check .
Solution. By spherical symmetry the field is radial, , depending only on . On a sphere of radius , and the integral is .
Outside (). The enclosed charge is the whole ball:
Outside the ball, the field is identical to that of a point charge at the centre. This is Coulomb’s law, recovered from Gauss + symmetry.
Inside (). The enclosed charge is now , so
The interior field grows linearly with and vanishes at the centre.
Differential check. Take the divergence of . In spherical coordinates for a radial vector field ,
which matches the differential form of Gauss’s law with on the interior. On the exterior, and one checks similarly that (any inverse-square radial field is divergence-free off the singularity).
Takeaway. Symmetry + the integral form gives the field cheaply; the differential form is the local consistency check. The two forms are related by the divergence theorem — the worked check above is essentially that theorem applied to one infinitesimal shell.
Problem 2: The electromagnetic wave equation
Setup. In vacuum (, ), Maxwell’s equations reduce to a coupled pair for and . Show that each field separately satisfies the wave equation
and that the propagation speed is .
Strategy. Take the curl of Faraday’s law, substitute the Ampère–Maxwell law on the right, and use the vector identity . In vacuum kills the first term.
Solution. Faraday in differential form:
Take the curl of both sides:
The left-hand side expands via the identity, and the right-hand side uses Ampère–Maxwell in vacuum ():
In vacuum Gauss’s law gives , so the gradient term drops out. Rearranging,
This is the wave equation. Comparing to the canonical form identifies the propagation speed
The same derivation with the curl applied to Ampère–Maxwell (and Faraday substituted on the right) gives the matching wave equation for .
Takeaway. The displacement-current term in Ampère–Maxwell is exactly what makes the wave equation work — without it, taking the curl of Faraday and plugging Ampère in gives (Laplace, not wave). The fact that the speed comes out as , a quantity measurable purely from electrostatics and magnetostatics, is the historical bridge from Maxwell’s equations to optics.
Problem 3: Self-discharge of a leaky capacitor
Setup. A parallel-plate capacitor has plate area and gap , filled with a lossy dielectric of permittivity and conductivity (no longer the perfect insulator of the textbook capacitor). Charge the plates to voltage at , then disconnect. The leak current through the dielectric discharges the plates. Find the time-constant of that discharge and show that it depends only on the material (, ), not on the geometry (, ).
Strategy. Use parallel-plate capacitance and the geometry of Ohm’s law in matter to write and separately, then form the RC time constant and see what cancels.
Solution. From the capacitance derivation above (Gauss’s law on a pillbox + voltage = field × gap),
From Ohm’s law in matter applied to the same geometry (the dielectric is a slab of cross-section , length , conductivity ),
The discharge dynamics is the RC equation with no external drive (, ),
with solution . Substituting the geometric expressions for and ,
The area and gap both cancel. The time constant is set entirely by the material: a slow-leaking dielectric (small ) gives a long , regardless of the capacitor’s shape.
For reference, for various media:
| medium | |
|---|---|
| good insulator (Teflon, S/m) | s, i.e. millions of years |
| pure water | s (microsecond) |
| salt water | s |
| metal | s (effectively instantaneous) |
| neuron’s lipid bilayer | to s (membrane time constant!) |
The last row is the link to The LIF Neuron: a neuron’s membrane is a leaky capacitor with set by the open ion channels, and the discharge time constant is exactly the membrane time constant that shows up in the LIF model.
Takeaway. Time constants of leaky capacitors are material properties, not geometric ones. A neuron’s membrane sits in a particular regime of that makes its comparable to the timescale of synaptic input — which is what allows it to integrate incoming spikes rather than passing them through instantly or holding them forever.
Problem 4: Resting potential of a real neuron
Setup. A neuron has the ion concentrations from the Nernst table: , , , , , (all in mM). At rest, the membrane has permeabilities (typical “at-rest” ratios; channels dominate). Find the resting potential.
Strategy. Compute the individual Nernst potentials, then combine them with the Goldman–Hodgkin–Katz (GHK) equation, which is the extension of Nernst to multiple permeable ions:
The cation concentrations are arranged “out / in”; chloride enters with inside / out swapped because it is negatively charged. Body temperature: at .
Solution. First the individual Nernst potentials. Using and of the ratios:
The cell at rest would sit at if were the only permeable ion. The other two pull it slightly off.
GHK numerator: . GHK denominator: .
The resting potential is about — close to but pulled positive by the small leak. Without permeability the cell would sit at ; the leak is what gives a finite “depolarisation gap” to spike threshold.
Takeaway. The resting potential is not any individual ion’s Nernst potential — it is a weighted average of all permeable species, weighted by their permeabilities. Because the cell’s permeability ratios are not 1:1:1, is dominated by the most-permeable ion () but pulled away from its Nernst potential by the others. The same equation, with different open-channel ratios, governs the membrane voltage during an action potential — permeability briefly dominates, pulling toward .
Problem 5: The f–I curve of a deterministic LIF neuron
Setup. An LIF neuron with membrane time constant , resting potential , threshold , hard reset to , and refractory period is driven by a constant input current . Compute its firing rate as a function of .
Strategy. Between spikes, the membrane obeys the RC equation with constant input. Solve the ODE for the time-to-threshold , add the refractory period, and invert to get .
Solution. With (the steady-state if the cell could stay subthreshold forever) and initial condition , the RC equation gives
(Subtracting from both sides if you prefer, .)
The neuron fires at the time when . Setting and solving for ,
Two regimes fall out:
- Sub-rheobase (, i.e. the steady state never reaches threshold). The argument of the log is negative, is undefined: the neuron never fires. The minimum current to fire is the rheobase
- Supra-rheobase (). The neuron fires every seconds, then waits before being able to integrate again. The interspike interval is , so the firing rate is
Limits.
- Just above rheobase (), the logarithm , so and . The f–I curve rises continuously from zero — no discontinuity at threshold.
- Far above rheobase (), the log , so and . The neuron saturates: it fires every refractory-period-worth of time, no faster.
A typical neuron has , , giving a maximum rate of . The curve is concave: shallow near rheobase, steeper at moderate inputs, then saturating.
Takeaway. The LIF f–I curve has a sharp rheobase (no firing below a threshold current) and a saturating maximum rate (set by the refractory period), with a smooth transition between them. This is the simplest analytically tractable input-output relation for any spiking neuron — every more elaborate model (CUBA, COBA, Hodgkin–Huxley) collapses to a qualitatively similar concave-saturating f–I curve, with the differences showing up in onset shape (gradual vs. discontinuous) and the precise saturation level.
Where this leads
The five sections trace a single chain: vector calculus → fields (Maxwell) → circuits (Ohm, capacitance, RC) → cells (LIF, COBA) → worked exercises that pin each link of the chain into place. A reader who can derive each of the five worked examples from scratch has internalised the material. The next step in the codebase is to wire many such cells into a network — the subject of CUBANet, COBANet, and every experiment in the notebooks.