Integration in Action: Synaptic Charge
Time to use integration for a real neuroscience question: how much electric charge does one incoming spike dump onto a neuron? The answer is literally the area under the voltage bump — an integral. We'll compute it with a Riemann sum, in code you can run.
The setup. When a spike arrives, it creates a little voltage bump — a postsynaptic potential (PSP). Its shape is the alpha function you met in the product-rule lesson:
PSP(t) = J · t · exp( −(t − t_sp) / τ_s )
J = synaptic strength, t_sp = spike time, τ_s = how fast the bump fades.
The total charge transferred = the area under that bump = its integral. And we compute the area the way we just learned: every value of PSP is a rectangle height, multiply by the step width dt to get areas, then add them all up with a running (cumulative) sum.
Hit Run — the left plot is the voltage bump, the right plot is the charge piling up as we integrate.
import numpy as npimport matplotlib.pyplot as plt# Parameters of one excitatory spikeJ = 1.0 # synaptic amplitudetau_s = 1.0 # synaptic time constant (how fast it fades)t_sp = 1.0 # the spike happens at t = 1 msdt = 0.1 # step size (rectangle width)t = np.arange(0, 10, dt)# The PSP voltage bump (alpha function). Only defined after the spike.PSP = J * t * np.exp(-(t - t_sp) / tau_s)# --- Numerical integration (Riemann sum) ---# 1) each PSP value is a rectangle height; width is dt -> area of each striprectangle_areas = PSP * dt# 2) add them up cumulatively to get charge transferred over timenumerical_integral = np.cumsum(rectangle_areas)print('Total charge transferred =', round(numerical_integral[-1], 2)) # ~2.5fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 3.5))ax1.plot(t, PSP, color='crimson')ax1.set_title('PSP voltage bump'); ax1.set_xlabel('time (ms)')ax2.plot(t, numerical_integral, color='green')ax2.set_title('Charge transferred (integral)'); ax2.set_xlabel('time (ms)')plt.tight_layout(); plt.show()Press Run. The key two lines are the integration: multiply by dt to get rectangle areas, then np.cumsum to add them up. Total charge ends up a little over 2.5. Try changing J or tau_s and re-run — bigger, slower bumps transfer more charge.
The takeaway: area = np.cumsum(values dt) is* numerical integration — a Riemann sum in one line. You just measured a real biophysical quantity (charge) as the area under a curve. That's integration earning its keep.