# Here we create a list of Nagell fundamental solutions and output a list of # global Stolt fundamental solutions of x^2-dy^2=n, where 4 divides n and n is nonzero. # Also d > 0 and is nonsquare. # We return the number of Stolt fundamental solutions. # There are three possibilities: Let e1=x1+y1sqrt(d) be the least positive solution of # x^2 - dy^2 = 1 and e4 = (x4+y4sqrt(d))/2 be the least positive solution of # x^2 - dy^2 = 4. if e1=e4, then the Stolt and Nagell classes are identical. # if e1=e4^2, each Stolt class is composed of two Nagell classes, # if e1=e4^3, each Stolt class is composed of three Nagell classes. # function e1versuse4(d) tells us when these occur. # This method of finding the Stolt fundamental solutions is much quicker that the # function stolt0 in file stolt. # type bc stoltvialmm stoltarrange.bc squareroot patz genfacs define stoltvialmm(d,n,printflag){ auto h,s,gpsize,i,j,x[],y[] h=patzgen(d,n) # if h>0, this creates arrays # globalfundxff[0],...,globalfundxff[h-1] and # globalfundyff[0],...,globalfundyff[h-1]. if(h==0){ print "no solutions\n" return(0) } s=fund4(d,0) if(printflag){ print "globalx=",globalx,"\n" print "globaly=",globaly,"\n" } gpsize=e1versuse4(d) if(printflag){ print "gpsize=",gpsize,"\n" } if(gpsize==1){ if(printflag){ print "Stolt and Nagell classes are identical\n"; } for(j=0;jy[i+1]){ index[j]=i+1 } if(y[i]==y[i+1]){ if(x[i]<0){ index[j]=i+1 }else{ index[j]=i } } } if(gpsize==3){ if(y[i]y[i+2]){ index[j]=i+2 } } if(y[i+1]==y[i+2]){ if(y[i]y[i+1]){ if(x[i+1]>=0){ index[j]=i+1 }else{ index[j]=i+2 } } } if(y[i]==y[i+2]){ if(y[i+1]y[i]){ if(x[i]>=0){ index[j]=i }else{ index[j]=i+2 } } } } globalstoltvialmmx[j]=x[index[j]] globalstoltvialmmy[j]=y[index[j]] j=j+1 } h=h/gpsize if(printflag){ for(j=0;j0 and squarefree. # We reduce the equation to X^2 -dY^2=4an, where X=2ax+y and Y=y and then solve this equation # to get the Stolt fundamental solutions. define binaryviasfs(a,b,c,n,printflag){ auto d,fouran,alpha,beta,twoa,t,count,x,y,u,temp,temp1,temp2,g,h,absa,j if(a==0){ print "a=0\n" return(-1) } #if(b==0){ # print "b=0\n" # return(-1) #} if(n==0){ print "n=0\n" return(-1) } d=b^2-4*a*c if(d<=0){ print "d<=0\n" return(-1) } x=sqrt(d) if(x^2==d){ print "d is a perfect square\n" return(-1) } fouran=4*a*n twoa=2*a d=b^2-4*a*c g=stoltvialmm(d,fouran,printflag) if(printflag){ print g," is the number of Stolt fundamental classes of x^2 - ",d,"y^2=",fouran,"\n" } absa=abs(a) count=0 for(h=0;hx){ x=u } if(printflag){ print "interchanging u and x\n" } } } globalbinaryviastoltx[count]=x if(printflag){ print "Stolt fundamental solution[",count,"]=(",x,",",y,")\n" print "(",x,",",beta,")\n" print"\tx=(" temp=-(b*x+2*c*y) t=printauplusbv(x,temp) print")/2\n" print"\ty=(" temp=2*a*x+b*y t=printauplusbv(y,temp) print")/2\n" } count=count+1 } } if(printflag){ if(count){ print "Here u^2-",d,"v^2=4\n" } } if(printflag){ for(j=0;j