mpmath
mpmath is a Python library for arbitrary-precision floating-point arithmetic, currently at version 1.4.1, with a release cadence of approximately every 1-2 years.
Warnings
- gotcha Importing all functions with 'from mpmath import *' can lead to name conflicts with other libraries. It's recommended to import only the necessary functions or use the 'mpmath.' namespace.
- gotcha Mixing mpmath with other libraries that define functions with the same names can cause unexpected behavior. To avoid this, import only the needed functions or use the 'mpmath.' namespace.
Install
-
pip install mpmath
Imports
- mp
from mpmath import mp
- mpf
from mpmath import mpf
Quickstart
from mpmath import mp mp.dps = 50 print(mp.quad(lambda x: mp.exp(-x**2), [-mp.inf, mp.inf]) ** 2)