# Diophantine equation $(n-x-y)^2 = 4xy + 1$

Given the Diophantine equation $(n-x-y)^2 = 4xy + 1$ where n is known and x, y are unknown: (1) Is there a single solution for any given n, or are there multiple solutions? (2) How does one determine the unknowns x, y?

• $$(x+y-n)^2=4xy+1$$ $$x=k(nk\mp1)$$ $$y=(k\pm2)(nk\mp1)+n+1$$ Nov 3 '15 at 4:56

I'm assuming $n > 0.$ Write $u = x-y$ and $v = x+y.$ We get the evident parabola $$2nv = u^2 + n^2 - 1,$$ with the restriction $$u \equiv v \equiv n+1 \pmod 2.$$ The restriction $u^2 + n^2 - 1 \equiv 0 \pmod n$ tells us that we also require $$u^2 \equiv 1 \pmod n.$$ If $n$ is prime, this is just $u \equiv -1 \pmod n$ and $u \equiv 1 \pmod n.$ If $n$ is composite there may be more than two square roots of $1 \pmod n.$

Given all that, there are infinitely many solutions, including the four $(x = n-1, y=0); \;$ $(x = n+1, y=0); \;$ $(x = 0, y=n-1); \;$ $(x = 0, y=n+1).$

Having found $u,v$ that works, we have $$x = \frac{u+v}{2},$$ $$y = \frac{-u+v}{2}.$$

In the picture below, with $n=3,$ we see the $x$ and $y$ intercepts at $2$ and $4.$ We have $6 v = u^2 + 8.$ We require $u$ even, but we also require $u$ not divisible by $3,$ so its square will be $1 \pmod 3.$ Here is a table, taking only $u > 0,$ so $x > y.$ You may also interchange $x,y.$

$$\begin{array}{cccc} u & v & x & y \\ \hline 2 & 2 & 2 & 0 \\ 4 & 4 & 4 & 0 \\ 8 & 12 & 10 & 2 \\ 10 & 18 & 14 & 4 \\ 14 & 34 & 24 & 10 \\ 16 & 44 & 30 & 14 \\ 20 & 68 & 44 & 24 \\ 22 & 82 & 52 & 30 \end{array}$$ With $n$ a little larger and composite, we may be able to get a solution with $x,y$ positive but $x+y < n,$ somewhere along the short parabola arc strictly between $(0,n-1)$ and $(n-1,0).$ Here $n=15.$

$$\begin{array}{cccc} u & v & x & y \\ \hline 4 & 8 & 6 & 2 \\ 14 & 14 & 14 & 0 \\ 16 & 16 & 16 & 0 \\ 26 & 30 & 28 & 2 \\ 34 & 46 & 40 & 6 \\ 44 & 72 & 58 & 14 \\ 46 & 78 & 62 & 16 \\ 56 & 112 & 84 & 28 \end{array}$$ Note $u \equiv 4,14,16,26 \pmod{30}.$ • Thanks! One clarifying question. You write "If n n is prime, this is just u≡−1(modn) and u≡1(modn)." Do you mean "If n n is prime, this is just u≡−1(modn) OR u≡1(modn)"? Nov 3 '15 at 2:51
• @SPSmith, both work, as in the table I included for $n=3.$ Nov 3 '15 at 2:53