A python package for finding small solutions of systems of diophantine (integer algebra) equations
Project description
Author: Thomas G. Close (tom.g.close@gmail.com)
Diophantine (http://github.com/tclose/Diophantine) is a Python package for finding small (integer) solutions of systems of diophantine equations (see http://en.wikipedia.org/wiki/Diophantine_equation). It is based on PHP code by Keith Matthews (see www.number-theory.org) that implements the algorithm described in https://github.com/tclose/Diophantine/blob/master/algorithm.pdf (see http://www.numbertheory.org/lll.html for a list of associated publications), which uses the LLL algorithm to calculate the Hermite-normal-form described in the paper:
Extended gcd and Hermite normal form algorithms via lattice basis reduction, G. Havas, B.S. Majewski, K.R. Matthews, Experimental Mathematics, Vol 7 (1998) 125-136
(please cite this paper if you use this code in a scientific publication)
There are two branches of this code in the GitHub repository (see https://github.com/tclose/Diophantine.git), ‘master’, which uses the sympy library and therefore uses arbitrarily long integer representations, and ‘numpy’, which uses the numpy library, which is faster but can suffer from integer overflow errors despite using int64 representations
To find small solutions to a system of diophantine equations, A x = b, where A is a M x N matrix of coefficents, b is a M x 1 vector and x is the N x 1 vector, use the ‘solve’ method in the module, e.g.
>>> from sympy import Matrix >>> from diophantine import solve >>> A = Matrix([[1, 0, 0, 2], [0, 2, 3, 5], [2, 0, 3, 1], [-6, -1, 0, 2], [0, 1, 1, 1], [-1, 2, 0,1], [-1, -2, 1, 0]]).T >>> b = Matrix([1, 1, 1, 1]) >>> solve(A, b) [Matrix([ [-1], [ 1], [ 0], [ 0], [-1], [-1], [-1]])]
The returned solution vector will tend to be one with the smallest norms. If multiple solutions with the same norm are found they will all be returned. If there are no solutions the empty list will be returned.
Diophantine is released under the MIT Licence (see Licence for details)
Installation
Diophantine is available from the Python Package Index (http://pypi.python.org) and can be installed with the command
pip install diophantine
Alternatively, the master branch can be installed from using the setuptools install command
python setup.py install
from a clone of the GitHub repository (https://github.com/tclose/Diophantine) or simply adding the cloned directory to your PYTHONPATH.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Diophantine-0.1.1.tar.gz
.
File metadata
- Download URL: Diophantine-0.1.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4394f7589f8c83dc88a1040cf0a471eacb73f9292d55cfe06342cc9992c75590 |
|
MD5 | 4876fd2a28ec89903e4aafcb53327338 |
|
BLAKE2b-256 | f59c0d7f65415f839e31afe3109d9fbd8c7ed1548c2c7b2f27caacd9d340b485 |
File details
Details for the file Diophantine-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: Diophantine-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2559d448a7fe0dc1e03a54896004ad4a0b3af6a4903a31dedc83c4037129be5f |
|
MD5 | 01024f0e5513cc745b515f35e6273fa3 |
|
BLAKE2b-256 | ef52cd4769e8ae73f24f662c9fbac72cf4c9b8f5b85c41b49ab72d8e519b5c8d |