First page Back Continue Last page Overview Graphics

Mathematical Functions

NumPy provides also umpteen mathematical functions, which can be applied on a per-element bases on arrays:

>>> x = np.array([2,4,9], float)

>>> np.sqrt(x)

array([ 1.41421356, 2. , 3. ])

>>>

Some functions:

abs, sign, sqrt, log, log10, exp, sin, cos, tan, arcsin, arccos,arctan, sinh, cosh, tanh, arcsinh, arccosh, and arctanh.

π and e are also available in NumPy:

>>> np.pi

3.1415926535897931

>>> np.e

2.7182818284590451