I am currently taking a course on arithmetic over domains and most of the exercises I have to solve involve things such as: check whether $5$ is a prime in $\mathbb{Z}[\sqrt{-7}]$, check whether it is irreducible, find the factorization of $633+135i$ into a product of irreducibles in $\mathbb{Z}[i]$, compute some gcd, etc.

I definitely understand how to do these, but I would like to know whether there is some software that can help me tackle such questions, i.e. if there is some software that can tell me whether $5$ is a prime in $\mathbb{Z}[\sqrt{-7}]$ and all the other things I listed. This would be really useful because it is frustrating to not be able to check whether your computations are correct when solving some problems (or wrongly conclude that some element is irreducible just because you messed up some diophantine equation).

The only computational algebra resources I have used so far have been the good old WolframAlpha (that doesn't do a really good job with quadratic integers) and Macaulay2 (this one only solves such tasks for polynomial rings as far as I know). I heard that PARI/GP can do the things I listed, but I tried to use it online and I couldn't figure it out. I also couldn't find any helpful guides on computations in quadratic integer rings, so this is why I decided to ask here.

  • $\begingroup$ An excellent book is the book by Marcus. Is has a long section about these rings with many examples. For a software you can use "pari-gp" or "Sage", which computes almost everything for you. Read the manual for pari-pg, then you will understand it. $\endgroup$ Nov 12, 2021 at 17:58
  • $\begingroup$ @DietrichBurde thank you very much! I found that manual, but it looks daunting to me because it is almost 600 pages long. Do you have any tips on how to read it? $\endgroup$
    – MathIsCool
    Nov 12, 2021 at 18:30
  • $\begingroup$ Well, error checking is done quickly with binary quadratic forms. First you ask whether there is an integer expression with $x^2 + xy + 2 y^2 = 5,$ which there isn;t since $5$ is a nonresidue $\pmod 7.$ I like Buell, Binary Quadratic Forms. I also have Buchmann and Volmer. There are also books that intend an introduction to ANT by doing forms and ideals side by side, one is bookstore.ams.org/dol-52 there are earlier books as well $\endgroup$
    – Will Jagy
    Nov 12, 2021 at 18:31
  • $\begingroup$ google.com/books/edition/Quadratic_Irrationals/… $\endgroup$
    – Will Jagy
    Nov 12, 2021 at 18:40
  • 1
    $\begingroup$ You might find Ctrl+F to be a useful tool against the 600-page-long manual. You can also look at this page which contains commands specialized to number fields. I can tell you all the commands you need, but if you don't learn to find commands yourself, you'll run into problems with the next command you need. $\endgroup$
    – Kenny Lau
    Nov 14, 2021 at 23:56

1 Answer 1


Are you really being asked if something is prime in $\mathbf Z[\sqrt{-7}]$ or did you just make up that example? I ask because $\mathbf Z[\sqrt{-7}]$ is not a UFD, so there is a distinction between primes and irreducibles.

By the way, how are you checking if something is prime in a quadratic ring? You wrote that you definitely know how to do this, but you didn’t indicate what it is you do.

  • $\begingroup$ I made up that example, but it can be done. Fix some quadratic ring $\mathbb{Z}[\sqrt{d}]$. Then some prime $p\in \mathbb{Z}$ is a prime in this quadratic ring iff $d$ is not a quadratic residue modulo $p$. Also, if we take some $a+b\sqrt{d}$ such that $\gcd(a, b)=1$, then this will be a prime iff its norm is a prime number (in $\mathbb{Z}$). These two results are enough to check whether any element is a prime, but I was looking for some software that would help me check my computations (not this one in particular because this one is easy, I just tried to give a few examples). $\endgroup$
    – MathIsCool
    Nov 21, 2021 at 15:26
  • $\begingroup$ Were you taught a practical necessary and sufficient criterion in quadratic rings (not only imaginary quadratic rings) for irreducibility when the number is not prime? $\endgroup$
    – KCd
    Nov 21, 2021 at 22:00
  • $\begingroup$ Not really, I just compute the norm of the number and then see if there are some elements whose norm divides the norm of my number. $\endgroup$
    – MathIsCool
    Nov 21, 2021 at 22:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .