I am looking at the equation $$\frac{4n^2-x}{x+1} = y$$ for even $x$ and $y$, both positive. Under what situations does $x+1$ divide $4n^2-x$?
-
@ArturoMagidin Isn't this just restating the problem? It's the same as 2k+1 dividing 2n^2-k, but I am trying to find a systematic way to find solutions that don't require trial and error – MyNameIsKhan Jun 24 '12 at 05:20
-
@ArturoMagidin That is what I meant by "under what situations does x+1 divide." I know that x being even is the same as replacing it with 2k, but this doesn't address the question at hand – MyNameIsKhan Jun 24 '12 at 05:24
-
I suppose I am saying I do not see how the original post is ambiguous in any way. I am asking when one divides the other. The answer "when 2k+1 divides 4n^2-2k" sounds tautological to me given the problem as defined. – MyNameIsKhan Jun 24 '12 at 05:28
-
2I need to explicitly mention that I am aware that even numbers are divisible by 2? You're assuming I am clueless and unaware of this? Honestly, I find that a little condescending. I would also appreciate you not deleting your posts, as it makes my earlier posts look odd and out of context. – MyNameIsKhan Jun 24 '12 at 05:32
-
Feel free to delete your comments, since they add nothing except telling me I should have known what you knew and what you didn't know. Since my posts were a waste of time, I see no reason to keep them up. – Arturo Magidin Jun 24 '12 at 05:34
-
We can rewrite the problem as finding all integer solutions $(n,k)$ to the congruence $$2n^2\equiv k\mod 2k+1,$$ I take it. – anon Jun 24 '12 at 05:38
-
@ArturoMagidin Yes, I think it is reasonable to expect that people know that I know what even numbers are. Am I being trolled here or something? – MyNameIsKhan Jun 24 '12 at 05:39
-
@anon Are there methods to finding integer solutions to such congruences? – MyNameIsKhan Jun 24 '12 at 05:41
-
2@AgainstAsicilian: Take a look around questions in this site. We get everything from retired, highly accomplished researchers, to people who would be utterly clueless as to how to proceed with the problem you pose, even to the point of not being able to reduce it even that simple step. I erred in trying to divine your level of competence from your plain post that contained no indication of what that level might be. Should I have guessed higher? Perhaps. Should you consider it an insult to your intelligence or an attempt at getting a rise from you? No. – Arturo Magidin Jun 24 '12 at 05:46
-
Since $2(2k^2)\equiv(2k+1)^2+1\equiv1$, with the Legendre symbol we have $$\begin{array}{c c} 2n^2\equiv k \iff n^2\equiv 2k^3\pmod{2k+1} \ \iff\quad~ \displaystyle p\mid(2k+1)\implies\left(2k\atop p\right)=1.\end{array}$$ The problem of fully characterizing these solutions doesn't seem very easy to me. (I've suppressed existential quantifiers on $n$.) – anon Jun 24 '12 at 05:56
-
I am afraid I don't understand what the Legendre symbol is or what that last bit means. Is that a combinatoric? – MyNameIsKhan Jun 24 '12 at 05:59
-
It has to do with Quadratic Reciprocity. – anon Jun 24 '12 at 05:59
-
1@anon: If $p|2k+1$, then $2k\equiv -1\pmod{p}$, hence $\left(\frac{2k}{p}\right) = 1$ if and only if $\left(\frac{-1}{p}\right)=1$ if and only if $p=2$ or $p\equiv 1\pmod{4}$. So your implication is equivalent to $p|2k+1 \implies p\equiv 1\pmod{4}$. Hence, $2k+1$ cannot be divisible by any prime that is congruent to $3$ modulo $4$. – Arturo Magidin Jun 24 '12 at 06:12
-
What does that mean? Primes in the form 1 modulo 4 are somehow important? – MyNameIsKhan Jun 24 '12 at 06:16
-
@AgainstASicilian: it means that a necessary (and possibly sufficient) condition is that the odd prime divisors of $x+1$ have to be congruent to $1$ modulo $4$. – Arturo Magidin Jun 24 '12 at 06:17
-
@ArturoMagidin Ah, of course! – anon Jun 24 '12 at 06:20
-
So this implies I can just generate primes that are 1 modulo 4, fuse them together in all possible ways, and each resulting product = 2k+1, allowing me to get k. Once I know k, I test the different y's? Or is there a direct way to get those too? – MyNameIsKhan Jun 24 '12 at 06:34
-
@AgainstASicilian: once you have $k$ you need to find solutions to $n^2\equiv 2k^3\pmod{2k+1}$. Each such value of $n$ will give you an expression on the left hand side which is an even integer, thus giving you the value of $y$. – Arturo Magidin Jun 24 '12 at 06:36
-
So example case: I look at prime 13. 2k+1=13, k=6. Can I solve for values of y and have it generate n values? – MyNameIsKhan Jun 24 '12 at 06:38
-
@AgainstASicilian: Yes. You need first to find $m$ such that $m^2\equiv -1\pmod{13}$. They are $m\equiv 5\pmod{13}$ and $m\equiv 8\pmod{13}$. Then you multiply them by $k$ to get solutions to $n^2\equiv 2k^3\pmod{13}$: $n\equiv 4\pmod{13}$ and $n\equiv 9\pmod{13}$. So each value of $n=13r+4$, with $x=12$, will give you a value of $y$: $n=4$ gives $y=4$, $n=43$ gives $y=568$; and each value of $n=13s+9$ will give you a value for $y$ as well. – Arturo Magidin Jun 24 '12 at 06:51
-
@ArturoMagidin Maybe modular arithmetic isn't my forte or anything, but I am having trouble understanding. I understand how to get k values. I am having trouble going from there to generating n values. – MyNameIsKhan Jun 24 '12 at 06:54
-
@AgainstASicilian: First you need to solve the congruence $m^2\equiv -1\pmod{2k+1}$. For each solution, which is of the form $m\equiv a\pmod{2k+1}$ for some $a$, you get the solutions $n\equiv ak\pmod{2k+1}$. For each such $n$ (all of which are of the form $ak+r(2k+1)$, with $r$ an arbitrary integer), plugging in will give you a value of $y$ for that $n$ and $x=2k$. But I don't know how to express $a$ in terms of $k$; all we have is a recipe for finding all solutions for a given $k$, not a formula. – Arturo Magidin Jun 24 '12 at 07:00
-
So all valid n's are ak+r(2k+1), so when I find a valid k, again say prime is 13 so k = 6, this means 6a + 13r = n correct? Then does this mean I just loop through all the combinations of a and r to get all valid solutions to n? – MyNameIsKhan Jun 24 '12 at 07:03
-
@AgainstASicilian: It's not a loop: it's an infinite family of solutions, one for each solution to $m^2\equiv -1\pmod{2k+1}$. – Arturo Magidin Jun 24 '12 at 07:08
-
My ignorance is really showing hard here. How do I know when m^2 is congruent to -1 mod 2k+1 and how does this give me what I need? – MyNameIsKhan Jun 24 '12 at 07:08
-
@ArturoMagidin I looked online a little, am I correct in saying that this is the same as saying m^2 = (2k+1)*X - 1 where X is an arbitrary number? So for each value of X, I check if the result is a perfect square? – MyNameIsKhan Jun 24 '12 at 07:18
-
(I've updated my answer to be more comprehensive, I hope it helps you now. Elementary number theory and in particular modular arithmetic is still very heavily assumed.) – anon Jun 24 '12 at 10:41
-
@AgainstASicilian: A much better one is to try to find solutions to $m^2\equiv -1\pmod{p}$ for $p$ the primes that divide $2k+1$, because there are fewer remainders to try (you just need to check the numbers $2,3,\ldots,\frac{p-1}{2}$ until you get a solution, and then the two solutions are $a$ and $p-a$). Once you know the solutions modulo $p$, you can lift them to solutions modulo $p^n$ as necessary using Hensel's Lemma, and then combine them to get a solution modulo $2k+1$ using the Chinese Remainder Theorem. – Arturo Magidin Jun 24 '12 at 18:22
-
I don't know how to lift them. Apparently for a single prime p of multiplicity 1, no lifting is needed and I get the value of m^2 modulo 2k+1 by doing ((p-1)/2)! – MyNameIsKhan Jun 24 '12 at 18:24
-
@AgainstASicilian: Real up on Hensel's Lemma. It tells you how to "lift them". Then read up on the Chinese Remainder Theorem, it tells you how to glue them. This is basic elementary number theory, the kind I was supposed to give you credit for, remember? So... apparently now I'm incorrectly assuming you do know stuff? – Arturo Magidin Jun 24 '12 at 18:26
-
Computing $((p-1)/2)!$ modulo $p$ is computationally expensive for large primes. You'd be better off with other methods. – Arturo Magidin Jun 24 '12 at 18:28
-
Assuming that someone knows even numbers are divisible by 2 is a far, far cry from knowing if someone knows Hensel's Lemma or CRT. I know CRT anyway. I don't understand Hensel's Lemma even after reading up on it. – MyNameIsKhan Jun 24 '12 at 18:28
-
Methods like what? – MyNameIsKhan Jun 24 '12 at 18:28
-
You've been given the names of two algorithms. At this point, you need to read up and learn. But even trial multiplication will be faster than computing $[(p-1)/2]!$, since you would only need to try $\lfloor \sqrt{p}\rfloor^2$, $(\lfloor \sqrt{p}\rfloor + 1)^2$, etc. until you hit a solution modulo $p$. Fewer expected computations. Hensel's Lemma gives you a formula for computing the solution. It's even there in the Wikipedia article, right at the top. What is it you don't understand about an explicit formula that tell you how to take the solution modulo $p$ to get the one modulo $p^k$? – Arturo Magidin Jun 24 '12 at 19:41
-
Because to get the solution modulo p don't you need the factorial thing to start off with? – MyNameIsKhan Jun 24 '12 at 19:42
-
@AgainstASicilian As Arturo just mentioned, trial division can get a solution modulo $p$ and is comparable or more efficient. In chat Henning also mentioned randomly looking for generators, and the trick for that would be to compute $x^{(p-1)/2}$ using exponentiation-by-repeated squaring (squaring within modular arithmetic); if this is $-1\bmod p$ then $x^{(p-1)/4}$ is a square root of $-1$ modulo $p$. – anon Jun 24 '12 at 20:27
4 Answers
(This answer has been seriously updated to be more comprehensive.) As noted, the condition
$$(x+1)\mid(4n^2-x),~~~x\text{ even} \tag{$\bullet$}$$
implies that $x$ can be written $2k$, and subsequently is equivalent to $2n^2\equiv k\bmod 2k+1$.
For the moment, fix $k$. Congruences will be modulo $m:=2k+1$ unless otherwise stated. Suppose the prime factorization of $m$ is $\prod p^r$ (we abusively leave indices out for brevity). Since
$$2(2k^2)\equiv(2k+1)^2+1\equiv1,$$
it follows that there is an explicit inverse $2^{-1}\equiv 2k^2$. Now there is a chain of equivalences:
$$\exists n: 2n^2\equiv k ~~~\iff~ \exists n: n^2\equiv 2k^3 \tag{1}$$ $$\hskip -0.5in \iff \exists n: (n k^{-1})^2\equiv 2k\equiv-1 \tag{2}$$ $$\hskip 0.22in \iff \exists n: n^2 \equiv -1\bmod p^r\;\text{ for each }p|m \tag{3}$$ $$\hskip 0.23in \iff \exists n: n^2\equiv -1\bmod p ~~\text{ for each }p|m \tag{4}$$ $$\hskip -0.25in \iff p\equiv1\bmod 4 ~~\text{ for each }p|m. \tag{5}$$
Note that these are equivalences, not just implications, so $(5)$ is both necessary and sufficient for the existence of a a valid $n$ for a given $k$ (remember $m:=2k+1$ here). Explanations:
- $(1)$ follows from simply multiplying both sides by $2^{-1}\equiv2k^2$;
- $(1)\iff(2)$ follows from dividing by $k^2$;
- $(2)\iff(3)$ follows from the Chinese Remainder Theorem (CRT);
- $(3)\iff(4)$ follows from Hensel's lemma (HL);
- $(4)\iff(5)$ follows from Quadratic Reciprocity (QR).
Technical note. In propositional logic, something like $A\iff B\iff C$ would be ambiguous for lack of parentheses. However, in outside and more casual contexts, it may in fact stand for the formula $(A\iff B)~\&~(B\iff C)$ (logical and); this works with chains of equivalences too. Also, the symbols "$\exists n:$" stand for "there exists an $n$ such that."
Working "backwards" from $(5)$: arbitrarily pick a set of prime powers $p^r$, each prime congruent to one modulo four, multiply them together and call the result $m$. QR guarantees the existence of at least two distinct solutions $\pm n_p$ to the equations $u^2\equiv-1\bmod p$ (in fact basic field theory says there will be precisely two solutions, since $p\ne2$). HL guarantees that these lift up uniquely to the two solutions $\pm\,\hat{n}_p$ to the congruences $u^2\equiv-1\bmod p^r$. CRT guarantees there is a unique solution $n$ that satisfies $u^2\equiv-1\bmod p^r$ for each $p^r$, which is equivalent to $u^2\equiv-1\bmod m$ (unique modulo $m$ for a specific choice of roots, that is: note the $\pm$ signs).
To compute $n_p$ (for each prime $p|m$), we use this fact: $$\begin{array}{c l} (p-1)! & \equiv 1\cdot 2\cdots\frac{p-1}{2}\frac{p+1}{2}\cdots (p-1) \\ & \equiv 1\cdot 2\cdots\frac{p-1}{2}\left(p-\frac{p-1}{2}\right)\cdots\big(p-(1)\big) \\ & \equiv \left(\frac{p-1}{2}\;!\right)^2(-1)^{(p-1)/2} \mod p. \end{array} \tag{$\bigcirc$}$$ When $p\equiv1\mod 4$, $(-1)^{(p-1)/2}=-1$, thus (applying Wilson's theorem to the LHS): $$n_p\equiv \left(\frac{p-1}{2}\right)!\mod p \tag{$\times$}$$ is a square root of $-1$ modulo $p$. Note that computing factorials can be expensive, so you want to do it via repeated modular multiplication, which is more efficient.
To compute $\hat{n}_p$, the solution to $f(u):= u^2+1\equiv0\mod p^r$, we apply HL. First we evaluate $f\,'$ (the derivative) at the argument $n_p$, getting $2n_p$, and compute the multiplicative inverse of $2n_p$ modulo $p^{r-1}$ and multiply by the integer $-f(n_p)/p$; in other words $$\hat{n}_p\equiv-\left(\frac{n_p^2+1}{p}\right)\left[\frac{1}{2n_p}\bmod p^{r-1}\right] \mod p^r \tag{$\square$}$$ Note that since $p|(n_p^2+1)$, the division in parentheses is integer division, and the reciprocal in brackets is computed via modular arithmetic $\bmod p^{r-1}$, but then viewed $\bmod p^r$ afterwards. Furthermore, we may multiply $\hat{n}_p$ by $-1\bmod p^r$ to get a second square root of $-1\bmod p^r$; call these two roots $n_p^+$ and $n_p^-$ respectively. An arbitrary choice of $\pm$ is available for each $p$.
Using the general case formula for CRT, we glue all of the "localized" solutions together: $$n\equiv \sum_{p}n_p^{\pm}\left(\frac{m}{p^r}\right)\left[\left(\frac{m}{p^r}\right)^{-1}\bmod p^r \right] \mod m \tag{$\triangle$}$$ Again, a choice of $+$ or $-$ is made for each $p$. Counterintuitively, these do not designate the notions of "positive" or "negative"; they designate an initially computed root versus an optional, auxiliary root. Above, division in parentheses is done in the integers (so not in modular arithmetic), whereas the reciprocals in brackets are computed $\bmod p^r$ (for various values of $p$), and then the results are reinterpreted as integers $\bmod m$.
After the $2^{\omega(m)}$ solutions $n$ to $u^2\equiv-1\bmod m$ are collected (here $\omega(m)$ stands for the number of primes in $m$'s prime factorization, which was the number of $\pm$ choices that occurred), we may characterize the full set of solutions to our original condition $(\bullet)$ by, for each $m$ we created, moving backwards by setting $k=(m-1)/2$ and adding arbitrary multiples of $m$ to any of the solutions $n$ to the congruence $u^2\equiv-1\bmod m$ we've formed.

- 151,657
-
I'm CWing 'cause AM finished typing way before me. Technically there's a distinction between $(A\iff B)\iff C$ and the 'casual' interpretation of $A\iff B\iff C$, which is to split into $A\iff B$ and $B\iff C$. I'm following the latter route. – anon Jun 24 '12 at 06:50
-
Once I get k, is there a way to solve for y and generate a family of n values? – MyNameIsKhan Jun 24 '12 at 06:51
-
@AgainstASicilian: You need to have the solutions to $m^2\equiv -1\pmod{2k+1}$. This requires you to solve the congruence modulo the prime powers that divide $2k+1$. I don't know of a formula, but you can write down an expression for $y$ in terms of the solutions to that congruence. Note that the number of solutions to the congruence will be $2^t$, where $t$ is the number of distinct prime factors of $2k+1$ (all of which must be congruent to $1$ modulo $4$). It is fairly straightforward to generate solutions given $k$, but it seems pretty hard to write them down in terms of $k$. – Arturo Magidin Jun 24 '12 at 06:54
-
To compute square roots in modular arithmetic, there are e.g. the Cipolli or Tonelli-Shanks algorithms (I know nothing about these), but I don't believe there is a straightforward formula. Note that computing the square root of $-1$ modulo primes, needs to be taken up to modulo prime powers vie Hensel, and then glued together to find a solution modulo the composite number $m$ via CRT. | Also, I guess it would have been more sensible to write $2k^3\equiv-1$ before localizing to prime power moduli, but it works either way. – anon Jun 24 '12 at 06:57
-
To elucidate anon's comments. Writing $x=2k$, we have $$\frac{4n^2-x}{x+1} = \frac{4n^2-2k}{2k+1} = \frac{2(2n^2-k)}{2k+1}.$$ Thus, the left hand side is an integer if and only if $2n^2\equiv k\pmod{2k+1}$.
Now, as anon noted, since $4k^2\equiv 1\pmod{2k+1}$, we can rewrite $2n^2\equiv k\pmod{2k+1}$ as $2n^2\equiv 1k \equiv 4k^3\pmod{2k+1}$. Since $2k+1$ is odd, we can cancel $2$ to get $n^2\equiv 2k^3\pmod{2k+1}$. That means that $2k^3$ must be a square modulo $2k+1$. And this occurs if and only if $2k$ is a square modulo $2k+1$. Since $2k\equiv -1\pmod{2k+1}$, this occurs if and only if $-1$ is a square modulo $2k+1$.
Now, if this occurs, and $p$ is a prime that divides $2k+1$, then $-1$ will also be a square modulo $p$. It is well known that the only odd primes for which $-1$ is a square are the primes that are congruent to $1$ modulo $4$. Thus, if $2n^2\equiv k\pmod{2k+1}$, then every prime that divides $2k+1=x+1$ must be congruent to $1$ modulo $4$. Conversely, suppose that every prime that divides $2k+1$ is congruent to $1$ modulo $4$. Then $-1$ is a square modulo all prime powers that divides $2k+1$, and so we can find $n$ such that $n^2 \equiv 2k^3 \pmod{2k+1}$. Hence, we can find $n$ such that $2n^2\equiv k\pmod{2k+1}$, hence $x+1$ will divide $2n^2-x$.
Thus, there exists $n$ such that $x+1$ divides $2n^2-x$ if and only if $x+1$ is a product of primes that are congruent to $1$ modulo $4$.
For example, with $x+1=5$ (so $k=2$), we need an $n$ such that $n^2\equiv 16\equiv 1\pmod{5}$. Thus, each value of $n\equiv 1\pmod{5}$ and each value of $n\equiv43\pmod{5}$ gives a solution $(x,y,n)$: e.g., if $n=11$, then $$\frac{4n^2-x}{x+1} = \frac{4(121)-4}{5} = 4(24).$$ So for $k=2$, we get families of solutions $(5r+1,4,y)$ and $(5r+4,4,y)$, with $y$ being given by the formula you have.
Or say $x+1=169 = 13^2$ (so $k=84$). We need to find the $n$ such that $n^2\equiv 2(84)^3 \pmod{169}$. This is equivalent to finding $m$ such that $m^2\equiv 168\equiv -1\pmod{169}$, and then multiplying by $k=84$ to get the right answer. One such solution is $m\equiv 70\pmod{169}$, the other being $m\equiv 99\pmod{169}$. So the solutions to $n^2\equiv 2(84)^3\pmod{169}$ are $n\equiv 70(84)\equiv 134\pmod{169}$ and $n\equiv 99(84)\equiv 35\pmod{169}$.
Thus, one solution has $n=35$, $x=168$, and $y=28$. Another is $n=169+134=303$, $x=168$, and then $y=2172$.
Etc.
It all comes down to having the solutions to $m^2\equiv -1\pmod{2k+1}$. There are exactly $2^t$ solutions, where $t$ is the number of distinct prime factors of $2k+1$ (all of which are required to be congruent to $1$ modulo $4$). Each solution generates an infinite family of values of $n$ and $y$ that solve the equation and that can be written down explicitly in terms of the solution. However, writing down the solutions to the congruence in terms of $k$, even when $2k+1$ is prime, seems pretty difficult (if it can be done at all, and I suspect there are no known efficient algorithms; added: $((p-1)/2)!$ and $p-((p-1)/2)!$ are solutions modulo $p$, but they are computationally expensive to calculate; using Hensel's Lemma to lift them for prime powers is relatively simple, and using the Chinese Remainder Theorem to glue them for a solution modulo $2k+1$ is fairly straightforward as well. The last one is relatively cheap, computationally, but difficult to write out explicitly in terms of $k$ alone).
So, given a $k$ such that $2k+1$ is the product only of primes congruent to $1$ modulo $4$, to find all $n$ and $y$ for which $(n,2k,y)$ is a solution we proceed as follows:
Find all solutions to the congruence $m^2\equiv -1\pmod{2k+1}$. This congruence has $2^t$ solutions modulo $2k+1$, where $t$ is the number of distinct prime factors of $2k+1$.
For each solution $m\equiv a\pmod{2k+1}$, and each integer $r$, let $n=ak+(2k+1)r$. Then $y = \frac{4n^2-x}{x+1}$ will be an integer.
Thus, each of the $2^t$ solutions to $m^2\equiv -1\pmod{2k+1}$ gives rise to an infinite family of solutions: if $m\equiv a\pmod{2k+1}$ is a solution to the congruence, then $$\left(ak+(2k+1)r, 2k, \frac{4(ak+(2k+1)r)^2 - 2k}{2k+1}\right),\qquad r\in\mathbb{Z}$$ is an integer solution to the original equation.

- 398,050
I will throw another wooden nickel on the fire.
Since $\dfrac{4n^2-x}{x+1}+1=\dfrac{4n^2+1}{x+1}$, we get that the question is equivalent to asking when $$ x+1\,|\,4n^2+1\tag{1} $$ Trivially, $x=0$ and $x=4n^2$ satisfy $(1)$, and these are the only solutions when $4n^2+1$ is prime. Let's look for less trivial solutions. That is, let us look at when $4n^2+1$ is composite.
Suppose there is a prime $p$ so that $$ p\,|\,4n^2+1\tag{2} $$ $4n^2+1$ is odd, so $p$ must be odd. Furthermore, condition $(2)$ says that $-1\equiv(2n)^2\pmod{p}$; that is, $-1$ is the square of some number $\bmod{p}$ (usually said as "$-1$ is a quadratic residue $\bmod{p}$").
Intro to Quadratic Residues
Suppose that $p$ is an odd prime and $a\not\equiv0\pmod{p}$ is a quadratic residue $\bmod{p}$. There is an $x$ so that $x^2\equiv a\pmod{p}$. First, note that $x\not\equiv0\pmod{p}$. Therefore, by Fermat's Little Theorem, $$ a^{\frac{p-1}{2}}\equiv x^{p-1}\equiv1\pmod{p}\tag{3} $$ Consider the equation $$ (x^{\frac{p-1}{2}}+1)(x^{\frac{p-1}{2}}-1)=x^{p-1}-1\equiv0\pmod{p}\tag{4} $$ Since $\mathbb{Z}_p$ is a field, there are at most $\frac{p-1}{2}$ solutions to each of $$ x^{\frac{p-1}{2}}+1\equiv0\pmod{p}\quad\text{and}\quad x^{\frac{p-1}{2}}-1\equiv0\pmod{p}\tag{5} $$ However, Fermat's Little Theorem says there are $p-1$ solutions to $(4)$. Therefore, there are exactly $\frac{p-1}{2}$ solutions to each relation in $(5)$.
Consider the set of non-zero, quadratic residue classes, $Q$. For each $a\in Q$, there are exactly two solutions for $x^2=a$ ($x$ and $-x$). Thus, $|Q|=\frac{p-1}{2}$. For each $a\in Q$, we showed in $(3)$ that $a^{\frac{p-1}{2}}\equiv1$. The pigeonhole principle and $(5)$ say that for the $\frac{p-1}{2}$ non-zero, non-quadratic residue classes $\bmod{p}$, we have $a^{\frac{p-1}{2}}\equiv-1\pmod{p}$.
Thus, we have shown that for an odd prime $p$, $$ a^{\frac{p-1}{2}}\equiv\left\{\begin{array}{}+1\pmod{p}&\text{if }a\text{ is a quadratic residue }\bmod{p}\\-1\pmod{p}&\text{if }a\text{ is not a quadratic residue }\bmod{p}\end{array}\right.\tag{6} $$ For example, $-1$ is a quadratic residue $\bmod{p}$ if and only if $(-1)^{\frac{p-1}{2}}\equiv1\pmod{p}$; that is, if and only if $p\equiv1\pmod{4}$.
Therefore, if $x+1$ is divisible by any prime $p\not\equiv1\pmod{4}$, then $\dfrac{4n^2-x}{x+1}$ cannot be an integer.
If $4n^2+1$ is prime, there are only trivial solutions, and if $4n^2+1$ is composite, then $x+1$ can be any factor of $4n^2+1$.

- 345,667
I feel like the existing answers make the problem far too complicated. Let $u=x+1$ and $v=y+1$; then by easy algebra, the given equation is the same as $4n^2+1 = uv$. Since $x$ and $y$ are both even and positive, $u$ and $v$ must be odd (no problem, since $4n^2+1$ is odd) and at least $3$. Therefore the solutions are in 1-to-1 correspondence with the nontrivial factorizations (if any) of $4n^2+1$.

- 78,820