The purpose of the NZMATH system is to provide mathematical, especially number-theoretic computational power to you. It is written in Python scripting language in order to enhance quickly with users' experiences.
NZMATH requires Python version 3.8 or later. If you do not have Python installed on your computer, please install it.
The Python language is a very high level language. It is downloadable from the website. There are also some documents there.
NZMATH is ready for Python 3 now, and will not support for Python 2. For Python 2, you can install a former version NZMATH-1.2.0 for example.
First of all, please download the distribution file. The file you need differs depending on your operating system. For unix or unix-like systems the file is NZMATH-x.y.z.tar.gz, where x, y, z are non-negative integers, (or NZMATH-x.y.z.zip). For Microsoft Windows, NZMATH-x.y.z.win32Install.exe or NZMATH-x.y.z.win64Install.exe.
To install NZMATH you should have privilege which lets you install some files under the standard python script path, /usr/lib/python3.8/site-packages or /usr/local/lib/python3.8/site-packages depending on the Python installation path.
We denote the privileged user's prompt # and ordinary user's %.
Expand the downloaded file.
% tar zxf NZMATH-x.y.z.tar.gz
Then, you have a child directory named NZMATH-x.y.z.
% cd NZMATH-x.y.z % su # python setup.py install
The last command install NZMATH into the python script path described above. Depending on system, you may get SetuptoolsDeprecationWarning. Please do not worry for the moment. Installed NZMATH works well.
Click the downloaded file, and follow the instruction.
(Optional, but recommended)
IPython is an enhanced interactive Python shell. If you do not have it installed on your system, it is recommended to install it now.
You can get IPython with pip.
% python -m pip install ipython
(we use '%' for a command prompt. If you are on Windows, it may be 'C:>' or something.)
(Optional, but recommended)
mpmath is a multiple precision floating point arithmetic package for Python. Some modules in NZMATH essentially depend on the availability of mpmath, and some other modules can be more powerful with mpmath.
You can get mpmath with pip.
% python -m pip install mpmath
(we use '%' for a command prompt. If you are on Windows, it may be 'C:>' or something.)
NZMATH does not have own interpreter nor graphical interface. Users have to use with the raw Python interpreter (or possibly IPython). Though the interpreters are designed well, of course, they are not specialized for mathematical computation. Please be patient about it.
Start your Python interpreter
% python Python 3.8.6 (....................) [....................] on ........ Type "help", "copyright", "credits" or "license" for more information. >>>
(we use '%' for a command prompt. If you are on Windows, it may be 'C:>' or something.)
Here, '>>>' is a Python prompt. You are in the Python interpreter until you will type EOF (Ctrl-D on unices and Ctrl-Z on Windows). Then, type:
>>> from nzmath import * >>>
The whole NZMATH stuff is imported.
>>> r = rational.Rational(113, 355) >>> print(r) 113/355 >>> ....
The session continues until you will stop.
(Optional)
As you see, class names of NZMATH objects may be boringly long to type. You can use completion feature; if you are using ipython it is presented by default, or if you use default Python you might be able to configure it to use readline. Unfortunately, sometimes Python is built WITHOUT readline module for some license issue. So, the following is for those who are lucky to have readline enabled Python.
Save the following content in your file, pythonrc.py, for example:
Then, set environment variable PYTHONSTARTUP pointing to the file.
(Please read Python Library Reference of readline and rlcompleter modules for more detailed explanation.)
Writing everything at the interpreter prompt is a dull work. Instead of it, you can make a program file.
The name of file must end with '.py'; for example, 'sample.py'.
The contents of the file must be a valid Python program. And, you may want to import some NZMATH modules at the start of the file.
See the Python documents for detailed Python syntax or built-in data types and functions. NZMATH data types are explained below.
To invoke your program (sample.py, say), simply:
% python sample.py
Or, if you are using unices, make it executable as usual.
Python is an object-oriented programming language, and user can create a new data type as class. The data types provided by NZMATH are also classes, which have a lot of methods including overloaded operators.
There is an integer data type int (arbitrary precision) in Python. NZMATH has Integer (nzmath.rational.Integer) to give a rational result for division instead of a float.
>>> rational.Integer(3) / 4 Rational(3, 4) >>> 3 / 4 0.75
Python's int behaves just like C's int type by double slash operator, i.e. floor division.
>>> 3 // 4 0 >>> 8 // 5 1
NZMATH provides Rational (nzmath.rational.Rational) class representing a rational number, as already appeared in the previous example.
In NZMATH, algfield module provides algebraic numbers.
Python has float data type for it. The mpmath also provides it.
There are several polynomial classes. New users should use poly sub-package.
>>> poly.uniutil.polynomial({0:-1,100:1}, rational.theIntegerRing) IntegerPolynomial([(0, -1), (100, 1)], IntegerRing())
poly.uniutil.polynomial is the factory function for univariate polynomials.
There are several matrix classes. matrix module provides them.
Integers are in the integer ring, a polynomial in a certain polynomial ring, etc.... They are obtained from elements of them by getRing method. For example, rational.Integer(1).getRing() returns a rational.IntegerRing object.
This is a convention in NZMATH and does not apply to the object provided by Python itself such as int...
Fields are a part of rings (see Rings).
There are some fields: the field of rational numbers, real numbers, and complex numbers are defined. Finite fields are provided through finitefield module.
There are some groups in NZMATH: for example, class group of imaginary quadratic fields in quad module, or rational point of elliptic curves over finite fields in elliptic module.
We are not providing general frameworks for them, though.
There are other modules, such as bigrandom, factor, prime, etc. Please read the manual for those modules.
The project is of open source, and your participation is essential.
We have a project site on the sf.net. There are bug tracker, source repository and so on.
Your feedbacks are always welcomed. Please consider to join the mailing list.
Almost all the former developers are doctor, master or bachelor course students of Nakamula laboratory, Tokyo Metropolitan University (TMU).
NZMATH is distributed under the BSD license. Please read LICENSE.txt in the distribution tar ball for detail.