What are the fundamental differences between the functions in Python's math module and their equivalents in the NumPy library?
Asked
Active
Viewed 61 times
1
-
Does this answer your question? [What is the difference between import numpy and import math](https://stackoverflow.com/questions/41648058/what-is-the-difference-between-import-numpy-and-import-math) – wjandrea Feb 26 '23 at 16:50
-
Does this answer your question? [What is the difference between math.exp and numpy.exp and why do numpy creators choose to introduce exp again?](https://stackoverflow.com/questions/30712402/what-is-the-difference-between-math-exp-and-numpy-exp-and-why-do-numpy-creators) – wjandrea Feb 26 '23 at 16:57
1 Answers
1
numpy
works with vectors (or scalars, or matrices, or arbitrary n-dimensional arrays), math
works with scalars only.

Antony Hatchkins
- 31,947
- 10
- 111
- 111
-
1More specifically, `math` only works with floats, or other objects that can be converted to float. That's why we have [`cmath`](https://docs.python.org/3/library/cmath.html) for example, to work with complex numbers. – wjandrea Feb 26 '23 at 16:27