Python library for arbitrary-precision floating-point arithmetic
|pypi version| |Build status| |Code coverage status| |Zenodo Badge|
.. |pypi version| image:: https://img.shields.io/pypi/v/mpmath.svg :target: https://pypi.python.org/pypi/mpmath .. |Build status| image:: https://github.com/fredrik-johansson/mpmath/workflows/test/badge.svg :target: https://github.com/fredrik-johansson/mpmath/actions?workflow=test .. |Code coverage status| image:: https://codecov.io/gh/fredrik-johansson/mpmath/branch/master/graph/badge.svg :target: https://codecov.io/gh/fredrik-johansson/mpmath .. |Zenodo Badge| image:: https://zenodo.org/badge/2934512.svg :target: https://zenodo.org/badge/latestdoi/2934512
A Python library for arbitrary-precision floating-point arithmetic.
Website: http://mpmath.org/ Main author: Fredrik Johansson [email protected]
Mpmath is free software released under the New BSD License (see the LICENSE file for details)
The following people (among others) have contributed major patches or new features to mpmath:
Numerous other people have contributed by reporting bugs, requesting new features, or suggesting improvements to the documentation.
For a detailed changelog, including individual contributions, see the CHANGES file.
Fredrik's work on mpmath during summer 2008 was sponsored by Google as part of the Google Summer of Code program.
Fredrik's work on mpmath during summer 2009 was sponsored by the American Institute of Mathematics under the support of the National Science Foundation Grant No. 0757627 (FRG: L-functions and Modular Forms).
Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the sponsors.
Credit also goes to:
Mpmath requires Python 2.7 or 3.5 (or later versions). It has been tested with CPython 2.7, 3.5 through 3.7 and for PyPy.
The latest release of mpmath can be downloaded from the mpmath website and from https://github.com/fredrik-johansson/mpmath/releases
It should also be available in the Python Package Index at https://pypi.python.org/pypi/mpmath
To install latest release of Mpmath with pip, simply run
pip install mpmath
Or unpack the mpmath archive and run
python setup.py install
Mpmath can also be installed using
python -m easy_install mpmath
The latest development code is available from https://github.com/fredrik-johansson/mpmath
See the main documentation for more detailed instructions.
The unit tests in mpmath/tests/ can be run via the script runtests.py, but it is recommended to run them with py.test (https://pytest.org/), especially to generate more useful reports in case there are failures.
You may also want to check out the demo scripts in the demo directory.
The master branch is automatically tested by Travis CI.
Documentation in reStructuredText format is available in the doc directory included with the source package. These files are human-readable, but can be compiled to prettier HTML using the build.py script (requires Sphinx, http://sphinx.pocoo.org/).
See setup.txt in the documentation for more information.
The most recent documentation is also available in HTML format:
Mpmath is a work in progress. Major issues include:
Some functions may return incorrect values when given extremely large arguments or arguments very close to singularities.
Directed rounding works for arithmetic operations. It is implemented heuristically for other operations, and their results may be off by one or two units in the last place (even if otherwise accurate).
Some IEEE 754 features are not available. Inifinities and NaN are partially supported; denormal rounding is currently not available at all.
The interface for switching precision and rounding is not finalized. The current method is not threadsafe.
General questions and comments can be sent to the mpmath mailinglist, [email protected]
You can also report bugs and send patches to the mpmath issue tracker, https://github.com/fredrik-johansson/mpmath/issues