# The NumPy Module vs the math Module

For more information about concepts covered in this lesson, you can check out:

**00:00**
One of the most prominent libraries in Python for mathematical calculations is Numerical Python, or NumPy. In this lesson, we’ll discuss the differences between NumPy and the `math`

module.

**00:13**
If you’re working with arrays of numerical values, then you definitely want to check out the NumPy module. The NumPy module offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transform functions, and just in general, a plethora of functions to work with arrays of numerical values.

**00:35**
NumPy, however, is not part of the Python standard library, and so you’ll have to use something like `pip`

to install it on your machine.

**00:43**
The main advantage of NumPy versus `math`

is that math operations in NumPy are optimized to work with NumPy arrays, or ndarrays. All looping in NumPy is done using optimized C functions, which is another reason why you may want to use NumPy if you’re working with arrays of numerical values instead of creating your own functions that are written in Python and using basic `for`

loops.

**01:08**
One nice feature with NumPy is that many of the functions that we talked about—like the exponential function, sine and cosine, the natural logarithm—they can be applied directly to NumPy arrays, and therefore return NumPy arrays that you can then work with. However, if you plan on working mostly with scalar values, then you may just want to stick with the `math`

module functions.

**01:31**
These can be faster than their NumPy equivalents, and the reason is because the NumPy functions, they’re going to convert the values that are passed in as inputs into arrays, and so this will slow down the computation if you plan on doing many computations with these functions.

**01:49**
Now, we can’t really go even into the basics of NumPy in this video course on the `math`

module, so instead, I’ll refer you to a realpython.com tutorial on NumPy called Your First Steps Into Data Science in Python.

**02:03**
Look up *NumPy* in the search field and this should be one of the very first courses that comes up. All right, so let’s wrap things up with a summary.

Become a Member to join the conversation.