All cells in animal body tissues are electrically polarized. I.e. there is voltage
difference V across the cell's membrane (membrane potential).
This electrical polarization results from different Na, Ca and K ions
consentrations inside and outside cells (due to the electrochemical gradient).
Polarization is maintaining by voltage-gated protein structures embedded in the membrane
called ion pumps and ion channels. The Hodgkin-Huxley model  describes how action potentials
in neurons are initiated and propagated
dV/dt = -(iK + iNa + il )/Cm ,
where Cm = 1 μF/cm2 is membrane's capacitance,
iNa , iK are Na, K ion currents,
il is a small leakage current caused by other ions
iK = 36 n4(V - 12),
iNa = 120 m3h (V + 115),
il = 0.3 (V + 10.613),
dy/dt = αy - (αy +
βy )y = (y∞ - y)/τy ,
τy = 1/(αy + βy ),
y∞ = αy /(αy + βy ), y is one of potassium n, fast activation m or slow inactivation h gates.
αn = 0.01 (V + 10) / (exp((V + 10)/10) -1),
βn = 0.125 exp(V/80),
αm = 0.1 (V + 25) / (exp((V + 25)/10) - 1),
βm = 4 exp(V/18),
αh = 0.07 exp(V/20),
βh = 1 / (exp((V + 30)/10) + 1).
τn(E)/10 (ms) are ploted below (E = -V)
here 0 ≤ E ≤ 150 (mV), 0 ≤ y ≤ 1.
So the minimum time is τm (100) ~ 0.13 and the maximum one is
τh (0) ~ 8.5 (ms).
You can see below action potential dynamics in the HH model.
A sufficiently strong depolarization (increase in E)
causes the voltage-sensitive sodium channels to open (due to fast m gate).
The increasing voltage in turn causes even more sodium channels to open,
which pushes V still further. This positive feedback continues until
the sodium channels are fully open. However, raised voltage also slowly shuts them
off by the h gate. The sodium channels become inactivated. At the same time,
the raised voltage opens voltage-sensitive potassium channels, driving membrane
back towards the resting E = 0 value.
The script makes 1000 it time steps dt.
You can change initial E and gates values.