I want to implement a fast algorithm (avoiding or at least minimizing bruteforce) which for a given square number $n$ calculates a series of positive integers $y$ up to a certain limit $l$ such that $n+y^2$ is again a perfect square?
I can obtain the trivial case $y=\frac{1}{2}(n-1)$ as described in the answer and comments on this question using the equation $(x-y)(x+y)=x^2-y^2$.
Example: Let us take $n=225(=15^2)$, we obtain one solution $y=\frac{1}{2}(225-1)=112$ directly. But how we can obtain the whole list $(8, 20, 36, 112)$?
My ideas: As described here I came across the so called "Norm-Form Equation", which is a diophantine equation of the form $x^2-Dy^2=n$ and we have the special case $D=1$. To deal with this Norm-Form Equation, in his book Richard A. Mollin involves the divisor function.
Refering to our example, if we can deduce the other $y$-values $8,20,36$ from the (directly obtained) value $y=112$, it would allow me to speed up my bruteforce search drastically.
Note: If we cannot avoid bruteforce completely, I would be greateful for an approach that at least minimizes the search for these $y$-values.
For the given problem, you neither need Pell-like equations nor Pythagorean triples. You just need , as mentioned , the divisors of $\ n\ $ :
You want the solutions of $$n+y^2=z^2$$ with positive integers $\ y\ $ and $\ z\ $
This means $$n=(z-y)(z+y)$$
Hence every pair of positive integers $a,b$ with $ab=n$ , where $a,b$ have the same parity gives a solution : $y=\frac{a-b}{2}$ , $z=\frac{a+b}{2}$
To ensure that $y$ is positive, $a$ must exceed $\sqrt{n}$
In PARI/GP, the following routine determines the pairs of positive integer solutions :