Generating correct $(a,..,z)$ tuples for the polynomial defined in “Diophantine representation of the set of prime numbers” (Jones et al)

I am reading "Diophantine representation of the set of prime numbers" (Jones, Sato, Wada, Wiens), and to understand the prime generating polynomial (credits to @JoelReyesNoche for writing the polynomial here):

$$(k+2)(1-(wz+h+j-q)^2-((gk+2g+k+1)\cdot(h+j)+h-z)^2-(2n+p+q+z-e)^2-(16(k+1)^3\cdot(k+2)\cdot(n+1)^2+1-f^2)^2-(e^3\cdot(e+2)(a+1)^2+1-o^2)^2-((a^2-1)y^2+1-x^2)^2-(16r^2y^4(a^2-1)+1-u^2)^2-(((a+u^2(u^2-a))^2-1)\cdot(n+4dy)^2+1-(x+cu)^2)^2-(n+l+v-y)^2-((a^2-1)l^2+1-m^2)^2-(ai+k+1-l-i)^2-(p+l(a-n-1)+b(2an+2a-n^2-2n-2)-m)^2-(q+y(a-p-1)+s(2ap+2a-p^2-2p-2)-x)^2-(z+pl(a-p)+t(2ap-p^2-1)-pm)^2)$$

... I have prepared a Python program to bring some of the $(a,..,z)$ tuples that applied to the polynomial shown in the paper provide prime numbers. The questions are at the end of the explanation.

Probably I am doing something wrong or I did not understand exactly how to use the polynomial, but I can not obtain a single correct example of tuple. This is the Python code (please be free to use it and modify it). I have tried to be careful about the parenthesis (but could be wrong). It takes random positive vales for $(a,..,z)$ and apply them to the polynomial, but unfortunately so far I did not get any good example:

def dp():
from random import randint

lop=[]
test_limit=30000
times=1000

a=randint(1,test_limit)
b=randint(1,test_limit)
c=randint(1,test_limit)
d=randint(1,test_limit)
e=randint(1,test_limit)
f=randint(1,test_limit)
g=randint(1,test_limit)
h=randint(1,test_limit)
i=randint(1,test_limit)
j=randint(1,test_limit)
j=randint(1,test_limit)
l=randint(1,test_limit)
m=randint(1,test_limit)
n=randint(1,test_limit)
o=randint(1,test_limit)
p=randint(1,test_limit)
q=randint(1,test_limit)
r=randint(1,test_limit)
s=randint(1,test_limit)
t=randint(1,test_limit)
u=randint(1,test_limit)
v=randint(1,test_limit)
w=randint(1,test_limit)
x=randint(1,test_limit)
y=randint(1,test_limit)
z=randint(1,test_limit)

while (times!=0):

r2=((w*z)+h+j-q)**2
r3=((((g*k)+(2*g)+k+1)*(h+j))+h-z)**2
r4=((2*n)+p+q+z-e)**2
r5=((16*((k+1)**3)*(k+2)*((n+1)**2))+1-(f**2))**2
r6=(((e**3)*(e+2)*((a+1)**2))+1-(o**2))**2
r7=((((a**2)-1)*(y**2))+1-(x**2))**2
r8=((16*(r**2)*(y**4)*((a**2)-1))+1-(u**2))**2
r9=(((a+((u**2)*((u**2)-1)))**2)+1-((x+(c*u))**2))**2
r10=(n+l+v-y)**2
r11=((((a**2)-1)*(l**2))+1-(m**2))**2
r12=((a*i)+k+1-l-i)**2
r13=(p+(l*(a-n-1))+(b*((2*a*n)+(2*a)-(n**2)-(2*n)-2))-m)**2
r14=(q+(y*(a-p-1))+(s*((2*a*p)+(2*a)-(p**2)-(2*p)-2))-x)**2
r15=(z+(p*l*(a-p))+(t*((2*a*p)-(p**2)-1))-(p*m))**2
r1=(1-r2-r3-r4-r5-r6-r7-r8-r9-r10-r11-r12-r13-r14-r15)
res=(k+2)*r1
if res>0:
print(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
print(res)
times=times-1
a=randint(1,test_limit)
b=randint(1,test_limit)
c=randint(1,test_limit)
d=randint(1,test_limit)
e=randint(1,test_limit)
f=randint(1,test_limit)
g=randint(1,test_limit)
h=randint(1,test_limit)
i=randint(1,test_limit)
j=randint(1,test_limit)
k=randint(1,test_limit)
l=randint(1,test_limit)
m=randint(1,test_limit)
n=randint(1,test_limit)
o=randint(1,test_limit)
p=randint(1,test_limit)
q=randint(1,test_limit)
r=randint(1,test_limit)
s=randint(1,test_limit)
t=randint(1,test_limit)
u=randint(1,test_limit)
v=randint(1,test_limit)
w=randint(1,test_limit)
x=randint(1,test_limit)
y=randint(1,test_limit)
z=randint(1,test_limit)

dp()


According to the paper, when nonnegative integers are substituted for those variables, the positive values of the polynomial coincide exactly with the set of all prime numbers, and the polynomial also takes on negative values (those values are out of the target, so that point about the negative values is understood).

But I am not being able to obtain a single correct value, so I would like to ask the following questions:

1. Please if somebody could provide an online resource where some of these valid $(a,..,z)$ tuples are available (or some tested samples in the answer, tuple and obtained value) so I can check my code versus a correct tuple to find the possible error I would be very grateful.

2. I thought that any tuple $(a,..,z)$ with all $a,..,z$ nonnegative values provides a prime number if the value of the polynomial is positive, but I am getting with all nonnegative tuples positive values of the polynomial that are not primes. Did I misunderstand the explanation of the paper? Thank you!

• Look at the structure of the polynomial. It's $k+2$ times something which is $1$ minus a bunch of squares. If any of those squares is not $0$, the whole thing is useless. So we need to be able to find other $25$ numbers, given a $k$, that make each of the $25$ numbers you're squaring equal to $0$. It is highly highly unlikely you'd find them by brute force. – Bob Jones Feb 28 '17 at 0:36
• @BobJones thank you for the feedback. I see... I hope to find one or two examples online to see how they look like. – iadvd Feb 28 '17 at 1:32
• Today I found the following online resource, but it is also based on the calculation of random tuples ahonga.fr/js/primes/primesJones-5.html – iadvd Mar 1 '17 at 6:35

You get a positive value of $k+2$ if and only if all the squares in the second factor turn out to be $0$. If you just try random values for the variables, that will be extremely unlikely to be the case. You should follow the paper to see what values the different variables should have. This is essentially a clever encoding of Wilson's theorem, with $f = (k+1)!$.