About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

linux default iconmpmath Publisher's description

mpmath is a replacement for Python's float/complex types and math/cmath modules with unlimited precision and exponent sizes.

mpmath is a replacement for Python's float/complex types and math/cmath modules with unlimited precision and exponent sizes. The mpmath software is written entirely in Python without any external dependencies and hence runs almost anywhere, without the need for compilation.

To install, unpack the mpmath archive and run

python setup.py install

Documentation and usage:

Import mpmath with

from mpmath import *

This provides the classes mpf and mpc which work analogously to Python's float and complex types:

>>> mpf(2) / mpf(3)

>>> mpc(0, -1)
mpc(real='0', imag='-1')

>>> mpf(-0.6) ** mpf(-0.2)
mpc(real='0.89603999408558288', imag='-0.65101116249684809')

For prettier output (that also hides small rounding errors), use print or str():

>>> print mpf(2) / mpf(3)

>>> print mpc(1+2j)**0.5
(1.27201964951407 + 0.786151377757423j)

The precision is controlled by the properties mpf.prec (number of bits) and mpf.dps (number of decimals). These properties are linked, so changing one automatically updates the other to match. Setting prec or dps changes the precision at which all operations are carried out and the number of digits to display when printing numbers. The default is
prec=53 and dps=15, the same as Python floats.

>>> mpf.dps = 30
>>> mpf(2) / mpf(3)
>>> print _
>>> mpf.dps = 15 # restore to default

You can create mpfs and mpcs from Python numbers, or combine mpfs and mpcs with Python numbers in arithmetic operations, but be aware that regular Python floats only have finite precision. To initialize an mpf with a full-precision value, use a string:

>>> mpf(0.1)
mpf('0.10000000000000001') # same accuracy as float
>>> mpf.dps = 50
>>> mpf(0.1)
mpf('0.1000000000000000055511151231257827021181583404541016') # junk

>>> mpf('0.1')
mpf('0.1000000000000000000000000000000000000000000000000001') # ok

The following standard functions are available and support both real and complex arguments:

sqrt, exp, log, power, cos, sin, tan, cosh, sinh, tanh,
acos, asin, atan, acosh, asinh, atanh


>>> mpf.dps = 15
>>> print cos(1)
>>> mpf.dps = 50
>>> print cos(1)

Some less-common functions are also available: gamma (gamma function), factorial, erf (error function), lower_gamma/upper_gamma (incomplete gamma function) and zeta (Riemann zeta function).

Finally, the convenience functions hypot and atan2 are available (defined for real numbers only).

The constants pi, e, and cgamma (Euler's constant) are available as special objects that behave like mpfs but whose values automatically adjust to the precision.

>>> mpf.dps = 15
>>> print pi
>>> mpf.dps = 50
>>> print pi

>>> mpf.dps = 15
>>> e**(-pi*1j)
mpc(real='-1', imag='-1.2289836075083701E-16')
>>> mpf.dps = 50
>>> e**(-pi*1j)
mpc(real='-1', imag='1.0106 [...] E-51')

Directed rounding is partially implemented. For example, this computes and verifies a 15-digit approximation interval for pi:

>>> mpf.dps = 15
>>> mpf.round_down(); pi1 = +pi
>>> mpf.round_up(); pi2 = +pi
>>> pi1
>>> pi2
>>> mpf.dps = 30
>>> pi1 < pi < pi2

What's New in This Release:

В· General
В· It is now possible to create multiple context objects and use context-local methods instead of global state/functions (e.g. mp2=mp.clone(); mp2.dps=50; mp2.cos(3)). Not all functions have been converted to context methods, and there are some bugs, so this feature is currently experimental.
В· If mpmath is installed in Sage 4.0 or later, mpmath will now use sage.Integer instead of Python long internally.
В· Removed instances of old-style integer division from the codebase.
В· runtests.py can be run with -coverage to generate coverage statistics.

В· Types and basic arithmetic

В· Fixed comparison with -inf.
В· Changed repr format of the mpi interval type to make eval(repr(x)) == x.
В· Improved printing of intervals, with configurable output format (contributed by Vinzent Steinberg based on code by Don Peterson).
В· Intervals supported by mpmathify() and nstr() (contributed by Vinzent Steinberg).
В· mpc is now hashable.
В· Added more formatting options to the internal function to_str.
В· Faster pure-Python square root.
В· Fix trailing whitespace giving wrong values in str->mpf conversion.

В· Calculus

В· Fixed nsum() with Euler-Maclaurin summation which would previously ignore the starting index and sum from n=1.
В· Implemented Newton's method for findroot() (contributed by Vinzent Steinberg).

В· Linear algebra

В· Fixed LU_decomp() to recognize singular matrices (contributed by Vinzent Steinberg).
В· The various norm functions were replaced by the generic vector norm function norm(x,p) and the generic matrix norm function mnorm(x,p).

Special functions:

В· Some internal caches were changed to always slightly overallocate precision. This fixes worst-case behavior where previously the cached value had to be recomputed on every function call.
В· Fixed log(tiny number) returning nonsense at high precision.
В· Fixed gamma() and derivative functions such as binomial() returning wrong results at integer inputs being divisible by a large power of 2.
В· Fixed asin() not to raise an exception at high precision (contributed by Vinzent Steinberg).
В· Optimized the AGM code for the natural logarithm, making the previously used Newton method at intermediate precisions obsolete.
В· The arithmetic-geometric mean function agm() is now an order of magnitude faster at low precision.
В· Faster implementations of ellipk() and ellipe().
В· Analytic continuation of ellipe() to |x| >= 1 implemented.
В· Implemented the log gamma function (loggamma()) with correct branch cuts (slow, placeholder implementation).
В· Fixed branch cuts of hyperfac().
В· Implemented the Riemann-Siegel Z-function (siegelz()).
В· Implemented the Riemann-Siegel theta function (siegeltheta()).
В· Implemented calculation of Gram points (grampoint()).
В· Implemented calculation of Riemann zeta function zeros (zetazero()).
В· Implemented the prime counting function: a slow, exact version (primepi()). and a fast approximate version (primepi2()) that gives a bounding interval.
В· Implemented the Riemann R prime counting function (riemannr()).
В· Implemented Bell numbers and polynomials (bell()).
В· Implemented the expm1() function.
В· Implemented the 'polyexponential function' (polyexp()).
В· Implemented the twin prime constant (twinprime) and Mertens' constant (mertens).
В· Implemented the prime zeta function (primezeta()).

System Requirements:

В· Python
Program Release Status:
Program Install Support: Install and Uninstall

mpmath Tags:

Click on a tag to find related softwares

Is mpmath your software?

Manage your software

Most Popular

linux default icon GDB 7.4
GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it... Read more
linux default icon Coral 0.9.1
Coral is a tool and a development platform to create and transform models and modeling languages.
linux default icon Forum Paid Plus Script 6.1
Forum Paid Pay Per Post Exchange is targeted at forum owners who wish to...
linux default icon sdo 0.6.5
Converts oracle SDO_GEOMETRY objects to WKT and GeoJSON.
linux default icon Get Paid Plus Script 6.1
Get Paid Plus Script

Related Category

» Other (877)
» Tools & Editors (359)
» Web Development (146)