The Product Rule
So far the functions were simple. But often a function is two functions multiplied together — and you can't just differentiate each piece separately. That's what the product rule is for.
If f(t) = u(t) · v(t) then d f/dt = v · (du/dt) + u · (dv/dt)
Derivative of a product = (first × derivative of second) + (second × derivative of first). Not just du/dt × dv/dt!
Where this shows up in neuroscience: the shape of a postsynaptic potential — the little bump of voltage after a neuron receives a spike — is described by the alpha function:
f(t) = t · e^(−t/τ)
A product of u(t) = t and v(t) = e^(−t/τ). τ (tau) is the synaptic time constant.
Wait — what actually IS this, and why do we need it?
When one neuron fires, it sends a signal across the synapse to the next neuron. The receiving neuron's voltage doesn't snap up and stay there — it rises quickly, peaks, then fades back down to rest. That little bump of voltage is a postsynaptic potential (PSP).
The alpha function is just the simplest formula that recreates that bump shape — and look why it's a product:
• the t part pulls the voltage up from zero,
• the e^(−t/τ) part drags it back down toward rest (τ sets how fast it fades).
A rising piece × a falling piece = a rise-and-fall bump. We need it to realistically simulate how signals actually arrive at neurons. And because it's a product, finding its slope (how fast the voltage is changing) needs the product rule.
So we apply the product rule with u = t and v = e^(−t/τ):
• du/dt = 1 (the derivative of t)
• dv/dt = −(1/τ)·e^(−t/τ)
Plug into the rule:
df/dt = e^(−t/τ)·(1) + t·(−(1/τ)·e^(−t/τ))
Why can't I just use np.gradient for du/dt here? Great question — because the product rule needs the exact derivative of each piece. The derivative of u = t is exactly 1, by the power rule. np.gradient only gives an approximation from data points — close, but not exact. When you're building a formula by hand (analytically), you use the exact rules; np.gradient is for when you only have data, not a formula.
Reading the alpha-function plot: the top curve (the PSP itself) rises then falls — a bump. The bottom curve (its derivative) starts positive while the bump is climbing, crosses zero exactly at the peak, then goes negative as the bump falls back down. That sign flip is the derivative telling you "now going up... now at the top... now going down."

Top (red): the PSP voltage bump. Bottom (blue): its derivative — positive while the bump rises, zero right at the peak, negative while it falls.