Setting up mpmath
=================

Download and installation
-------------------------

Installer
.........

The mpmath setup files can be downloaded from the `mpmath download page <http://code.google.com/p/mpmath/downloads/list>`_ or the `Python Package Index <http://pypi.python.org/pypi/mpmath/>`_. Download the source package (available as both .zip and .tar.gz), extract it, open the extracted directory, and run

    ``python setup.py install``

If you are using Windows, you can download the binary installer

    ``mpmath-(version).win32.exe``

from the mpmath website or the Python Package Index. Run the installer and follow the instructions.

Using setuptools
................

If you have `setuptools <http://pypi.python.org/pypi/setuptools>`_ installed, you can download and install mpmath in one step by running:

    ``easy_install mpmath``

or

    ``python -m easy_install mpmath``

If you have an old version of mpmath installed already, you may have to pass ``easy_install`` the ``-U`` flag to force an upgrade.


Debian/Ubuntu
.............

Debian and Ubuntu users can install mpmath with

    ``sudo apt-get install python-mpmath``

See `debian <http://packages.debian.org/python-mpmath>`_ and `ubuntu <https://launchpad.net/ubuntu/+source/mpmath>`_ package information; please verify that you are getting the latest version.

OpenSUSE
........

Mpmath is provided in the "Science" repository for all recent versions of `openSUSE <http://www.opensuse.org/>`_. To add this repository to the YAST software management tool, see http://en.opensuse.org/Add_Package_Repositories_to_YaST and use one of the following repository URLs:

  * http://download.opensuse.org/repositories/science/openSUSE_10.2/
  * http://download.opensuse.org/repositories/science/openSUSE_10.3/
  * http://download.opensuse.org/repositories/science/openSUSE_11.0/

Current development version
...........................

See  http://code.google.com/p/mpmath/source/checkout for instructions on how to check out the mpmath Subversion repository. The source code can also be browsed online from the Google Code page.

Checking that it works
......................

After the setup has completed, you should be able to fire up the interactive Python interpreter and do the following::

    >>> from mpmath import *
    >>> mp.dps = 50
    >>> print mpf(2) ** mpf('0.5')
    1.4142135623730950488016887242096980785696718753769
    >>> print 2*pi
    6.2831853071795864769252867665590057683943387987502

*Note: if you have mpmath 0.6 or earlier installed, you may have to either first uninstall the old version, or manually delete the obsolete mpmath/lib directory. Otherwise this directory will be imported erroneously.*

Running tests
-------------

It is recommended that you run mpmath's full set of unit tests to make sure everything works. The tests are located in the ``tests`` subdirectory of the main mpmath directory. They can be run via

    ``python runtests.py``

The tests should finish in about a minute. If you have `psyco <http://psyco.sourceforge.net/>`_ installed, the tests can also be run with

    ``python runtests.py -psyco``

which will cut the running time in half.

If any test fails, please send a detailed bug report to the `mpmath issue tracker <http://code.google.com/p/sympy/issues/list>`_. The tests can also be run with `py.test <http://codespeak.net/py/dist/>`_. This will sometimes generate more useful information in case of a failure.

*This currently only applies to the development version of mpmath*: By default, mpmath will use `gmpy <http://code.google.com/p/gmpy/>`_ if version 1.03 or later is installed on your system. To run the tests with support for gmpy disabled, use

    ``python runtests.py -nogmpy``

To enable extra diagnostics, use

    ``python runtests.py -strict``

Compiling the documentation
---------------------------

If you downloaded the source package, the text source for these documentation pages is included in the ``doc`` directory. The documentation can be compiled to pretty HTML using `Sphinx <http://sphinx.pocoo.org/>`_. Go to the ``doc`` directory and run

    ``python build.py``

You can also test that all the interactive examples in the documentation work by running

    ``python run_doctest.py``

(The doctests may take several minutes.)

Finally, some additional demo scripts are available in the ``demo`` directory included in the source package.
