1

Is there a method for factoring a prime of the form $4k+1$ (residual 1 modulo 4) into Gaussian prime factors?

What I am looking for is a method/procedure to generate the factors from this table for the norm values which are, once again, primes of the form $4k+1$ (5, 13, 17, 29, ...)

There does not seem to be much on math stack exchange beyond this post, whose only comment is somewhat terse and I hope to see expanded upon.

Ex.

First few primes of the form $4k+1$ = $\{5, 13, 17, 29, ...\}$.

So for $5$, I want to know if there is a procedure for factoring it into $(2+i)(1+2i)$.

For $13$, how to factor it into $(3+2i)(2+3i)$, so on and so forth.

dfish
  • 140
  • 2
    In other words, if I give you a prime $p$ of form $4k+1$, you want integers $a, b$ such that $a^2 + b^2 = p$. Is that correct? – Michael Lugo Jun 16 '21 at 20:25
  • @MichaelLugo not quite, I'll edit my question to be more explicit – dfish Jun 16 '21 at 20:26
  • 1
    I would have thought that @MichaelLugo's attempt at paraphrasing your question is exactly right, since $p=a^2+b^2$ gives $p=(a+bi)(a-bi)$, as desired. Your example with $5$ differs from that only by the unit $i$ in the Gaussian integers... – paul garrett Jun 16 '21 at 20:33
  • 1
    If it is only those primes then, once you have $p=a^2+b^2$ that gives $p=(a+bi)(a-bi)$. The other thing that they are doing in those factorizations is taking into account that it is up to a unit. So, they are multiplying by $i$: $ip=(a+bi)(b+ai)$. – plop Jun 16 '21 at 20:33
  • @paulgarrett ahh you're right, I apologize, MichaelLugo's clarification is correct – dfish Jun 16 '21 at 20:37
  • 1
    The only factors of a prime $p \equiv 1 \pmod 4$ in Gaussian integers are $a+bi$ and $a-bi$ (upto multiplication by units). The (a,b) are also the unique (positive) integers such that $a^2+b^2=p$ like @Michael said above. The answer in the post you linked to actually explains the preferred algorithm. Find $t$ such that $t^2 \equiv -1 \pmod p$ using Tonelli-Shanks and then use Euclidean to find the gcd. – arbashn Jun 16 '21 at 20:40
  • 2
    The references at https://oeis.org/A002330 might also be useful. – Michael Lugo Jun 16 '21 at 20:41
  • 1
    @arbashn I must have misunderstood it then. This question might be dumb, but how does $gcd(t+i,p)$ give you $a+bi$ if the gcd is only returning one value? – dfish Jun 16 '21 at 21:03
  • 1
    @dfish, if $a+bi$ divides $p$, then $a-bi$ divides $p$... and for $p$ odd these two are distinct, that is, do not differ by units in the Gaussian integers... – paul garrett Jun 16 '21 at 21:28

1 Answers1

3

Fermat's theorem on sums of two squares guarantees that every prime $ p \equiv 1 \pmod 4$ can be written as $p = a^2 + b ^2$. Moreover, this representation is also unique for positive $a,b$. This means that $p$ can be decomposed into Gaussian factors $p=(a+bi)(a-bi)$ uniquely (upto multiplication by units).

We know from quadratic reciprocity (or even Euler's criterion) that $-1$ is a square mod $p$ i.e. there exists an integer $t$ such that $$ t^2 \equiv -1 \pmod p$$

The usual algorithm to find a square root mod $p$ is the Tonelli-Shanks algorithm. We only need a much simpler version in our case:

Take a random residue $a \pmod p$ and find $a^{\frac{p-1}{4}}$. Since $a^{\frac{p-1}{2}} \equiv \left( \frac{a}{p} \right) \pmod p$, we get a square root of $-1$ iff $a$ is a quadratic nonresidue modulo $p$. Since half of the residues mod $p$ are quadratic nonresidues, our average required number of tries is less than $2$.

Once we have found $t$, we see that $p \mid t^2+1=(t+i)(t-i)$. $p$ cannot completely divide one of $t \pm i$ (it has to divide all the coefficients), which means that each of the two factors of $p$ divide exactly one of $t \pm i$. WLOG assume $a+bi$ divides $t+i$ and since $\Bbb{Z}[i]$ is an Euclidean domain, we can carry out the Euclidean algorithm to find out $\operatorname{gcd}(t+i,p)$ to find $a+bi$. We easily generate $a-bi$ and the factorization is complete.

arbashn
  • 675