1

What are the fundamental differences between the functions in Python's math module and their equivalents in the NumPy library?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 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 Answers1

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
  • 1
    More 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