What is Differentiation?
Calculus is the math of change. Every neuron model in NMA is about something changing over time — voltage rising, firing rate shifting. Calculus is how you describe that change precisely. There are two halves: differentiation and integration. Start here.
Differentiation answers one question: how fast is the output changing as you nudge the input?
The answer it gives you is called the derivative.
You can think about it two ways — and they're the same thing:
• In words: the rate of change.
• On a graph: the slope of the curve at a point — how steep it is right there.
The car example (this is the whole idea):
As you drive, the distance you've traveled changes with time. The derivative of distance, with respect to time, is your velocity — how fast distance is changing right now.
• Cruising at a steady speed? The distance climbs at a constant rate. The derivative is flat — same value everywhere.
• Speeding up and slowing down? The rate of change is different at different moments, so the derivative changes too.
Slow (small derivative) → distance barely moves in a moment. Fast (big derivative) → distance jumps a lot in that same moment.
The sign tells you the direction. Derivative positive → the function is going up. Negative → going down. And right where it flips — the very top of a hill or bottom of a valley — the slope is zero. (You'll use that later to find peaks and best-answers.)
Which derivatives are actually worth remembering?
You took these in school — here's the honest short list that matters for neuroscience. You really only need to recognize these:
• Constant → 0 (a flat line doesn't change)
• Power rule: tⁿ → n·tⁿ⁻¹ (so t → 1, t² → 2t, t³ → 3t²)
• Exponential: eᵗ → eᵗ (the special one — itself!)
• Natural log: ln(t) → 1/t
• sin(t) → cos(t) and cos(t) → −sin(t)
That's it. The power rule and eᵗ are the two you'll see constantly.
Don't stress about memorizing the rest. In real work you almost never differentiate by hand — np.gradient(y, t) does it for you (below). What matters is the intuition: derivative = slope, sign = direction, zero = peak/valley. The rules above are just for recognizing what's going on.
In Python, you don't compute derivatives by hand. One function does it: np.gradient(y, t) — give it your data y and the time points t, and it hands back the slope at every point. Hit Run below to see it. ↓
import numpy as npimport matplotlib.pyplot as pltt = np.linspace(0, 10, 100) # time pointsy = t**2 # the function: distance = t²dydt = np.gradient(y, t) # the derivative (velocity) at every pointplt.figure(figsize=(6, 4))plt.plot(t, y, label="function y = t²")plt.plot(t, dydt, label="derivative dy/dt = 2t")plt.xlabel("t")plt.legend()plt.title("A function and its derivative")plt.show()Press Run — the parabola is the function, the straight line is its derivative (2t). Try changing y = t**2 to y = np.sin(t) and run again!