Triangles with prime hypotenuse

The sequence $3, 5, 9, 11, 15, 19, 21, 25, 29, 35,\dots$ consists of odd legs in right triangles with integer side lengths and prime hypotenuse. We show that the upper density of this sequence is zero, with logarithmic decay. The same estimate holds for the sequence of even legs in such triangles. We expect our upper bound, which involves the Erd\H{o}s--Ford--Tenenbaum constant, to be sharp up to a double-logarithmic factor. We also provide a nontrivial lower bound. Our techniques involve sieve methods, the distribution of Gaussian primes in narrow sectors, and the Hardy--Ramanujan inequality.


Introduction
The sequence OEIS A281505 concerns odd legs in right triangles with integer side lengths and prime hypotenuse. By the parametrisation of Pythagorean triples, these are positive integers of the form x 2 − y 2 , where x, y ∈ N and x 2 + y 2 is prime. Even legs are those of the form 2xy, where x, y ∈ N and x 2 + y 2 is an odd prime. Let A be the set of odd legs, and B the set of even legs that occur in such triangles. Consider the quantities Additionally, note that B(2N) = C(N), where C(N) = #{1 < ab N : a 2 + b 2 ∈ P}. We estimate C(N), which is equivalent to estimating B(N) and similar to estimating A(N). Let η = 1 − 1 + log log 2 log 2 ≈ 0.086 be the Erdős-Ford-Tenenbaum constant. This constant is related to the number of distinct products in the multiplication table, and also arises in other contexts, for example, see [2], [3], and [9]. Theorem 1.1. We have Since every prime p ≡ 1 (mod 4) is representable as a 2 +b 2 with a, b integral, we have C(N) unbounded. In fact, using the maximal order of the divisor function, we have C(N) N 1−o (1) as N → ∞. We obtain a strengthening of this lower bound. (1) .
Note that log 4 − 1 ≈ 0.386. Since B(2N) = C(N), we obtain the same bounds for B(N). By essentially the same proofs, one can also deduce these bounds for A(N).
To motivate the outcome, consider the following heuristic. There are typically ≈ (log n) log 2 divisors of n, which follows from the normal number of prime factors of n, a result of Hardy and Ramanujan [7]. Moreover, given a factorisation n = ab, the "probability" of a 2 + b 2 being prime is roughly (log n) −1 . Since log 2 < 1, we expect the proportion C(N)/N to decay logarithmically. In the presence of biases and competing heuristics, this prima facie prediction should be taken with a few grains of salt. We use Brun's sieve and the Hardy-Ramanujan inequality to formally establish our bounds. In addition, for Theorem 1.2 we use a result of Harman and Lewis [8] on the distribution of Gaussian primes in narrow sectors of the complex plane.
We write P for the set of primes. We use Vinogradov and Landau notation. As usual, we write ω(n) for the number of distinct prime divisors of n, and Ω(n) for the number of prime divisors of n counted with multiplicity. The symbols p and ℓ are reserved for primes, and N denotes a large positive real number.

An upper bound
In this section, we establish Theorem 1.1. The Hardy-Ramanujan inequality [7] states that there exists a positive constant c 0 such that uniformly for i ∈ N and N 3 we have By Mertens's theorem and the fact that the sum of the reciprocals of prime powers higher than the first power converges, there is a positive constant c 1 such that Let α be a parameter in the range 1 < α < 2, to be specified in due course. We begin by bounding the size of the exceptional set 2) By the Hardy-Ramanujan inequality, we have where k = log log N, and therefore Note that we have used here the elementary inequality 1/L! < (e/L) L , which holds for all positive integers L and follows instantly from the Taylor series for e L . Thus, For an integer n 2, write P (n) for the largest prime factor of n, and let P (1) = 1. By de Bruijn [1, Eq. (1.6)] we may bound the size of the exceptional set E 2 := {n N : P (n) N 1/ log log N } by N/(log N) 2 for all sufficiently large numbers N. (Actually, the denominator may be taken as any fixed power of log N.) Next, we estimate For n counted by C * (N), we see by symmetry that we have n = ab 0 ℓ for some a, b 0 , ℓ ∈ N with ℓ > N 1/ log log N prime and a 2 + b 2 0 ℓ 2 prime. Thus C * (N) 2 We turn our attention to S(a, b 0 ). We may assume that ab 0 is even and gcd(a, b 0 ) = 1, for otherwise S(a, b 0 ) = 0. Observe that To bound this from above, we apply Brun's sieve [5, Corollary 6.2] with A = m(a 2 + b 2 0 m 2 ) : 1 m X , and with the completely multiplicative density function g defined by For this to be valid, we need to check that n ≡ 0 mod d} and P (z) = p<z p. We begin by noting that if p ∈ P then the congruence m(a 2 + b 2 0 m 2 ) ≡ 0 mod p has g(p)p solutions m mod p. Observe that any divisor d of P (z) must be squarefree; thus, by the Chinese remainder theorem, the congruence We also need to check that where V (z) = p<z (1 − g(p)), and where (c/e) c = e, c ≈ 3.59.
This follows from the inequalities

A lower bound
In this section, we establish Theorem 1.2. Let Writing P (n) for the largest prime factor of n > 1, and P (1) = 1, put Let ε be a small positive real number, and let Finally, write As we seek a lower bound, we are free to discard some inconvenient elements of C(N). Thus, by the Cauchy-Schwarz inequality, we have We first show that #L 0 ≫ N.  Then The implied constant is absolute.
Proof. By de Bruijn [1, Eq. (1.6)], we have Thus, by symmetry, we have #L 1 ≪ N log N . Lemma 3.3. We have Proof. As #L 2 = #L 3 , we need only show this for j = 2. Taking out a prime factor ℓ > N 1/ log log N of ab, we have where S a,b = N 1/ log log N <ℓ N ab ℓ, a 2 +b 2 ℓ 2 ∈P

1.
As in the last section, Brun's sieve implies that where (3.4) As in the prior section, the multinomial theorem implies that Since (1 + ε)(1 − log(1 + ε)) < 1, using this estimate in (3.3) completes the proof of the lemma.

Combining (3.2) with Lemmas 3.2 and 3.3 gives
Proof. One component of the count is when (a, b) = (c, d). This is the diagonal case, and it is easily estimated. By the sieve, the number of pairs (a, b) ∈ L with a b is at most which is negligible. (Note that this estimate shows that (3.5) is essentially tight.) For the nondiagonal case we imitate §2. If (a, b, c, d) is counted by S(N), put g = gcd(a, c), a = gu, c = gv, so that ub = vd, d = uw, b = vw. Recall (3.4), and let G be the set of (g, u, v, w 0 ) ∈ N 4 such that As P (ab) > N 1/ log log N , we see by symmetry that where S(g, u, v, w 0 ) = ℓ∈P, N 1/ log log N <ℓ N guvw 0 (gu) 2 +(vw 0 ) 2 ℓ 2 , (gv) 2 +(uw 0 ) 2 ℓ 2 ∈P 1.
The fact that u = v ensures that there are three primality conditions defining S(g, u, v, w 0 ). To bound S(g, u, v, w 0 ) from above, we may assume without loss that guvw 0 is even, and that the variables g, u, v, w 0 are pairwise coprime, for otherwise S(g, u, v, w 0 ) = 0. Paralleling §2, an application of Brun's sieve reveals that Substituting (3.7) into (3.6) yields where and T is as in (3.4). With U = 2T , it follows from the multinomial theorem that and a further application of the multinomial theorem gives As U = 2(1 + ε) log log N + O(1), we now have Substituting this into (3. As c ′ > log 4 − 1, we may choose ε > 0 to give S(N) ≪ c ′ N(log N) c ′ .

A final comment
We conjecture that Theorem 1.1 holds with equality. For a lower bound, one might restrict attention to those pairs (a, b) with ω(a) ≈ ω(b) ≈ 1 2 log 2 log log N. The upper bound for the second moment is analysed as in the paper, getting N/(log N) η+o(1) ; we expect that a more refined analysis would give N(log log N) O (1) (log N) η here. The difficulty is in obtaining this same estimate as a lower bound for the first moment. This would follow if we had an analogue of Theorem 3.1 in which a, b have a restricted number of prime factors. Such a result holds for the general distribution of Gaussian primes, at least if one restricts only one of a, b, see [4].