Questions tagged [mpmath]

Mpmath is a Python library for arbitrary-precision floating-point arithmetic.

Mpmath is a pure-Python library for multiprecision floating-point arithmetic. It provides an extensive set of transcendental functions, unlimited exponent sizes, complex numbers, interval arithmetic, numerical integration and differentiation, root-finding, linear algebra, and much more. Almost any calculation can be performed just as well at 10-digit or 1000-digit precision, and in many cases mpmath implements asymptotically fast algorithms that scale well for extremely high precision work. Mpmath internally uses Python's builtin long integers by default, but automatically switches to GMP/MPIR for much faster high-precision arithmetic if gmpy is installed or if mpmath is imported from within Sage.

Mpmath is free (BSD license) and easy to install or include in other software due to being written entirely in Python with no additional required dependencies. It runs on Python 2.5 or higher, including Python 3.x. It can be used as a library, interactively via the Python interpreter, or via SymPy which uses it for numerical evaluation of symbolic expressions. Mpmath is also a standard component of Sage which uses it for special function evaluation.

If matplotlib is available, mpmath also provides a convenient plotting interface.

169 questions
-1
votes
1 answer

Calling mpmath directly from C

I want to access mpmath's special functions from a C code. I know how to do it via an intermediate python script. For instance, in order to evaluate the hypergeometric function, the C program: #include void main (int argc, char…
-1
votes
1 answer

Mpmath hypergeometric function shows different behaviour for high & low precision

For one of my projects, I need to repeatedly evaluate an expression involving the general hypergeometric function. While SciPy does not support the general HypGeo function, MPMath does. However, using mp.hyper(..) is very time consuming. So instead…
Ben
  • 465
  • 2
  • 6
  • 17
-3
votes
1 answer

Improve precision on numpy narrays

I have written this optimization procedure using numpy where I have to perform the following calculation: B is a symmetric negative semi-definite matrix and I the identity matrix. The problem is that the values of B can be too big (>1e25) and when…
-4
votes
1 answer

Improving speed of my mpmath code

Hello I wrote some code in Python, using the mpmath, arbitrary precision math module: from __future__ import division from numpy import arctan, sin, absolute, log10 from mpmath import * import time imax = 1000001 x = mpf(0) y = mpf(0) z = mpf(0) t =…
Iwko Czerniawski
  • 83
  • 1
  • 1
  • 8
1 2 3
11
12