# We are dealing with the hyperbola equation ax^2+bxy+cy^2+dx+ey+f=0 (1). # We find the reduced equation AX^2+BXY+CY^2=K (2), where A=a/g,B=b/g,C=c/g, and where g=gcd(a,b,c). # Also with D=b^2-4ac, K=k/g, where k=-D(ae^2-bed+cd^2+fD). # The lemma states that if a solution (X0,Y0) of (2) corresponds to a solution (x,y) of (1), # then (X2,Y2)^t = U^2(X0,Y0)^2 also corresponds to a solution of (1), where # U=((t-bu)/2, -cu, au, (t+bu)/2) and (t,u) is the least positive solution of t^2-Du^2=4. # Similarly with U^2 replaced by U^(-2). # Consequently we need only examine all pm(X0,Y0)^t and pmU(X0,Y0)^t. define bigu(a,b,c,d,e,f,printflag){ auto alpha,beta,k,dd,x,y,u11,u12,u21,u22,phi,psi,s,t,g,h,t1,t2,t3,t4,solutionx1,solutiony1,solutionx2,solutiony2,solutionx3,solutiony3,solutionx4,solutiony4,gamma,epsilon,count,v11,v12,v21,v22,n dd=b^2-4*a*c temp=sqtest(dd) if(temp>=0){ print "discriminant is a square\n" return(-1) } if(d==0 && e==0){ n=-f t=binaryviasfs(a,b,c,n,1) return(t) } alpha=-b*e+2*c*d beta=-b*d+2*a*e print "alpha=",alpha,", beta=",beta,"\n" print dd,"x=X+(",alpha,")," print dd,"y=Y+(",beta,")\n" print "\n" k=-dd*(a*e^2-b*e*d+c*d^2+f*dd) # print "solving (",a,")X^2+(",b,")XY+(",c,")Y^2=",k,"\n" s=fund4(dd,0) phi=globalx psi=globaly print "(phi,psi)=(",phi,",",psi,")\n" u11=(phi-b*psi)/2 u12=-c*psi u21=a*psi u22=(phi+b*psi)/2 print "U=(",u11,",",u12,",",u21,",",u22,")\n" count=0 g=binaryviasfs(a,b,c,k,printflag) if(g==0){ print "There are no solutions\n" return(count) } for(h=0;h1){ print "There are ",count," families of solutions\n" } return(count) } define test(x,y,alpha,beta,dd){ auto xx,yy xx=x+alpha yy=y+beta if(xx%dd==0 && yy%dd==0){ #print "(",xx/dd,",",yy/dd,") is a solution\n" globalhyperbolasolutionx=xx/dd globalhyperbolasolutiony=yy/dd return(1) }else{ return(0) } } define sqtest(n){ auto g g=sqrt(n) if(g*g==n){ return(g) }else{ return(-1) } } define testarrayvalue(arrayvalue[],count,value){ flag=1 for(h=0;h