All primes $p,q,r$ such that $(p-q)^2+1=r$

How can one find all prime numbers $p,q,$ and $r$ such that $$(p-q)^2+1=r\ ?$$

-
Taking $r = 5$, we need to find all twin primes. So this question is rather difficult. –  Yuval Filmus Apr 12 '11 at 14:03
It would also go a long way towards finding primes of the form $n^2+1$ (it would solve it if we knew every even integer were the difference of two primes). –  Zev Chonoles Apr 12 '11 at 14:26
why did you post this question?? –  quanta Apr 12 '11 at 14:27
Hmmm, yeah, I am sorry. :( This problem is nonsense. I cannot delete it now, can someone please delete it for me? Sorry again. –  Amir Hossein Apr 12 '11 at 14:45
I don't mean that it's a bad question but how did you come up with it? .. Where do you find all these diophantine problems? –  quanta Apr 12 '11 at 16:47

Yuval is right, this question is very hard. Breaking it up into 3 cases:

1. $r - 1$ is not a perfect square, in which case there are no solutions.
2. $r - 1$ is a perfect square and $r$ is even, in which case $p - q$ is odd and so one of them (say $q$, noting that if $(p,q)$ is a solution then $(q,p)$ is as well) is $2$ and so $p = 2 + \sqrt{r - 1}$, which may or may not be a solution. If it is a solution, it is unique aside from switching the order of $p$ and $q$.
3. $r - 1$ is a perfect square and $r$ is odd. This problem is open for all such values of $r$.

Edit: As Zev pointed out, $r$ even $\implies r = 2$ because if $r > 2$ we have $r - 2 = (p - q - 1)(p - q + 1)$ is even thus both terms $(p - q - 1),(p - q + 1)$ are and so we can continue to factor out $2$, i.e. $2^n | r - 2$ for all $n > 1$, a clear contradiction.

-
$r$ is even $\Rightarrow$ $r=2$... –  Zev Chonoles Apr 12 '11 at 14:22

The Hardy-Littlewood conjecture E says that there are infinitely many primes of the form $n^2+1$ (and gives an asymptotic density); de Polignac's conjecture says that there are infinitely many primes, indeed consecutive primes, with a specified even distance. So on these conjectures there are infinitely many $r$ such that $r-1$ is a perfect square, and for any such choice ($r\neq2$) there are infinitely many $p,q$ such that $(p-q)^2+1=r.$

-