neuromodels.utils.vtrap

neuromodels.utils.vtrap(x, y)[source]

Traps for zero in denominator of rate eqns.

HH-style model rate equations often contain expressions that are equivalent to

\[x / (\exp(u) - 1),\]

where \(u = x / y\). From Taylor series approximation, one can find that the above expression is approximated by

\[y (1 - u / 2)\]

if \(u << 1\).

This approximation ensures that indeterminate cases are handled properly.

Parameters
xfloat or ndarray

Numerator in the exponential function argument.

yfloat or ndarray

Denominator in the exponential function argument.

Returns
vtrapfloat or ndarray

The result of the evaluation.

References

Inspired by the vtrap function in the NEURON simulator; github.com/neuronsimulator/nrn/blob/master/src/nrnoc/hh.mod