Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was looking for free alternatives to Magma to perform number theory computations, such as modular, factorization, etc. and I've found GAP and Pari.

What's the difference between them? Any other advise instead?


New: Sage has a lot of features but it has two drawbacks: It's made with many different applications, great applications but independent, with few features, not properly merged on a single one. Each application has its commands, format...

And it's OK for Linux users but for Windows users has to be run virtualized, much slower.

I've found that the difference is that SAGE is better for abstract algebra problems and PARI for big number arithmetic.

share|cite|improve this question
I've grown fond of SAGE ( It's open source, free and has a lot easier syntax than many of the other math programs. – Fredrik Meyer Dec 17 '12 at 21:17
I'd also recommend sage... especially since it incorporates both GAP and Pari. – Shaun Ault Dec 17 '12 at 21:26
I personally prefere GAP. It has large libraries for group theory. But for number theory, SAGE might be your friend. – sebigu Dec 17 '12 at 22:08
Maybe a bit out of topic here, but GAP actually has an interface to PARI/GP in the Alnuth package – Alexander Konovalov Apr 22 '13 at 15:42
Pari vs Gap: Pari is much faster for computationally hard number theory, but it is relatively easy to misuse (most pari objects are literally lists of numbers; in GAP objects are lists of numbers wrapped up in sugary coating so that you don't send the wrong kind of list of numbers to a function). – Jack Schmidt Apr 23 '13 at 1:47

GAP has certain number-theoretical functionality, see in particular manual chapters Integers, Number Theory, Finite Fields, Abelian Number Fields.

Besides the functionality implemented in the core system, GAP has also two packages:

  • FactInt, providing more advanced methods for factoring integers

  • Alnuth, providing various methods to compute with number fields which are given by a defining polynomial or by generators. Some of the methods are written in GAP code, while some use PARI/GP via an interface, which is also a part of the package. The main methods included in Alnuth are: creating a number field, computing its maximal order (using PARI/GP), computing its unit group (using PARI/GP) and a presentation of this unit group, computing the elements of a given norm of the number field (using PARI/GP), determining a presentation for a finitely generated multiplicative subgroup (using PARI/GP), and factoring polynomials defined over number fields (using PARI/GP).

Since GAP 4.5, integer arithmetic in GAP became faster due to the GMP library, but PARI/GP still will be faster for hard computational problems. On the other hand, GAP may offer you a robust programming environment and access to other areas of mathematics covered by GAP. Thus, the final choice would depend on particular problems you want to deal with...

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.