def recordxmin5primelistextend(PL,startp,m): pr = startp # Set the beginning prime value k = len(PL) # Compute the number of items in the given list print("Number of initial data points is", k) # Announce the current number of data points R = PL[k-1][1] # Find the current record x-value in the list PL p = PL[k-1][0] # Find the current record prime in the list PL NEW = 0 # Set the number of new data points at 0 NList = [] # Initiate an empty list for the new data for i in range(m+1): # Start running through the next m prime numbers pr = next_prime(pr) # Increase the prime number from the current value K.<sqrtpr> = QuadraticField(pr) # Call on the mathematical technology needed cf = continued_fraction(sqrtpr); # Find the continued fraction of sqrt of prime kk = cf.period() # Find the period of the continued fraction mm = len(kk)+1 # Find the length mm of the period for i in range(2*mm+1): # Search solution among first 2mm+1 convergents ppr = cf.convergent(i).numerator() # x-value of convergent i qqr = cf.convergent(i).denominator() # y-value of the convergent i if (ppr^2 - pr*qqr^2 == -5): # If x^2 - p y^2 = -5, x is a candidate if (ppr>R): # If this x exceeds the current record value, NList = NList + [(pr,ppr)] # extend the new data list by a new term (p,x) R = ppr # Update the record value of x NEW = NEW+1 # Increase the new data count by 1 break else: # If the x is not a record, break # End the search for this prime number print("Number of new data points",NEW) # When all is done, say how many new data points print("Start Prime", pr) return(pr,NList) def recordymin5primelistextend(PL,startp,m): pr = startp # Set the beginning prime value k = len(PL) # Compute the number of items in the given list print("Number of initial data points is", k) # Announce the current number of data points R = PL[k-1][1] # Find the current record y-value in the list PL p = PL[k-1][0] # Find the current record prime in the list PL NEW = 0 # Set the number of new data points at 0 NList = [] # Initiate an empty list for the new data for i in range(m+1): # Start running through the next m prime numbers pr = next_prime(pr) # Increase the prime number from the current value K.<sqrtpr> = QuadraticField(pr) # Call on the mathematical technology needed cf = continued_fraction(sqrtpr); # Find the continued fraction of sqrt of prime kk = cf.period() # Find the period of the continued fraction mm = len(kk)+1 # Find the length mm of the period for i in range(2*mm+1): # Search solution among first 2mm+1 convergents ppr = cf.convergent(i).numerator() # x-value of convergent i qqr = cf.convergent(i).denominator() # y-value of the convergent i if (ppr^2 - pr*qqr^2 == -5): # If x^2 - p y^2 = -5, y is a candidate if (qqr>R): # If this y exceeds the current record value, NList = NList + [(pr,qqr)] # extend the new data list by a new term (p,y) R = qqr # Update the record value of y NEW = NEW+1 # Increase the new data count by 1 break else: # If the y is not a record, break # End the search for this prime number print("Number of new data points",NEW) # When all is done, say how many new data points print("Start Prime", pr) return(pr, NList) #def extractprimelist(Lst): # k = len(Lst) # Compute the number of items in the given list # NEW = 0 # Set the number of new data points at 0 # PList = [] # Initiate an empty list for the new data # for i in range(k): # PList = PList + [Lst[i][0]] # return(PList) def extractprimelist(Lst): k = len(Lst) # Set the number of new data points at 0 PList = [] # Initiate an empty list for the new data for i in range(k): PList = PList + [Lst[i][0]] return(PList) def extractxylist(Lst): k = len(Lst) # Set the number of new data points at 0 PList = [] # Initiate an empty list for the new data for i in range(k): PList = PList + [Lst[i][1]] return(PList)