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 R3\mathbb{R}^3 with Cartesian coordinates (x,y,z)(x, y, z). 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.

aba · b = 0.28
Drag either tip. The dashed segment drops a perpendicular from a onto the line of b; the grey arrow along b is the projection, and its signed length equals (a · b) / |b|. Make the two vectors perpendicular and the dot product goes to zero; rotate past 90° and it goes negative.
ab  =  iaibi  =  a1b1+a2b2+a3b3  =  abcosθ,\mathbf{a} \cdot \mathbf{b} \;=\; \sum_{i} a_i b_i \;=\; a_1 b_1 + a_2 b_2 + a_3 b_3 \;=\; |\mathbf{a}|\,|\mathbf{b}|\,\cos\theta,

where θ\theta is the angle between them. It measures how much a\mathbf{a} projects onto b\mathbf{b}; it is zero exactly when the two are perpendicular. Dot products of the form FdA\mathbf{F} \cdot d\mathbf{A} and Fd\mathbf{F} \cdot d\boldsymbol{\ell} 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.

ab(a × b)_z = 0.82
Drag either tip. The shaded region is the parallelogram a and b span; its signed area is (a × b)z. ⊙ means the cross product points out of the page (positive); ⊗ means into the page; swap a and b and the symbol flips — that's the antisymmetry. Collapse them to a line and the area drops to zero.
a×b  =  (a2b3a3b2,  a3b1a1b3,  a1b2a2b1),a×b=absinθ.\mathbf{a} \times \mathbf{b} \;=\; \bigl(a_2 b_3 - a_3 b_2,\; a_3 b_1 - a_1 b_3,\; a_1 b_2 - a_2 b_1\bigr), \qquad |\mathbf{a} \times \mathbf{b}| = |\mathbf{a}|\,|\mathbf{b}|\,\sin\theta.

The direction follows the right-hand rule. Unlike the dot product, this one is anti-symmetric: a×b=b×a\mathbf{a} \times \mathbf{b} = -\,\mathbf{b} \times \mathbf{a}. We use it implicitly via the curl operator below.

Intuitively: a vector pointing along the axle of the rotation that would carry a\mathbf{a} onto b\mathbf{b}, with length equal to the area of the parallelogram they span.

Gradient

Takes a scalar field f(x,y,z)f(x, y, z) to a vector field.

+f = 0.07 |∇f| = 0.83
Small arrows are ∇f sampled on a grid covering the whole frame, for a two-bump scalar field with a peak (filled dot, +) and a valley (hollow dot, ). Every arrow points the way f increases fastest at that point. Drag the handle to place a probe; the big arrow is ∇f there, and the readout shows f and |∇f|. ∇f always points uphill — toward the peak, away from the valley — and shrinks to zero at the extrema themselves.
f  =  (fx,  fy,  fz).\nabla f \;=\; \left(\frac{\partial f}{\partial x},\; \frac{\partial f}{\partial y},\; \frac{\partial f}{\partial z}\right).

At every point it gives the direction of steepest increase of ff and a magnitude equal to the rate of that increase. The symbol =(x,y,z)\nabla = \bigl(\partial_x,\, \partial_y,\, \partial_z\bigr) 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 ff as the altitude — the arrow pointing straight up the steepest path.

Jacobian

Takes a vector field F:RnRm\mathbf{F} : \mathbb{R}^n \to \mathbb{R}^m to a matrix of partial derivatives at each point. For F(x)=(F1(x),,Fm(x))\mathbf{F}(\mathbf{x}) = \bigl(F_1(\mathbf{x}), \dots, F_m(\mathbf{x})\bigr),

JF(x)  =  (F1/x1F1/xnFm/x1Fm/xn).J_\mathbf{F}(\mathbf{x}) \;=\; \begin{pmatrix} \partial F_1 / \partial x_1 & \cdots & \partial F_1 / \partial x_n \\ \vdots & \ddots & \vdots \\ \partial F_m / \partial x_1 & \cdots & \partial F_m / \partial x_n \end{pmatrix}.

The (i,j)(i, j) entry is the rate at which the ii-th output component changes with respect to the jj-th input variable. Special cases: when F\mathbf{F} is scalar-valued (m=1m = 1) the Jacobian is a row vector — the transpose of the gradient. When F\mathbf{F} is a coordinate transformation (m=nm = n), detJF|\det J_\mathbf{F}| 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 x0\mathbf{x}_0, F(x0+δx)F(x0)+JF(x0)δx\mathbf{F}(\mathbf{x}_0 + \delta\mathbf{x}) \approx \mathbf{F}(\mathbf{x}_0) + J_\mathbf{F}(\mathbf{x}_0)\,\delta\mathbf{x}. For a dynamical system x˙=F(x)\dot{\mathbf{x}} = \mathbf{F}(\mathbf{x}) with a fixed point at x\mathbf{x}^\star (where F(x)=0\mathbf{F}(\mathbf{x}^\star) = 0), the linearised dynamics are δx˙=JF(x)δx\dot{\delta\mathbf{x}} = J_\mathbf{F}(\mathbf{x}^\star)\,\delta\mathbf{x}, and the eigenvalues of JF(x)J_\mathbf{F}(\mathbf{x}^\star) 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 F=(Fx,Fy,Fz)\mathbf{F} = (F_x, F_y, F_z) to a scalar field.

+∇·F = 0.00
Arrows show a vector field F with a source (filled dot, +) and a sink (hollow dot, ) — flow radiates out of one and converges into the other. Drag the probe to read ∇·F. The inner ring is the imagined test volume; the dashed ring sitsoutside it when divergence is positive (the volume is being pushed outward), andinside it when negative (the volume is being squeezed inward). The gap between the two rings scales with |∇·F|. Halfway between source and sink — and far from both — divergence is zero and only the inner ring is drawn.
F  =  Fxx+Fyy+Fzz.\nabla \cdot \mathbf{F} \;=\; \frac{\partial F_x}{\partial x} + \frac{\partial F_y}{\partial y} + \frac{\partial F_z}{\partial z}.

It measures the net outflow of F\mathbf{F} 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.

(∇×F)_z = 0.00
Arrows show a vector field F with two vortices — a counter-clockwise one (filled dot, ↺) and a clockwise one (hollow dot, ↻). Drag the probe to read (∇×F)zat that point; the curved arrow inside the probe ring is a "paddle wheel" that would spin the same way (counter-clockwise for positive curl, clockwise for negative), with arc length scaling with |∇×F|. Between the vortices, and far from both, the field still flows but doesn't twist — curl is zero.
×F  =  (FzyFyz,  FxzFzx,  FyxFxy).\nabla \times \mathbf{F} \;=\; \left(\frac{\partial F_z}{\partial y} - \frac{\partial F_y}{\partial z},\; \frac{\partial F_x}{\partial z} - \frac{\partial F_z}{\partial x},\; \frac{\partial F_y}{\partial x} - \frac{\partial F_x}{\partial y}\right).

At every point it measures the local rotation of F\mathbf{F} — 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 F\mathbf{F} through a surface SS is the integral of its normal component across that surface.

+n∫ F·n dℓ = -0.24
Drag either endpoint of the line segment through the field. The small arrows along the segment are the local F·n contributions — outward (along the chosen normal n) when positive, opposite when negative. The readout is their sum: the flux of F across the segment. Rotate the segment by swinging an endpoint and watch the sign flip when the normal swaps sides; line the segment up along the field and the flux drops to zero (nothing is crossing it).
ΦF(S)  =  SFdA  =  S(Fn)dA,\Phi_{\mathbf{F}}(S) \;=\; \int_{S} \mathbf{F} \cdot d\mathbf{A} \;=\; \int_{S} (\mathbf{F} \cdot \mathbf{n})\, dA,

where n\mathbf{n} is the unit normal to SS at each point and dAdA is the scalar area element. In 2D the surface degenerates to a curve and dAddA \to d\ell, the arclength element. Each infinitesimal patch contributes FndA\mathbf{F} \cdot \mathbf{n}\, dA — 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 n\mathbf{n} points is part of the orientation conventions below. Flipping n\mathbf{n} 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 V\partial V wrapping a volume VV) carry the outward normal. The surface element dAd\mathbf{A} points away from the enclosed volume, so FdA\mathbf{F} \cdot d\mathbf{A} counts flux leaving VV as positive and flux entering as negative. This is what makes the divergence theorem a “net outflow” statement.
  • Open surfaces with boundary (an SS bounded by a curve S\partial S) carry a normal dAd\mathbf{A} that the user picks, and the boundary curve S\partial S is then oriented by the right-hand rule — curl your right-hand fingers around S\partial S, and your thumb points along dAd\mathbf{A}. Flip dAd\mathbf{A} and the direction of integration around S\partial S 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 S\partial S relative to dAd\mathbf{A}, 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 F\mathbf{F} defined on a volume VV with closed boundary surface V\partial V, the integral of the divergence over the volume equals the flux through the boundary.

+∫∫ ∇·F dA = 1.21∮ F·n dℓ = 1.21difference = 0.002
Drag the disc-shaped region R. The small arrows on the boundary show F·n — local flux out of (outward arrow) or into (inward arrow) R. The two readouts are the two sides of the theorem: ∫∫R ∇·F dA on top, ∮∂R F·n don the bottom. They stay equal regardless of where you place the region: enclose only the source (both positive), only the sink (both negative), both (cancel), neither (both ~ zero).
V(F)dV  =  VFdA.\int_{V} (\nabla \cdot \mathbf{F})\, dV \;=\; \oint_{\partial V} \mathbf{F} \cdot d\mathbf{A}.

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 VV has to cross V\partial V on its way out.

Stokes’ theorem

For a vector field F\mathbf{F} on an oriented surface SS with boundary curve S\partial S, the flux of the curl through SS equals the line integral around S\partial S.

∫∫ (∇×F)_z dA = 1.21∮ F·dℓ = 1.21difference = 0.002
Drag the disc-shaped surface S. The arrows on its boundary are the local tangential contributions F·d — going CCW around the disc when positive, CW when negative. The two readouts are the two sides of Stokes' theorem: ∫∫S (∇×F)z dA on top, ∮∂S F·don the bottom. Enclose only the CCW vortex (both positive), only the CW one (both negative), both (cancel), or neither (both ~ zero).
S(×F)dA  =  SFd.\int_{S} (\nabla \times \mathbf{F}) \cdot d\mathbf{A} \;=\; \oint_{\partial S} \mathbf{F} \cdot d\boldsymbol{\ell}.

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, ff and gg are scalar fields and A\mathbf{A}, B\mathbf{B}, C\mathbf{C} are vector fields. The first group are pure-algebra identities about dot/cross products; the rest are differential identities about how \nabla combines with itself or distributes through products.

Triple products.

a(b×c)  =  b(c×a)  =  c(a×b).\mathbf{a} \cdot (\mathbf{b} \times \mathbf{c}) \;=\; \mathbf{b} \cdot (\mathbf{c} \times \mathbf{a}) \;=\; \mathbf{c} \cdot (\mathbf{a} \times \mathbf{b}).

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.

a×(b×c)  =  b(ac)    c(ab).\mathbf{a} \times (\mathbf{b} \times \mathbf{c}) \;=\; \mathbf{b}\,(\mathbf{a} \cdot \mathbf{c}) \;-\; \mathbf{c}\,(\mathbf{a} \cdot \mathbf{b}).

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 2f(f)=x2f+y2f+z2f\nabla^2 f \equiv \nabla\cdot(\nabla f) = \partial_x^2 f + \partial_y^2 f + \partial_z^2 f is the divergence of the gradient of a scalar field.

×(f)  =  0.\nabla \times (\nabla f) \;=\; \mathbf{0}.

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.

(×F)  =  0.\nabla \cdot (\nabla \times \mathbf{F}) \;=\; 0.

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 B=×A\mathbf{B} = \nabla\times\mathbf{A} when B=0\nabla\cdot\mathbf{B} = 0.

×(×F)  =  (F)    2F.\nabla \times (\nabla \times \mathbf{F}) \;=\; \nabla(\nabla \cdot \mathbf{F}) \;-\; \nabla^2 \mathbf{F}.

The curl-of-curl identity. This is what turns Maxwell’s two curl equations into the wave equation: taking ×\nabla\times of Faraday and substituting Ampère–Maxwell on the right invokes this identity on the left, and E=0\nabla\cdot\mathbf{E} = 0 in vacuum kills the first term.

Product rules. The differential operators distribute through products in patterns analogous to the ordinary calculus product rule.

(fg)  =  fg  +  gf.\nabla(f g) \;=\; f\,\nabla g \;+\; g\,\nabla f. (fA)  =  f(A)  +  Af.\nabla \cdot (f \mathbf{A}) \;=\; f\,(\nabla \cdot \mathbf{A}) \;+\; \mathbf{A} \cdot \nabla f. ×(fA)  =  f(×A)  +  (f)×A.\nabla \times (f \mathbf{A}) \;=\; f\,(\nabla \times \mathbf{A}) \;+\; (\nabla f) \times \mathbf{A}. (A×B)  =  B(×A)    A(×B).\nabla \cdot (\mathbf{A} \times \mathbf{B}) \;=\; \mathbf{B} \cdot (\nabla \times \mathbf{A}) \;-\; \mathbf{A} \cdot (\nabla \times \mathbf{B}).

The last of these is what proves Poynting’s theorem in electromagnetism: applied to S=E×B/μ0\mathbf{S} = \mathbf{E} \times \mathbf{B}/\mu_0 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

E=ρϵ0Gauss’s law of electricityB=0Gauss’s law of magnetism×E=BtFaraday’s law of induction×B=μ0J+μ0ϵ0EtAmpeˋre–Maxwell law\begin{aligned} \nabla \cdot \mathbf{E} &= \frac{\rho}{\epsilon_0} && \text{Gauss's law of electricity} \\[4pt] \nabla \cdot \mathbf{B} &= 0 && \text{Gauss's law of magnetism} \\[4pt] \nabla \times \mathbf{E} &= -\,\frac{\partial \mathbf{B}}{\partial t} && \text{Faraday's law of induction} \\[4pt] \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t} && \text{Ampère–Maxwell law} \end{aligned}

Here E\mathbf{E} and B\mathbf{B} are the electric and magnetic fields, ρ\rho is the charge density, J\mathbf{J} the current density, and ϵ0\epsilon_0, μ0\mu_0 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

VEdA=Qencϵ0Gauss’s law of electricityVBdA=0Gauss’s law of magnetismSEd=ddtSBdAFaraday’s law of inductionSBd=μ0Ienc+μ0ϵ0ddtSEdAAmpeˋre–Maxwell law\begin{aligned} \oint_{\partial V} \mathbf{E} \cdot d\mathbf{A} &= \frac{Q_{\text{enc}}}{\epsilon_0} && \text{Gauss's law of electricity} \\[4pt] \oint_{\partial V} \mathbf{B} \cdot d\mathbf{A} &= 0 && \text{Gauss's law of magnetism} \\[4pt] \oint_{\partial S} \mathbf{E} \cdot d\boldsymbol{\ell} &= -\,\frac{d}{dt} \int_{S} \mathbf{B} \cdot d\mathbf{A} && \text{Faraday's law of induction} \\[4pt] \oint_{\partial S} \mathbf{B} \cdot d\boldsymbol{\ell} &= \mu_0 I_{\text{enc}} + \mu_0 \epsilon_0 \,\frac{d}{dt} \int_{S} \mathbf{E} \cdot d\mathbf{A} && \text{Ampère–Maxwell law} \end{aligned}

Here QencQ_{\text{enc}} is the total charge enclosed by the closed surface V\partial V, IencI_{\text{enc}} is the total current passing through the open surface SS, and the orientation conventions for dAd\mathbf{A} and dd\boldsymbol{\ell} 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 \nabla \cdot equations into the two flux statements through closed surfaces. Applied to F=E\mathbf{F} = \mathbf{E}, it converts E=ρ/ϵ0\nabla \cdot \mathbf{E} = \rho/\epsilon_0 into the enclosed-charge version of Gauss’s law; the same move applied to B\mathbf{B} gives the magnetic Gauss law with zero on the right.
  • Stokes’ theorem turns the two ×\nabla \times equations into the two circulation-vs-flux-derivative statements. Applied to F=E\mathbf{F} = \mathbf{E}, it converts Faraday’s ×E=B/t\nabla \times \mathbf{E} = -\partial \mathbf{B}/\partial t into the integral form above (and the minus sign carries over directly); applied to F=B\mathbf{F} = \mathbf{B}, 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 S\partial S relative to dAd\mathbf{A}, 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.

E  =  ρϵ0.\nabla \cdot \mathbf{E} \;=\; \frac{\rho}{\epsilon_0}.

Integral form.

VEdA  =  Qencϵ0.\oint_{\partial V} \mathbf{E} \cdot d\mathbf{A} \;=\; \frac{Q_{\text{enc}}}{\epsilon_0}.

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 V\partial V you draw, the total outward flux of E\mathbf{E} across it is the total charge QencQ_{\text{enc}} inside, divided by ϵ0\epsilon_0. The link between the two is the divergence theorem applied to F=E\mathbf{F} = \mathbf{E}.

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):

symbolnameunits
E\mathbf{E}electric fieldV/m (volts per metre)
ρ\rhocharge densityC/m³ (coulombs per cubic metre)
QencQ_{\text{enc}}charge enclosed by V\partial VC (coulombs)
V\partial Vclosed surface (boundary of a volume VV)m² when integrated
dAd\mathbf{A}outward-pointing surface elementm² (vector, normal to V\partial V)
ϵ0\epsilon_0vacuum permittivity8.854×10128.854 \times 10^{-12} F/m (farads/m, equivalent C²/(N·m²))

The constant ϵ0\epsilon_0 is what sets the scale: a single 1C1\,\mathrm{C} point charge produces a total flux of 1/ϵ01.13×1011Vm1/\epsilon_0 \approx 1.13 \times 10^{11}\,\mathrm{V\,m} — large because a coulomb is a lot of charge. In everyday terms, ϵ0\epsilon_0 encodes “how stiffly the vacuum opposes electric field lines”: a small ϵ0\epsilon_0 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.

B  =  0.\nabla \cdot \mathbf{B} \;=\; 0.

Integral form.

VBdA  =  0.\oint_{\partial V} \mathbf{B} \cdot d\mathbf{A} \;=\; 0.

The two forms again say the same thing at different scales, linked by the divergence theorem. The differential form says the divergence of B\mathbf{B} 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 Qenc/ϵ0Q_{\text{enc}}/\epsilon_0 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):

symbolnameunits
B\mathbf{B}magnetic fieldT (tesla, equivalent V·s/m² or N/(A·m))
V\partial Vclosed surfacem² when integrated
dAd\mathbf{A}outward-pointing surface elementm² (vector, normal to V\partial V)

No constant appears on the right-hand side — the law’s content is the equation =0= 0. If a magnetic monopole were ever discovered, it would acquire a ρm/μ0\rho_m/\mu_0-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.

×E  =  Bt.\nabla \times \mathbf{E} \;=\; -\,\frac{\partial \mathbf{B}}{\partial t}.

Integral form.

SEd  =  ddtSBdA.\oint_{\partial S} \mathbf{E} \cdot d\boldsymbol{\ell} \;=\; -\,\frac{d}{dt} \int_{S} \mathbf{B} \cdot d\mathbf{A}.

The two forms are linked by Stokes’ theorem. The differential form is a local identity: the curl of E\mathbf{E} at every point equals the negative time-derivative of B\mathbf{B} there. The integral form is the global consequence: the total E\mathbf{E}-circulation around any closed loop S\partial S equals the negative rate of change of the B\mathbf{B}-flux through any surface SS 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 S\partial S to dAd\mathbf{A}.

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):

symbolnameunits
E\mathbf{E}electric fieldV/m
B\mathbf{B}magnetic fieldT
S\partial Sclosed boundary curve of SSm when integrated
dd\boldsymbol{\ell}tangent line element to S\partial Sm (vector, right-hand-oriented relative to dAd\mathbf{A})
SSopen surface bounded by S\partial Sm² when integrated
dAd\mathbf{A}surface element on SSm² (vector, normal to SS)
/t\partial/\partial tpartial derivative in timeper second

No constants appear on the right-hand side beyond the minus sign — the relation between E\mathbf{E} and tB\partial_t \mathbf{B} is exact, with no scale factor. The whole content of the law sits in that minus sign and the geometric pairing EB\mathbf{E} \leftrightarrow \mathbf{B}.

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.

×B  =  μ0J  +  μ0ϵ0Et.\nabla \times \mathbf{B} \;=\; \mu_0 \mathbf{J} \;+\; \mu_0 \epsilon_0 \,\frac{\partial \mathbf{E}}{\partial t}.

Integral form.

SBd  =  μ0Ienc  +  μ0ϵ0ddtSEdA.\oint_{\partial S} \mathbf{B} \cdot d\boldsymbol{\ell} \;=\; \mu_0 I_{\text{enc}} \;+\; \mu_0 \epsilon_0 \,\frac{d}{dt} \int_{S} \mathbf{E} \cdot d\mathbf{A}.

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 B\mathbf{B} at every point has two sources: a real current density J\mathbf{J}, and a changing electric field tE\partial_t \mathbf{E}. The integral form says the B\mathbf{B}-circulation around a loop equals μ0\mu_0 times the current piercing any surface spanning it, plus μ0ϵ0\mu_0\epsilon_0 times the rate of change of E\mathbf{E}-flux through the same surface.

The displacement-current term μ0ϵ0tE\mu_0 \epsilon_0\, \partial_t \mathbf{E} was Maxwell’s invention; without it, the original Ampère law ×B=μ0J\nabla \times \mathbf{B} = \mu_0 \mathbf{J} is inconsistent with charge conservation (taking \nabla\cdot of both sides would imply J=0\nabla\cdot \mathbf{J} = 0 always, which is false whenever charge density changes in time). Adding the term not only patches that inconsistency but also produces the wave equation 2E=μ0ϵ0t2E\nabla^2 \mathbf{E} = \mu_0 \epsilon_0\, \partial_t^2 \mathbf{E} when combined with Faraday’s law in vacuum — the propagation speed comes out as c=1/μ0ϵ0c = 1/\sqrt{\mu_0 \epsilon_0}, 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 E\mathbf{E} generates a circulating B\mathbf{B} which generates a circulating E\mathbf{E}, and the pair propagates through empty space at speed cc.

Symbols and units (SI):

symbolnameunits
B\mathbf{B}magnetic fieldT
J\mathbf{J}current densityA/m² (amperes per square metre)
E\mathbf{E}electric fieldV/m
IencI_{\text{enc}}current piercing SSA (amperes)
S\partial Sboundary curve of SSm when integrated
dd\boldsymbol{\ell}tangent line elementm
SSopen surface bounded by S\partial Sm² when integrated
dAd\mathbf{A}surface element on SS
μ0\mu_0vacuum permeability1.257×1061.257 \times 10^{-6} N/A² (henries/m)
ϵ0\epsilon_0vacuum permittivity8.854×10128.854 \times 10^{-12} F/m

The two constants μ0\mu_0 and ϵ0\epsilon_0 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: c=1/μ0ϵ02.998×108m/sc = 1/\sqrt{\mu_0\epsilon_0} \approx 2.998 \times 10^{8}\,\mathrm{m/s}. 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

τdVdt  =  (VV)  +  RIext(t),τ  =  RC,\tau\,\frac{dV}{dt} \;=\; -(V - V_\infty) \;+\; R\,I_{\text{ext}}(t), \qquad \tau \;=\; RC,

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 E\mathbf{E}, B\mathbf{B}, ρ\rho and J\mathbf{J}. In a conductor there is one extra relation, supplied by the material rather than by Maxwell: an electric field E\mathbf{E} pushes the free charges around, and the rate at which they move per unit area, per unit time, is the current density J\mathbf{J}. To linear order,

J  =  σE,\mathbf{J} \;=\; \sigma\, \mathbf{E},

where σ\sigma is the conductivity of the material (siemens per metre, S/m\mathrm{S/m}). 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 D=ϵE\mathbf{D} = \epsilon\mathbf{E} plays for dielectrics.

What conductivity actually is

A field E\mathbf{E} exerts a force qEq\mathbf{E} 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 τc\tau_c, the mean free time between collisions. Between collisions it picks up a velocity Δv=(q/m)Eτc\Delta v = (q/m)\mathbf{E}\,\tau_c, then loses it again. Averaged over many collisions, every carrier acquires a steady drift velocity

vd  =  μE,μ  =  qτcm,\mathbf{v}_d \;=\; \mu\,\mathbf{E},\qquad \mu \;=\; \frac{q\,\tau_c}{m},

where μ\mu is the mobility of that carrier (units m2/(Vs)\mathrm{m^2/(V\,s)}). With nn carriers per unit volume, each carrying charge qq, the current density is just nqvdn q \mathbf{v}_d, so

  σ  =  nqμ  =  nq2τcm.  \boxed{\;\sigma \;=\; n\,q\,\mu \;=\; \frac{n\,q^2\,\tau_c}{m}.\;}

Conductivity is therefore a product of “how many carriers there are” (nn), “how much charge each one carries” (qq), and “how easily each one drifts in a field” (μ\mu, or equivalently τc/m\tau_c/m). A metal has n1028m3n \sim 10^{28}\,\mathrm{m^{-3}} near-free electrons and τc1014s\tau_c \sim 10^{-14}\,\mathrm{s}, giving σ107S/m\sigma \sim 10^7\,\mathrm{S/m}. Salt water has 1026m3\sim 10^{26}\,\mathrm{m^{-3}} dissolved ions of charge ±e\pm e, but the mobility of an ion in water is roughly six orders of magnitude smaller than an electron in a metal, so σ1S/m\sigma \sim 1\,\mathrm{S/m}. A neuron’s cytoplasm and the extracellular fluid sit in the same 1S/m\sim 1\,\mathrm{S/m} ballpark. The lipid bilayer at the membrane is the opposite extreme: essentially no mobile ions at all, σ1013S/m\sigma \sim 10^{-13}\,\mathrm{S/m}. That is why the membrane behaves as a capacitor in the next section and the fluids on either side behave as wires.

Intuitively: σ\sigma 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 J=σE\mathbf{J} = \sigma\mathbf{E} to the familiar V=IRV = IR we first need to nail down what voltage means. Voltage (or potential difference) between two points AA and BB is the work done per unit charge to carry a test charge from BB to AA against the electric field:

VAB  =  BAEd.V_{AB} \;=\; -\int_{B}^{A} \mathbf{E} \cdot d\boldsymbol{\ell}.

Units: joules per coulomb \equiv volts (V\mathrm{V}). The minus sign is bookkeeping: VAB>0V_{AB} > 0 when AA is at higher potential than BB, so a positive charge would want to fall from AA to BB — like a ball wanting to roll downhill.

Two consequences make voltage a useful circuit-level concept:

  • Path-independence. In the electrostatic limit, ×E=0\nabla\times\mathbf{E} = 0 (no time-varying B\mathbf{B}), 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: Ed=0\oint \mathbf{E}\cdot d\boldsymbol{\ell} = 0V=0\sum V = 0 around the loop. (When tB\partial_t \mathbf{B} 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 LL with constant E\mathbf{E} along it, the integral collapses to V=ELV = E\,L — the special case the textbook starts with.

Ohm’s law in integral form

Substituting V=ELV = EL and I=JAI = JA into J=σE\mathbf{J} = \sigma\mathbf{E} for the uniform wire gives

I  =  VR,R  =  LσA,I \;=\; \frac{V}{R}, \qquad R \;=\; \frac{L}{\sigma A},

with RR the wire’s resistance (ohms, Ω=V/A\Omega = \mathrm{V/A}). For neurons the two relevant values of σ\sigma — high for the fluids, \sim 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 AA separated by a gap dd, holding charge +Q+Q and Q-Q. The integral form of Gauss’s law applied to a pillbox surface straddling one plate gives a uniform field between the plates of magnitude

E  =  Qϵ0A.E \;=\; \frac{Q}{\epsilon_0\, A}.

Integrating that field across the gap gives the voltage between the plates, V=Ed=Qd/(ϵ0A)V = E\,d = Q d / (\epsilon_0 A). Rearranging,

Q  =  CV,C  =  ϵ0Ad,Q \;=\; C\, V, \qquad C \;=\; \frac{\epsilon_0\, A}{d},

where CC is the capacitance (farads, F=C/V\mathrm{F} = \mathrm{C/V}). The relation Q=CVQ = CV 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,

I  =  dQdt  =  CdVdt.I \;=\; \frac{dQ}{dt} \;=\; C\,\frac{dV}{dt}.

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 RR in parallel with a capacitor CC, with one end of both held at a reference voltage VV_\infty and the other driven by an external current source Iext(t)I_{\text{ext}}(t). Kirchhoff’s current law at the top node says the input current splits between charging the capacitor and leaking through the resistor,

Iext(t)  =  CdVdt  +  VVR.I_{\text{ext}}(t) \;=\; C\,\frac{dV}{dt} \;+\; \frac{V - V_\infty}{R}.

Rearranging gives the RC equation:

  τdVdt  =  (VV)  +  RIext(t),τ  =  RC.  \boxed{\;\tau\,\frac{dV}{dt} \;=\; -(V - V_\infty) \;+\; R\,I_{\text{ext}}(t),\qquad \tau \;=\; R\,C.\;}

With Iext=0I_{\text{ext}} = 0 the voltage relaxes exponentially toward VV_\infty on the timescale τ\tau. With a steady IextI_{\text{ext}} the steady-state shifts to V+RIextV_\infty + R\, I_{\text{ext}}. 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 τeff\tau_{\text{eff}} and VV_\infty 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 VV crosses some firing level θ\theta, emit a spike and snap VV 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, 5\sim 5 nm thick, separating an inside compartment (axoplasm, high K+K^+, low Na+Na^+) from an outside one (extracellular fluid, high Na+Na^+, low K+K^+). 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 σ1S/m\sigma \sim 1\,\mathrm{S/m} — 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 Cm1μF/cm2C_m \sim 1\,\mu\mathrm{F}/\mathrm{cm}^2.
  • Embedded ion channels open and close to let specific ions through. While open, each channel contributes a conductance gchannelg_{\text{channel}} across the membrane.

Stacking all of this for a small patch of membrane and applying Kirchhoff’s current law gives

CmdVdt  =  kgk(VEk)  +  Iext(t),C_m\,\frac{dV}{dt} \;=\; -\sum_k g_k\,(V - E_k) \;+\; I_{\text{ext}}(t),

where the sum is over the channel types kk that are currently open, gkg_k is the total open conductance of that type, and EkE_k is the channel’s reversal potential — the voltage at which the net current of ion kk through its channel is zero. The driving term (VEk)(V - E_k) makes each open channel pull VV toward its own EkE_k at a rate set by gkg_k.

Collapse all the channels into a single passive “leak” conductance gLg_L with reversal ELE_L and the equation reduces to the canonical RC form,

  CmdVdt  =  gL(VEL)  +  Iext(t),  \boxed{\;C_m\,\frac{dV}{dt} \;=\; -g_L\,(V - E_L) \;+\; I_{\text{ext}}(t),\;}

with membrane time constant τm=Cm/gL\tau_m = C_m / g_L and steady state V=ELV_\infty = E_L. 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 ELE_L 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 kk 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 Jdiff=Dc\mathbf{J}_{\text{diff}} = -D\,\nabla c.
  • Drift acts because the ion has charge qkq_k, so it feels the electric field across the membrane: Jdrift=μqkcE\mathbf{J}_{\text{drift}} = \mu\, q_k\, c\, \mathbf{E}, with μ\mu the ionic mobility.

For each ion species at equilibrium, these two fluxes cancel. Setting Jdiff+Jdrift=0\mathbf{J}_{\text{diff}} + \mathbf{J}_{\text{drift}} = 0, using the Einstein relation D=μkBTD = \mu\, k_B T to link diffusion and mobility, and integrating across the membrane gives the Nernst equation:

Ek  =  kBTqkln ⁣(ck,outck,in).E_k \;=\; \frac{k_B T}{q_k}\,\ln\!\left(\frac{c_{k,\text{out}}}{c_{k,\text{in}}}\right).

This is the voltage at which the field-driven drift of ion kk exactly cancels its concentration-driven diffusion — its equilibrium, or reversal, potential. For mammalian body temperature (T310KT \approx 310\,\mathrm{K}), the typical values are

ioninside (mM)outside (mM)EkE_k
K+K^+140586mV-86\,\mathrm{mV}
Na+Na^+15145+61mV+61\,\mathrm{mV}
ClCl^-1011064mV-64\,\mathrm{mV}
Ca2+Ca^{2+}10410^{-4}1.2+125mV+125\,\mathrm{mV}

The leak conductance gLg_L used in the previous section is a mixture of mostly K+K^+ and ClCl^- channels, so the effective ELE_L for the leak sits in the neighbourhood of 65mV-65\,\mathrm{mV} — the cell’s resting potential. Mixed-cation excitatory channels (AMPA receptors) end up with a reversal near Ee0mVE_e \approx 0\,\mathrm{mV}; chloride-selective inhibitory channels (GABA-A receptors) sit near Ei75mVE_i \approx -75\,\mathrm{mV} — 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 ELE_L, never crosses any threshold, never spikes. A real neuron does fire — when its membrane voltage rises above 50mV\sim -50\,\mathrm{mV} a cascade of voltage-gated Na+Na^+ and K+K^+ channels opens, drives the membrane up to +30mV\sim +30\,\mathrm{mV} 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 VV reaches a fixed threshold VthV_{\text{th}}, an instantaneous spike is emitted and VV is snapped back to a reset voltage VresetV_{\text{reset}}. Optionally, the cell enters a brief refractory period τref\tau_{\text{ref}} during which it is unresponsive — modelling the few-ms recovery time after a biological spike.

if V(t)Vth:emit spike,V(t+)Vreset,cell refractory for τref.\text{if } V(t) \geq V_{\text{th}} : \quad \text{emit spike}, \quad V(t^+) \leftarrow V_{\text{reset}}, \quad \text{cell refractory for } \tau_{\text{ref}}.

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:

symbolnametypical value
VthV_{\text{th}}spike threshold50mV-50\,\mathrm{mV}
VresetV_{\text{reset}}post-spike reset65mV-65\,\mathrm{mV} (often = ELE_L)
τref\tau_{\text{ref}}refractory period13ms1\text{–}3\,\mathrm{ms}
τm\tau_mmembrane time const1020ms10\text{–}20\,\mathrm{ms}

The choice of where to put the reset VresetV_{\text{reset}} is a modelling decision. Two common conventions:

  • Hard reset: VresetV_{\text{reset}} is a fixed value, usually ELE_L. Any overshoot above threshold is discarded.
  • Subtract reset: VVVthV \leftarrow V - V_{\text{th}}. Preserves overshoot, useful when integrating very fast inputs across long timesteps.

These choices show up explicitly in the pinglab CUBA implementationreset_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:

  τmdVdt  =  (VEL)  +  RmIext(t),if VVth ⁣:  S1,VVreset.  \boxed{\; \begin{aligned} \tau_m\,\frac{dV}{dt} \;&=\; -(V - E_L) \;+\; R_m\, I_{\text{ext}}(t), \\[4pt] \text{if } V \geq V_{\text{th}}\!:\;& \quad S \leftarrow 1, \quad V \leftarrow V_{\text{reset}}. \end{aligned} \;}

with τm=Cm/gL\tau_m = C_m / g_L and Rm=1/gLR_m = 1/g_L. Inputs Iext(t)I_{\text{ext}}(t) come from synapses (other neurons’ spikes filtered through receptor channels) plus any experimental injection. The output is the spike train {tk}\{t_k\} — the sequence of times at which VV crossed the threshold.

That is everything. Every term has a physical pedigree traceable back to Maxwell or to thermodynamics:

  • CmC_m from the bilayer’s geometry (Gauss’s law + parallel-plate capacitance).
  • gLg_L from the open leak channels (Ohm’s law in matter, with the channels playing the role of resistors).
  • ELE_L from the ion gradients (Nernst, equilibrium of diffusion and drift).
  • VthV_{\text{th}}, VresetV_{\text{reset}}, τref\tau_{\text{ref}} 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 ELE_L; if the water reaches a lip VthV_{\text{th}}, the bucket tips, emits a “drop” (the spike), refills to VresetV_{\text{reset}}, and starts again.

Synaptic input

A single LIF cell driven by an arbitrary Iext(t)I_{\text{ext}}(t) 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 tkt_k 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,

τsyndgdt  =  g  +  Wkδ(ttk),\tau_{\text{syn}}\,\frac{dg}{dt} \;=\; -g \;+\; W \sum_{k}\delta(t - t_k),

with τsyn\tau_{\text{syn}} on the order of milliseconds (2\sim 2 ms for AMPA, 9\sim 9 ms for GABA-A) and WW the synaptic weight (in conductance units). The state variable g(t)g(t) 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, g(t)g(t) is treated as a current and added directly to the membrane:

CmdVdt  =  gL(VEL)  +  igi(t)  +  Iext(t),C_m\,\frac{dV}{dt} \;=\; -g_L\,(V - E_L) \;+\; \sum_i g_i(t) \;+\; I_{\text{ext}}(t),

where the sum runs over all synapses, with positive WW for excitatory and negative for inhibitory. Each gig_i obeys its own exponential-synapse ODE.

The big advantage of CUBA is that the membrane equation stays linear in VV: 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 VV — 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, g(t)g(t) 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:

Isyn,k(t)  =  gk(t)(VEk).I_{\text{syn},\,k}(t) \;=\; -\,g_k(t)\,(V - E_k).

Each synapse type kk has its own conductance gk(t)g_k(t) obeying its own exponential synapse, and its own reversal potential EkE_k set by the Nernst equation. In a typical excitatory / inhibitory split:

familytransmitterτsyn\tau_{\text{syn}}EkE_k
excitatoryAMPA (mixed cations)2\sim 2 msEe0E_e \approx 0 mV
inhibitoryGABA-A (chloride)9\sim 9 msEi75E_i \approx -75 mV

Stacking the leak channel and the two synapse families gives the conductance-based LIF, i.e. the COBA subthreshold equation:

  CmdVdt  =  gL(VEL)    ge(t)(VEe)    gi(t)(VEi)  +  Iext(t).  \boxed{\; C_m\,\frac{dV}{dt} \;=\; -g_L\,(V - E_L) \;-\; g_e(t)\,(V - E_e) \;-\; g_i(t)\,(V - E_i) \;+\; I_{\text{ext}}(t). \;}

The same threshold-and-reset rule from the LIF section sits on top of this. The two synaptic conductances ge(t)g_e(t) and gi(t)g_i(t) 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 (VEk)(V - E_k) driving force in COBA that CUBA’s additive currents miss:

  1. Synaptic saturation. As VV approaches Ee0E_e \approx 0 mV the excitatory driving force shrinks toward zero, so the same conductance produces less current. A cell can’t be driven above EeE_e by excitation alone, no matter how much geg_e pours in.
  2. Shunting inhibition. Open inhibitory channels don’t just pull VV toward EiE_i — they also raise the total conductance gtotg_{\text{tot}}, which shortens the effective time constant τeff=Cm/gtot\tau_{\text{eff}} = C_m/g_{\text{tot}} and dampens the membrane’s response to every other input. CUBA has no equivalent because its inputs are additive.
  3. State-dependent coupling. The effective gain between a presynaptic spike and the postsynaptic voltage change depends on VV. 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 ELE_L 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 RR carries total charge QQ spread with uniform volume density ρ0=Q/(43πR3)\rho_0 = Q / (\tfrac{4}{3}\pi R^3). 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 (r>Rr > R) and one inside (r<Rr < R). Then differentiate the inside answer and check E=ρ/ϵ0\nabla\cdot\mathbf{E} = \rho/\epsilon_0.

Solution. By spherical symmetry the field is radial, E(r)=E(r)r^\mathbf{E}(\mathbf{r}) = E(r)\,\hat{\mathbf{r}}, depending only on r=rr = |\mathbf{r}|. On a sphere of radius rr, EdA=E(r)dA\mathbf{E}\cdot d\mathbf{A} = E(r)\,dA and the integral is E(r)4πr2E(r)\cdot 4\pi r^2.

Outside (r>Rr > R). The enclosed charge is the whole ball:

E(r)4πr2  =  Qϵ0Eout(r)  =  Q4πϵ0r2.E(r)\cdot 4\pi r^2 \;=\; \frac{Q}{\epsilon_0} \quad\Rightarrow\quad E_{\text{out}}(r) \;=\; \frac{Q}{4\pi\epsilon_0\, r^2}.

Outside the ball, the field is identical to that of a point charge QQ at the centre. This is Coulomb’s law, recovered from Gauss + symmetry.

Inside (r<Rr < R). The enclosed charge is now ρ043πr3=Q(r/R)3\rho_0 \cdot \tfrac{4}{3}\pi r^3 = Q\,(r/R)^3, so

E(r)4πr2  =  Q(r/R)3ϵ0Ein(r)  =  Q4πϵ0R3r  =  ρ03ϵ0r.E(r)\cdot 4\pi r^2 \;=\; \frac{Q (r/R)^3}{\epsilon_0} \quad\Rightarrow\quad E_{\text{in}}(r) \;=\; \frac{Q}{4\pi\epsilon_0\, R^3}\, r \;=\; \frac{\rho_0}{3\epsilon_0}\, r.

The interior field grows linearly with rr and vanishes at the centre.

Differential check. Take the divergence of Ein\mathbf{E}_{\text{in}}. In spherical coordinates for a radial vector field E(r)r^E(r)\hat{\mathbf{r}},

E  =  1r2r(r2E)  =  1r2r ⁣(ρ03ϵ0r3)  =  ρ0ϵ0,\nabla\cdot\mathbf{E} \;=\; \frac{1}{r^2}\frac{\partial}{\partial r}\bigl(r^2 E\bigr) \;=\; \frac{1}{r^2}\frac{\partial}{\partial r}\!\left(\frac{\rho_0}{3\epsilon_0}\, r^3\right) \;=\; \frac{\rho_0}{\epsilon_0},

which matches the differential form of Gauss’s law with ρ=ρ0\rho = \rho_0 on the interior. On the exterior, ρ=0\rho = 0 and one checks similarly that Eout=0\nabla\cdot\mathbf{E}_{\text{out}} = 0 (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 (ρ=0\rho = 0, J=0\mathbf{J} = 0), Maxwell’s equations reduce to a coupled pair for E\mathbf{E} and B\mathbf{B}. Show that each field separately satisfies the wave equation

2E  =  μ0ϵ02Et2,\nabla^2 \mathbf{E} \;=\; \mu_0\epsilon_0\, \frac{\partial^2 \mathbf{E}}{\partial t^2},

and that the propagation speed is c=1/μ0ϵ0c = 1/\sqrt{\mu_0\epsilon_0}.

Strategy. Take the curl of Faraday’s law, substitute the Ampère–Maxwell law on the right, and use the vector identity ×(×F)=(F)2F\nabla\times(\nabla\times\mathbf{F}) = \nabla(\nabla\cdot\mathbf{F}) - \nabla^2\mathbf{F}. In vacuum E=0\nabla\cdot\mathbf{E} = 0 kills the first term.

Solution. Faraday in differential form:

×E  =  Bt.\nabla\times\mathbf{E} \;=\; -\frac{\partial \mathbf{B}}{\partial t}.

Take the curl of both sides:

×(×E)  =  t(×B).\nabla\times(\nabla\times\mathbf{E}) \;=\; -\frac{\partial}{\partial t}(\nabla\times\mathbf{B}).

The left-hand side expands via the identity, and the right-hand side uses Ampère–Maxwell in vacuum (J=0\mathbf{J} = 0):

(E)2E  =  t ⁣(μ0ϵ0Et)  =  μ0ϵ02Et2.\nabla(\nabla\cdot\mathbf{E}) - \nabla^2 \mathbf{E} \;=\; -\frac{\partial}{\partial t}\!\left(\mu_0\epsilon_0\, \frac{\partial \mathbf{E}}{\partial t}\right) \;=\; -\mu_0\epsilon_0\, \frac{\partial^2 \mathbf{E}}{\partial t^2}.

In vacuum Gauss’s law gives E=0\nabla\cdot\mathbf{E} = 0, so the gradient term drops out. Rearranging,

  2E  =  μ0ϵ02Et2.  \boxed{\;\nabla^2 \mathbf{E} \;=\; \mu_0\epsilon_0\, \frac{\partial^2 \mathbf{E}}{\partial t^2}.\;}

This is the wave equation. Comparing to the canonical form 2u=(1/c2)t2u\nabla^2 u = (1/c^2)\,\partial_t^2 u identifies the propagation speed

c  =  1μ0ϵ0    2.998×108m/s.c \;=\; \frac{1}{\sqrt{\mu_0\epsilon_0}} \;\approx\; 2.998\times 10^8\,\mathrm{m/s}.

The same derivation with the curl applied to Ampère–Maxwell (and Faraday substituted on the right) gives the matching wave equation for B\mathbf{B}.

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 2E=0\nabla^2 \mathbf{E} = 0 (Laplace, not wave). The fact that the speed cc comes out as 1/μ0ϵ01/\sqrt{\mu_0\epsilon_0}, 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 AA and gap dd, filled with a lossy dielectric of permittivity ϵ\epsilon and conductivity σ\sigma (no longer the perfect insulator of the textbook capacitor). Charge the plates to voltage V0V_0 at t=0t = 0, 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 (ϵ\epsilon, σ\sigma), not on the geometry (AA, dd).

Strategy. Use parallel-plate capacitance and the geometry of Ohm’s law in matter to write CC and RR 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),

C  =  ϵAd.C \;=\; \frac{\epsilon\, A}{d}.

From Ohm’s law in matter applied to the same geometry (the dielectric is a slab of cross-section AA, length dd, conductivity σ\sigma),

R  =  dσA.R \;=\; \frac{d}{\sigma\, A}.

The discharge dynamics is the RC equation with no external drive (Iext=0I_{\text{ext}} = 0, V=0V_\infty = 0),

τdVdt  =  V,τ  =  RC,\tau\,\frac{dV}{dt} \;=\; -V,\qquad \tau \;=\; R C,

with solution V(t)=V0et/τV(t) = V_0\, e^{-t/\tau}. Substituting the geometric expressions for RR and CC,

τ  =  RC  =  dσAϵAd  =  ϵσ.\tau \;=\; R\, C \;=\; \frac{d}{\sigma A}\cdot\frac{\epsilon A}{d} \;=\; \frac{\epsilon}{\sigma}.

The area AA and gap dd both cancel. The time constant is set entirely by the material: a slow-leaking dielectric (small σ\sigma) gives a long τ\tau, regardless of the capacitor’s shape.

For reference, ϵ/σ\epsilon/\sigma for various media:

mediumϵ/σ\epsilon/\sigma
good insulator (Teflon, σ1025\sigma \sim 10^{-25} S/m)1015\sim 10^{15} s, i.e. millions of years
pure water106\sim 10^{-6} s (microsecond)
salt water1010\sim 10^{-10} s
metal1018\sim 10^{-18} s (effectively instantaneous)
neuron’s lipid bilayer103\sim 10^{-3} to 10210^{-2} s (membrane time constant!)

The last row is the link to The LIF Neuron: a neuron’s membrane is a leaky capacitor with σ\sigma set by the open ion channels, and the discharge time constant τm=Cm/gL1020ms\tau_m = C_m / g_L \sim 10\text{–}20\,\mathrm{ms} 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 ϵ/σ\epsilon/\sigma that makes its τm\tau_m 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: [K+]in=140[K^+]_{\text{in}} = 140, [K+]out=5[K^+]_{\text{out}} = 5, [Na+]in=15[Na^+]_{\text{in}} = 15, [Na+]out=145[Na^+]_{\text{out}} = 145, [Cl]in=10[Cl^-]_{\text{in}} = 10, [Cl]out=110[Cl^-]_{\text{out}} = 110 (all in mM). At rest, the membrane has permeabilities PK:PNa:PCl=1:0.04:0.45P_K : P_{Na} : P_{Cl} = 1 : 0.04 : 0.45 (typical “at-rest” ratios; K+K^+ 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:

Vrest  =  kBTeln ⁣(PK[K+]out+PNa[Na+]out+PCl[Cl]inPK[K+]in+PNa[Na+]in+PCl[Cl]out).V_{\text{rest}} \;=\; \frac{k_B T}{e}\,\ln\!\left( \frac{P_K [K^+]_{\text{out}} + P_{Na}[Na^+]_{\text{out}} + P_{Cl}[Cl^-]_{\text{in}}}{P_K [K^+]_{\text{in}} + P_{Na}[Na^+]_{\text{in}} + P_{Cl}[Cl^-]_{\text{out}}}\right).

The cation concentrations are arranged “out / in”; chloride enters with inside / out swapped because it is negatively charged. Body temperature: kBT/e=26.7mVk_B T / e = 26.7\,\mathrm{mV} at T=310KT = 310\,\mathrm{K}.

Solution. First the individual Nernst potentials. Using kBT/e=26.7mVk_B T / e = 26.7\,\mathrm{mV} and ln\ln of the ratios:

EK=26.7ln(5/140)  =  26.7(3.33)  =  89mV,ENa=26.7ln(145/15)  =  26.72.27  =  +61mV,ECl=26.7ln(110/10)  =  26.72.40  =  64mV(sign flipped for anion).\begin{aligned} E_K &= 26.7\,\ln(5/140) \;=\; 26.7 \cdot (-3.33) \;=\; -89\,\mathrm{mV}, \\ E_{Na} &= 26.7\,\ln(145/15) \;=\; 26.7 \cdot 2.27 \;=\; +61\,\mathrm{mV}, \\ E_{Cl} &= -26.7\,\ln(110/10) \;=\; -26.7 \cdot 2.40 \;=\; -64\,\mathrm{mV} \quad(\text{sign flipped for anion}). \end{aligned}

The cell at rest would sit at EKE_K if K+K^+ were the only permeable ion. The other two pull it slightly off.

GHK numerator: 15+0.04145+0.4510=5+5.8+4.5=15.31\cdot 5 + 0.04\cdot 145 + 0.45\cdot 10 = 5 + 5.8 + 4.5 = 15.3. GHK denominator: 1140+0.0415+0.45110=140+0.6+49.5=190.11\cdot 140 + 0.04\cdot 15 + 0.45\cdot 110 = 140 + 0.6 + 49.5 = 190.1.

Vrest  =  26.7ln(15.3/190.1)  =  26.7(2.52)  =  67mV.V_{\text{rest}} \;=\; 26.7\,\ln(15.3 / 190.1) \;=\; 26.7\cdot(-2.52) \;=\; -67\,\mathrm{mV}.

The resting potential is about 67mV-67\,\mathrm{mV} — close to EK=89mVE_K = -89\,\mathrm{mV} but pulled 22mV\sim 22\,\mathrm{mV} positive by the small Na+Na^+ leak. Without Na+Na^+ permeability the cell would sit at EKE_K; the Na+Na^+ 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, VrestV_{\text{rest}} is dominated by the most-permeable ion (K+K^+) 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 — Na+Na^+ permeability briefly dominates, pulling VV toward ENa+60mVE_{Na} \approx +60\,\mathrm{mV}.

Problem 5: The f–I curve of a deterministic LIF neuron

Setup. An LIF neuron with membrane time constant τm\tau_m, resting potential Vrest=ELV_{\text{rest}} = E_L, threshold VthV_{\text{th}}, hard reset to Vreset=ELV_{\text{reset}} = E_L, and refractory period τref\tau_{\text{ref}} is driven by a constant input current Iext=II_{\text{ext}} = I. Compute its firing rate f(I)f(I) as a function of II.

Strategy. Between spikes, the membrane obeys the RC equation with constant input. Solve the ODE for the time-to-threshold T(I)T(I), add the refractory period, and invert to get f=1/(T+τref)f = 1/(T + \tau_{\text{ref}}).

Solution. With V=EL+RmIV_\infty = E_L + R_m I (the steady-state if the cell could stay subthreshold forever) and initial condition V(0)=ELV(0) = E_L, the RC equation gives

V(t)  =  V+(ELV)et/τm  =  V(1et/τm)+ELet/τm.V(t) \;=\; V_\infty + (E_L - V_\infty)\, e^{-t/\tau_m} \;=\; V_\infty\,(1 - e^{-t/\tau_m}) + E_L\, e^{-t/\tau_m}.

(Subtracting ELE_L from both sides if you prefer, VEL=RmI(1et/τm)V - E_L = R_m I\,(1 - e^{-t/\tau_m}).)

The neuron fires at the time TT when V(T)=VthV(T) = V_{\text{th}}. Setting Vth=EL+RmI(1eT/τm)V_{\text{th}} = E_L + R_m I\,(1 - e^{-T/\tau_m}) and solving for TT,

T(I)  =  τmln ⁣(RmIRmI(VthEL)).T(I) \;=\; \tau_m\,\ln\!\left(\frac{R_m I}{R_m I - (V_{\text{th}} - E_L)}\right).

Two regimes fall out:

  • Sub-rheobase (RmI<VthELR_m I < V_{\text{th}} - E_L, i.e. the steady state never reaches threshold). The argument of the log is negative, TT is undefined: the neuron never fires. The minimum current to fire is the rheobase
Irh  =  VthELRm.I_{\text{rh}} \;=\; \frac{V_{\text{th}} - E_L}{R_m}.
  • Supra-rheobase (I>IrhI > I_{\text{rh}}). The neuron fires every T(I)T(I) seconds, then waits τref\tau_{\text{ref}} before being able to integrate again. The interspike interval is T+τrefT + \tau_{\text{ref}}, so the firing rate is
  f(I)  =  1τref+τmln ⁣RmIRmI(VthEL)  .  \boxed{\;f(I) \;=\; \frac{1}{\tau_{\text{ref}} + \tau_m\,\ln\!\dfrac{R_m I}{R_m I - (V_{\text{th}} - E_L)}}\;.\;}

Limits.

  • Just above rheobase (IIrh+I \to I_{\text{rh}}^+), the logarithm \to \infty, so TT \to \infty and f0f \to 0. The f–I curve rises continuously from zero — no discontinuity at threshold.
  • Far above rheobase (II \to \infty), the log (VthEL)/(RmI)0\to (V_{\text{th}} - E_L)/(R_m I) \to 0, so T0T \to 0 and f1/τreff \to 1/\tau_{\text{ref}}. The neuron saturates: it fires every refractory-period-worth of time, no faster.

A typical neuron has τm=10ms\tau_m = 10\,\mathrm{ms}, τref=2ms\tau_{\text{ref}} = 2\,\mathrm{ms}, giving a maximum rate of 500Hz500\,\mathrm{Hz}. 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.