This site is supported by donations to The OEIS Foundation.
PARI/GP
PARI/GP is a freely available, widely used computer algebra system designed for fast computations in number theory (factorizations, algebraic number theory, elliptic curves, etc.), but also contains a large number of other useful functions to compute with mathematical entities such as matrices, polynomials, power series, algebraic numbers etc., and a lot of transcendental functions. PARI is also available as a C library to allow for faster computations.
Originally developed by Henri Cohen and his co-workers (Université Bordeaux I, France), PARI is now under the GPL and maintained by Karim Belabas with the help of many volunteer contributors.
- PARI is a C library, allowing fast computations.
- gp is an easy-to-use interactive shell giving access to the PARI functions.
- GP is the name of gp's scripting language.
- gp2c, the GP-to-C compiler, combines both worlds by compiling GP scripts to the C language and transparently loading the resulting functions into gp. (gp2c-compiled scripts will typically run 3 or 4 times faster.) gp2c currently only understands a subset of the GP language.
Contents
Supported operating systems
PARI/GP was developed on Linux, but binary executables are available for Windows, using the Cygwin UNIX environment emulation layer.
On Windows, the basic interpreter can be installed without requiring administrator privileges, but in that case several features of the user interface, in particular the extended on-line help and documentation (the ?? and ??? commands), may be severely limited.
Basic Usage
For the semi-mechanical evaluation of a PARI code snippet in the OEIS, you can
- Cut out the code and store it in a file, for example
A093065.1.gp
{a(n)=local(A); if(n<1, 0, n--; A=x*O(x^n); polcoeff((eta(x^3+A)*eta(x^15+A)/eta(x+A)/eta(x^5+A))^2, n))}
- Create a second PARI file
print32.gp
for vector output:
echo "print(vector(32,n,a(n));quit;" > print32.gp
- Or create a file
bfile100.gp
for b-file output:
for(k=1,100, print(k, " ", a(k)));quit;
- Run the PARI interpreter in quiet mode with two files:
gp -q A093065.1.gp bfile100.gp
Comparison to other CAS
In the domain of number theory, PARI/GP is a strong rival to well established all-purpose CAS as Maple and Mathematica, mainly due to its computational speed, where it typically outperforms both of these well known commercial CAS, and its free availability.
Among the main drawbacks of the GP interpreter and scripting language are
- Weak string handling: While strings are supported, and it is easy to convert arbitrary expressions to strings and concatenate them, there are (almost?) no other string manipulation commands. The only way to deal with strings is to convert them into vectors of individual 1-character strings using the
Vec()
command (or into numerical arrays of ASCII codes viaVecsmall()
, but these are poorly supported), and then to usevecextract()
and subsequent concatenation commands. - No native support for memoization, as e.g. implemented in Maple via the
remember
option. This makes it slightly harder to code recursive functions which make large numbers of backreferences.
Another drawback of PARI/GP is the limited functionality of the user interface. It consists in a console window with the "command-line" interpreter, featuring only some support of colored output and the readline extension, and support for high resolution plotting in external windows.
See also
External links
- PARI/GP headquarters (development, downloads and documentation)
- Sample GP code on Rosetta Code
- GP online (compileonline.com)
- GP online (Collaborative Calculation in the Cloud, based on SageMath)