#This program constructs a point count table from one or several equations #The point count is AFFINE and uses a NAIVE algorithm #Currently the algorithm accepts as many equations as you like, but only in ONE or TWO variables #In order to use the algorithm, you must specify 4 pieces of information, marked as TODO 1, 2, 3, 4. import numpy #TODO 1: Set the number of variables (i.e. the dimension of the ambient affine space) #Currently only 1 or 2 variables are supported. V = 2 #TODO 2: Define functions. Use * for multiplication. #You may keep many functions here, just specify in the next step which ones should be used. #(The algorithm will count the common zeroes of these functions.) def f1(x,y): return y^2-x^3+27*x-46 def f2(x,y): return x^2+3*y^2 def f3(x): return x^5-1 def f4(x): return x*(x+2) #TODO 3: Create a list of the functions you actually want to use. These must take the right number of variables as input. my_list_of_functions = [f1,f2] #TODO 4: Set number of rows in table: R = 3 #TODO 5: Set number of columns in table: C = 4 #We define a function, capable of producing a point count matrix def affine_point_count(number_of_rows, number_of_columns, number_of_variables, function_list): #Constructing a list L containing the required primes L = primes_first_n(number_of_rows) #Initiating a point count matrix with all entries equal to -1 point_count_matrix = (-1)*numpy.ones((number_of_rows,number_of_columns), int) #Iterating over primes in L and then over exponents from 1 to C, searching for solutions by checking all possible values in the corresponding finite field row_index = 0 for p in L: for k in range(C): #The number k goes from 0 to C-1, inclusive e=k+1; #The number e goes from 1 to C, inclusive q=p^e; R.<a> = GF(q); m=0 if V == 1: for i, x in enumerate(R): b = True for f in function_list: if f(x) != 0: b = False; break if b == True: m = m+1; elif V == 2: for i,x in enumerate(R): for j, y in enumerate(R): b = True for f in function_list: if f(x,y) != 0: b = False; break if b == True: m = m+1; elif V > 2: print 'To many variables! The algorithm does not work!' point_count_matrix[row_index,k] = m; row_index = row_index+1 return point_count_matrix #Here we execute the function to actually produce the desired matrix pcm = affine_point_count(R, C, V, my_list_of_functions) print pcm
[[1 3 1 3]
[2 2 2 2]
[0 6 0 6]]