Sei sulla pagina 1di 2

#

#
#
#
#

Version 1.0
2015-07-09
Author: Catherine Hsu
This code requires PARI to be in the same folder as codeforbiquadratic.py.

#*****************************************************************************
#
Copyright (C) 2015 Catherine Hsu <cathyh@uoregon.edu>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
#
This code is distributed in the hope that it will be useful,
#
but WITHOUT ANY WARRANTY; without even the implied warranty of
#
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#
General Public License for more details.
#
# The full text of the GPL is available at:
#
#
http://www.gnu.org/licenses/
#*****************************************************************************
from subprocess import PIPE, Popen

def prime_factors(n):
i = 2
factors = []
while i * i <= n:
if n % i:
i += 1
else:
n //= i
factors.append(i)
if n > 1:
factors.append(n)
return factors
def is_prime(x):
if x<2:
return False
elif x == 2:
return True
else:
for n in range(2, x):
if x%n==0:
return False
return True
def do_pari(command):
proc = Popen(['gp.exe'],stdin=PIPE,stdout=PIPE)
pcomm = bytes(command,'UTF-8')
proc.stdin.write(pcomm)
out = str(proc.communicate()[0])
out=out[675:]
out = out[:-17]
proc.terminate()
return out

def find_prime(polK,polH, q, k, r):


for x in range (2,100):
if is_prime(x) and 1 != x% q and 1 != x% k and 1 != x% r and x !=q and x
!=k and x!=r and x!=2:
resdegK = do_pari('idealprimedec(nfinit('+polK+'),'+str(x)+')[1].f')
resdegH = do_pari('idealprimedec(nfinit('+polH+'),'+str(x)+')[1].f')
if int(resdegK)==1 and int(resdegH)==2:
if 1 != x%4:
return(x,x,resdegK,resdegH)
else:
return(x,x+2*q*k*r,resdegK,resdegH)
f = open('examplesbiquadratic.tex','w')
f.write("\\documentclass[oneside]{amsart}\\usepackage{amsmath,longtable,tabu}\\b
egin{document}\\begin{flushleft}\\textit{Examples of Biquadratic Number Fields w
ith a Non-Principal Euclidean Ideal}\\end{flushleft}\\begin{longtabu}{cccc}")
for x in range(29,50,4):
for y in range(29,100,4):
for z in range(y,100,4):
if is_prime(x) and is_prime(y) and is_prime(z) and x!=y and x!=z and
y!=z:
polK= 'x^4-'+str(2*x+2*y*z)+'*x^2+'+str(x*x+y*y*z*z-2*x*y*z)
poltexK= 'x^4-'+str(2*x+2*y*z)+'x^2+'+str(x*x+y*y*z*z-2*x*y*z)
hk=do_pari('bnfinit('+polK+').clgp.no')
if int(hk)==2:
S1=x+y+z
S2=x*y+x*z+y*z
S3 = x*y*z
polH='x^8-'+str(4*S1)+'*x^6+'+str(6*S1*S1-8*S2)+'*x^4-'+str(
4*S1*S1*S1-16*S1*S2+64*S3)+'*x^2+'+str(S1*S1*S1*S1-8*S1*S1*S2+16*S2*S2)
poltexH='y^8-'+str(4*S1)+'y^6+'+str(6*S1*S1-8*S2)+'y^4-'+str
(4*S1*S1*S1-16*S1*S2+64*S3)+'y^2+'+str(S1*S1*S1*S1-8*S1*S1*S2+16*S2*S2)
resdegrees =find_prime(polK,polH,x,y,z)
f.write("$("+str(x)+", " +str(y)+", "+str(z)+")$&$"+hk+"$&$"
+poltexH+"$&$("+str(resdegrees[0])+","+str(resdegrees[1])+")$\\\\")
f.write("&&$"+poltexK+"$&\\\\")
else:
f.write("$("+str(x)+", " +str(y)+", "+str(z)+")$&$"+hk+"$& &
\\\\")
f.write("\\end{longtabu}\\end{document}")
f.close()
Popen(['examplesbiquadratic.tex'],shell=True)

Potrebbero piacerti anche