# Can $(q,p)$ and $(p-q,p)$ be legs of a Pythagorean Triple

I'm searching to prove that there's no (or to find an example of) $$p$$ and $$q$$ coprimes, and $$n,m$$ integers such that:

$$q^2 + p^2 = n^2$$

$$(p-q)^2 + p^2 = m^2$$

I conjecture that this case is impossible. Do you have any idea of how to prove or disprove it ?

So far:

I was only able to prove that in this case $$p$$ must be even: since there's at least one number that is even in a pythagorean triple, it must be $$p$$, else there'll be a contradiction with the parity of $$q$$ and $$p-q$$.

Also, (thanks to Mark Bennet), one of $$p$$ and $$q$$ (this a general property for pythagorean triples) must be a multiple of $$3$$. Suppose $$q$$ is a multiple of $$3$$, then $$p$$ is not (there are coprimes). Then $$p-q$$ is a multiple of three minus a non-multiple of three, meaning $$p-q$$ is a non-one. But this leads to a contradiction, because one of $$p-q$$ or $$p$$ must be a multiple of $$3$$. This means that $$q$$ can't be a multiple of $$3$$ (which was our assumption), which implies that $$p$$ is.

All of this leads to $$p = 6p'$$ with $$p'$$ an integer, and also that $$q \equiv 1 \pmod 6$$ or $$q \equiv 5 \pmod 6$$.

Special cases: note that in general if a value of $$q$$ is impossible, then the value $$p-q$$ is impossible too.

• $$q = p$$ (or $$q = 0$$) is impossible, because in the first case $$p^2 + p^2 = 2p^2$$ which can't be a perfect square. This implies that $$q^2 + p^2 > p^2 \iff q^2 + p^2 \geq (p+1)^2 \iff q^2 \geq 2p+1$$.
• $$q = 1$$ is impossible, because $$1$$ can't be coprime with $$p$$.
• $$q = 2$$ is impossible because there's no pythagorean triple with a $$2$$ in it.
• $$q = 3$$ is impossible because it only appears in the triple $$(3,4,5)$$ (for $$a > 5, a^2 - (a-1)^2 = 2a - 1 > 9 = 3^2$$) and $$p-q = 2$$ can't be in a pythagorean triple.
• $$q = 5$$ ?
• $$q = 7$$ ?
• $$q = 11$$ ?
• $$q = 13$$ ?

We can also make tests for $$p$$. Thanks to Misha Lavrov, there's no solution for all $$p < 10^7$$!

Inequalities:

Because $$p = 0$$ is not interesting (this will implies that $$q$$ and $$p$$ aren't coprimes) we have: $$q^2 + p^2 > q^2 \iff q^2 + p^2 \geq (q+1)^2 \iff p^2 \geq 2q+1 \iff q \leq \frac{p^2 - 1}{2}$$, which gives an upper bound. This also gives us the lower bound $$q \geq \sqrt{2p+1}$$ and we have the same for $$p$$.

Applying it to $$p-q$$ we get: $$(p-q)^2 \geq 2p+1 \iff p^2 - 2pq + q^2 \geq 2p+1$$ And then: $$q^2 - 2pq + p^2 - 2p - 1 \geq 0 \iff p^2 - 2p(q+1) + q^2 - 1 \geq 0$$.

• We can solve for $$q$$, $$\Delta = 4p^2 - 4(p^2 - 2p - 1) = 4(2p+1)$$, and we have the two roots of the polynomial $$x_1 = p - \sqrt{2p+1}$$ and $$x_2 = p + \sqrt{2p+1}$$, meaning (if $$p \geq -\frac{1}{2}$$) we have $$q \leq p - \sqrt{2p+1}$$ or $$q \geq p + \sqrt{2p+1}$$.

• And we can solve for $$p$$, $$\Delta = 4(q+1)^2 - 4(q^2 - 1) = 4q^2 + 4q + 4 - 4q^2 - 4 = 4q$$. We have the two roots of the polynomial $$x_1 = q+1-\sqrt{q}$$ and $$x_2 = q+1 + \sqrt{p}$$, meaning (if $$q \geq 0$$) we have $$p \leq q+1-\sqrt{q}$$ or $$p \geq q+1+\sqrt{q}$$.

I think other inequalities should be useful, perhaps we can make ones with the fact that $$p$$ is a multiple of $$6$$.

If we need some information about pythagorean triples.

• One of $p$ and $q$ must be divisible by $3$ and one of $p, q, n$ divisible by $5$. Same for the second triple. Does that help any? – Mark Bennet Oct 10 '20 at 17:33
• Thank you! I think that it can prove that p must be a multiple of 3, I see that and I edit the post. – Uselessy495 Oct 10 '20 at 17:42
• I didn't find any solutions with $p < 10\,000\,000$. – Misha Lavrov Oct 10 '20 at 19:16
• I will write up the solution tommorow, but the idea is to use the parameterization for primitive Pythagorean triples and to use the pqrs method to solve the resulting equations. – Random Oct 10 '20 at 22:50

This solution unfortunately came out quite a bit longer than I expected (certainly not as easy as checking Sage), but it is entirely elementary and self contained. I'm sure there is a significantly shorter proof, but the idea is just to bash the equation using the $$pqrs$$ lemma and the parametrization for primitive Pythagorean triples.

As you have shown, $$p$$ must be even. Therefore by the parametrization of Pythagorean triples, there exist natural numbers $$a,b,c,d$$ such that

$$q = a^2 - b^2, p = 2ab, n=a^2+b^2$$

$$q-p = c^2 - d^2, p = 2cd, m =c^2+d^2$$

Equivalently, we are given four integers $$a,b,c,d$$ such that $$\gcd(a,b)=\gcd(c,d)=1, ab=cd, a^2-b^2=c^2-d^2+2cd$$

The $$pqrs$$ lemma states that given four positive integers $$a,b,c,d$$ such that $$\gcd(a,b)=\gcd(c,d)=1, ab=cd$$, there exist 4 pairwise coprime positive integers $$p,q,r,s$$ such that $$a=pq, b=rs, c=pr, d=qs$$. (The proof is simple: define $$p=\gcd(a,c), q=\gcd(a,d)...$$).

Using it here (this is a slight abuse of notation, as these $$p,q,r,s$$ are not related to the original $$p,q$$ but whatever), we get the equation

$$p^2q^2 - r^2s^2 = p^2r^2 - q^2s^2 +2pqrs$$

$$p^2(q^2-r^2) - 2pqrs +s^2(q^2-r^2)=0$$

Excluding the case $$q=r=1$$ (which you can easily check does not lead to a solution), this is a quadratic equation in $$p$$. For a quadratic equation to have a solution in integers, the discriminant must be a square, therefore $$s^2(q^2r^2-(q^2-r^2)^2)$$ is a square. Equivalently (as obviously $$s \neq 0$$),

$$(r^2 + rq - q^2)(q^2 + rq - r^2)$$ is a square. Notice that this is a product of two coprime integers (their $$\gcd$$ must divide their sum, which is $$2rq$$, but they are each coprime to $$2, r, q$$), so since their product is a square, each of them individually must be a square.

$$r^2 + rq - q^2 = e^2$$

$$q^2+ qr - r^2 = f^2$$

We will assume without loss of generality that $$r > q$$.

Adding and subtracting we get the equivalent equations

$$2qr = e^2 + f^2$$

$$2(r^2 - q^2) = e^2 - f^2$$

Notice from the first equation that $$e,f$$ must both be odd, and then looking $$\mod 4$$ we find that $$q,r$$ must both be odd as well. Using this, we define the four positive integers $$x = \frac{e+f}{2}, y= \frac{e-f}{2}, z = \frac{q+r}{2}, t = \frac{q-r}{2}$$, and we can rewrite our equation in these terms:

$$z^2 - t^2 = x^2 + y^2$$

$$2tz = xy$$

One of $$x,y$$ must be even, say $$x = 2x'$$. Then $$x'y = tz$$, and again using the $$pqrs$$ lemma we get four positive pairwise coprime integers $$p', q', r', s'$$ such that $$x' = p'q', y = r's', z = p'r', t = q's'$$, and the first equation can be written as

$$p'^2 r'^2 - q'^2 s'^2 = 4p'^2 q'^2 + r'^2 s'^2$$

$$p'^2 (r'^2 - 4q'^2) = s'^2(q'^2 + r'^2)$$

Therefore $$(q'^2 + r'^2)(r'^2 - 4q'^2)$$ is a nonzero square. We will show using the method of infinite descent that this cannot happen. Notice that $$\gcd(r'^2 - 4q'^2, r'^2 + q'^2) | 5q'^2$$, but they are both clearly coprime to $$q'$$ so $$\gcd(r'^2 - 4q'^2, r'^2 + q'^2) | 5$$.

Case 1: the gcd is equal to 1. In this case,

$$p'^2 = q'^2 + r'^2, r'^2 = s'^2 + (2q'^2)^2$$

A computation modulo 8 shows that r' must be odd, so these are two primitive Pythagorean triples. Using the parametrization we get numbers $$x',y',z',t'$$ such that $$r' = z'^2 - t'^2, q' = 2t'z', p' = t'^2 + z'^2$$ and $$r' = x'^2 + y'^2, 2q' = 2x'y', s' = x'^2 - y'^2$$

In other words we have found numbers $$x',y',z',t'$$ such that

$$2t'z' = x'y'$$

$$z'^2 - t'^2 = x'^2 + y'^2$$

Which is exactly what the original $$x,y,z,t$$ satisfied! So we can simply replicate the process we used to generate a smaller pair $$q', r'$$ such that $$(q'^2 + r'^2)(r'^2 - 4q'^2)$$ is a nonzero square. This means that what must eventually occur is

Case 2: the gcd is equal to 5.

Therefore there exist $$x,y$$ such that $$q'^2 + r'^2 = 5x^2, (r'-2q')(r'+2q')=5y^2$$.

Denoting $$k = \gcd(r'-2q', r'+2q')$$, we have two cases.

Case 2a) $$r'-2q' = 5k\cdot \alpha^2, r' + 2q' = k \cdot \beta^2$$ where $$y=k\alpha \beta$$, and $$\alpha, \beta$$ are coprime.

Then $$r' = k\cdot \frac{5 \alpha^2 + \beta^2}{2}, q' = k\cdot \frac{\beta^2 - 5 \alpha^2}{4}$$. Substituting this information into our equation we get that

$$r'^2 + q'^2 = (\frac{k}{4})^2 \cdot (125 \alpha^4 + 30 \alpha^2 \beta^2 + 5 \beta^4) = 5x^2$$

$$\beta^4 + 6\alpha^2 \beta^2 + 25\alpha^4 = (\frac{4x}{k})^2$$

$$(\beta^2 + 3\alpha^2)^2 + (4\alpha^2)^2 = (\frac{4x}{k})^2$$

Now, if both $$\alpha, \beta$$ are odd then we get $$(\frac{\beta^2 + 3\alpha^2}{4})^2 + (\alpha^2)^2 = (\frac{x}{k})^2$$, which is a Pythagorean triple with 2 odd numbers, which is impossible. Therefore, exactly one of $$\alpha, \beta$$ is even so $$\beta^2 + 3\alpha^2$$ is odd and $$(\beta^2 + 3\alpha^2)^2 + (4\alpha^2)^2 = (\frac{4x}{k})^2$$ is a primitive Pythagorean triple. One final use of the parametrization give us two positive integers $$m,n$$ such that

$$4\alpha^2 = 2mn, \beta^2 + 3\alpha^2 = m^2 - n^2$$

$$2\alpha^2 = mn$$, so one of $$m,n$$ is a square and the other twice a square.

Case 2a)i. $$m = 2u^2, n = v^2, \alpha = uv$$. Substituting, we get

$$\beta^2 = 4u^4 - 3u^2v^2 - v^4 = (4u^2 - v^2)(u^2 + v^2)$$, so we managed to create an even smaller pair $$u,v$$ which fits equation what we wanted from $$q', r'$$. As we cannot infinitely descend in this way we must eventually arrive at

Case 2b)ii. $$m = u^2, n = 2v^2, \alpha = uv$$. Substituting, we get

$$\beta^2 = u^4 - 3u^2v^2 - 4v^4 = (u^2-v^2)(u^2 + 4v^2) = (u-v)(u+v)(u^2 + 4v^2)$$

$$\gcd(u^2 - v^2, u^2 + 4v^2)|5$$. If the $$\gcd$$ is one they are both squares and we get $$v = gh, u = g^2 - h^2$$ from the second square and $$(g^2 - gh - h^2)(g^2 + gh - h^2)$$ is a square. We can use the same techniques to eventually arrive at a smaller pair $$q', r'$$.

If the $$\gcd$$ is five then we have another case which is similar (unfortunately I do not have time to write this up).

EDIT: I was a bit lazy here, it turns out that the $$\gcd$$ cannot be $$5$$: looking $$\mod 4$$ using the fact that $$u^2 - v^2$$ is 5 times a square we find that $$v$$ is even and $$u$$ is odd, but then $$u^2 + 4v^2 \equiv 1 (\mod 8)$$ which is not 5 times a square.

Case 2b) where $$r'-2q' = k\cdot \alpha^2, r' + 2q' = 5k \cdot \beta^2$$ where $$y=k\alpha \beta$$, and $$\alpha, \beta$$ are coprime is completely identical to Case 2a).

SUMMARY

We showed that to prove the problem it is sufficient to show that there do not exist a pair of coprime positive integers $$q', r'$$ such that $$(q'^2 + r'^2)(q'^2 - 4r'^2)$$ is a nonzero square. Then, we showed that given any such pair we can find a smaller pair of coprime positive integers such that the relevant product is a square. However, we cannot descend forever, which means that no such pair $$q', r'$$ exists, which proves the question.

• Thank you very much! I hoped to have an arithmetic demonstration. I just struggle a bit to understand each step (my fault), but when I do I'll valid your answer – Uselessy495 Oct 11 '20 at 16:30
• No problem, it definitely requires some digesting. If there's a specific step that you really can't figure out I'd be happy to help. – Random Oct 11 '20 at 16:34
• At 2t'z' = 2x'y' I think you meant 2t'z' = x'y'. At the case 2a), why (beta^2 + 3alpha^2)/4 with alpha, beta odd is necessary an integer (and then forming a pythagorean triple) ? Because I think it'll be a multiple of 1/2. and the same question for (x/k)^2 (I'm really sorry I think I missed something). – Uselessy495 Oct 11 '20 at 20:42
• Thanks I did indeed mean 2t'z' = x'y', I'll edit that now. As for case 2a: Every odd square is equal to 1 modulo 8, therefore (beta^2 + 3alpha^2) is equal to 4 modulo 8, so (beta^2 + 3alpha^2)/4 is an odd integer – Random Oct 11 '20 at 22:43

This is an elliptic curve, which is given as intersection of two quadrics.

For more details and references, see e.g. the GTM book by Silverman, The Arithmetic of Elliptic Curves.

We write $$n = q + u$$ and $$m = q + v$$. After simplification, we get $$\begin{eqnarray} 2qu &=& p^2 - u^2\\ 2q(p + v) &=& 2p^2 - v^2. \end{eqnarray}$$ which then leads to $$(p^2 - u^2)(p + v) = (2p^2 - v^2)u.$$

Viewing $$[p, u, v]$$ as projective coordinates, this is a plane cubic curve, with a rational point $$(p, u, v) = (0, 0, 1)$$.

Therefore we get an elliptic curve. We can use a computer algebra system to compute its rational points.

R.<p, u, v> = QQ[]
E = EllipticCurve((p^2 - u^2) * (p + v) - (2*p^2 - v^2) * u, [0, 0, 1])

print(E)
print(E.rank())
print(E.torsion_points())


The output:

Elliptic Curve defined by y^2 - 2*x*y - 2*y = x^3 + 5*x^2 + 8*x + 4 over Rational Field
0
[(-2 : -2 : 1), (-2 : 0 : 1), (-1 : 0 : 1), (0 : 1 : 0)]


The first line gives us a Weierstrass form of the curve.

The second line tells us that the Mordell-Weil group has rank $$0$$. Thus all rational points are torsion.

The third line lists out all torsion points. There are only $$4$$ of them. They correspond to the points $$[p, u, v] = [-1, 0, 1], [0, 1, 1], [0, 1, 0], [0, 0, 1]$$ in our model.

This shows that there is no non-trivial solution.