These math functions return a double precision value and take a double precision argument. The exception is atan2() which has two double precision arguments.
Arguments that are out of range give an argument domain diagnostic.
These functions call the library routines supplied by the compiler.
absolute value
>>> h.abs(-42.2)
42.2
See Vector.abs() for the Vector class.
Note
In Python code, use Python's abs function, which works on both numbers and numpy arrays:
>>> abs(-42.2)
42.2
>>> abs(-3 + 4j)
5.0
>>> v = h.Vector([1, 6, -2, -65])
>>> abs(v.as_numpy())
array([ 1., 6., 2., 65.])
returns the integer part of its argument (truncates toward 0).
>>> h.int(3.14)
3.0
>>> h.int(-3.14)
-3.0
Note
In Python code, use Python's int function instead. The behavior is slightly different in that the Python function returns an int type instead of a double:
>>> int(-3.14)
-3
>>> int(3.14)
3
square root
see Vector.sqrt() for the Vector class.
Note
Consider using Python's built in math.sqrt instead.
returns the exponential function to the base e
When exp is used in model descriptions, it is often the case that the cvode variable step integrator extrapolates voltages to values which return out of range values for the exp (often used in rate functions). There were so many of these false warnings that it was deemed better to turn off the warning message when Cvode is active. In any case the return value is exp(700). This message is not turned off at the interpreter level or when cvode is not active.
from neuron import h
for i in range(6,12):
print i, h.exp(i)
Note
Consider using Python's built in math.exp instead.
logarithm to the base e see Vector.log() for the Vector class.
Note
Consider using Python's built in math.log instead.
logarithm to the base 10
see Vector.log10() for the Vector class.
Note
Consider using Python's built in math.log10 instead.
trigonometric function of radian argument.
see Vector.sin()
Note
Consider using Python's built in math.cos instead.
trigonometric function of radian argument.
see Vector.sin() for the Vector class.
Note
Consider using Python's built in math.sin instead.
hyperbolic tangent. see Vector.tanh() for the Vector class.
Note
Consider using Python's built in math.tanh instead.
returns the arc-tangent of y/x in the range \(-\pi/2\) to \(\pi/2\). (x > 0)
Note
Consider using Python's built in math.atan instead.
Example:
from neuron import h h.atan2(0,0) for i in range(-1,2): print h.atan2(i*1e-6, 10) for i in range(-1,2): print h.atan2(i*1e-6, -10) for i in range(-1,2): print h.atan2(10, i*1e-6) for i in range(-1,2): print h.atan2(-10, i*1e-6) h.atan2(10,10) h.atan2(10,-10) h.atan2(-10,10) h.atan2(-10,-10)Note
Consider using Python's built in math.atan2 instead.
normalized error function
Note
In Python 2.7 and Python 3.2+, use math.erf instead.