** Advanced mathematical operators
:PROPERTIES:
:date: 2013/02/27 14:49:13
:updated: 2013/03/06 18:29:46
:categories: python
:END:
The primary library we will consider is mod:numpy, which provides many mathematical functions, statistics as well as support for linear algebra. For a complete listing of the functions available, see http://docs.scipy.org/doc/numpy/reference/routines.math.html. We begin with the simplest functions.
#+BEGIN_SRC python
import numpy as np
print np.sqrt(2)
#+END_SRC
#+RESULTS:
: 1.41421356237
*** Exponential and logarithmic functions
Here is the exponential function.
#+BEGIN_SRC python
import numpy as np
print np.exp(1)
#+END_SRC
#+RESULTS:
: 2.71828182846
There are two logarithmic functions commonly used, the natural log function func:numpy.log and the base10 logarithm func:numpy.log10.
#+BEGIN_SRC python
import numpy as np
print np.log(10)
print np.log10(10) # base10
#+END_SRC
#+RESULTS:
: 2.30258509299
: 1.0
There are many other intrinsic functions available in mod:numpy which we will eventually cover. First, we need to consider how to create our own functions.