+15 XP

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.

python
import numpy as np
import matplotlib.pyplot as plt
# Parameters of one excitatory spike
J = 1.0        # synaptic amplitude
tau_s = 1.0    # synaptic time constant (how fast it fades)
t_sp = 1.0     # the spike happens at t = 1 ms
dt = 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 strip
rectangle_areas = PSP * dt
# 2) add them up cumulatively to get charge transferred over time
numerical_integral = np.cumsum(rectangle_areas)
print('Total charge transferred =', round(numerical_integral[-1], 2))  # ~2.5
fig, (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.