commit 66116fa13d363efb88ee4ded81ce62362721f221 Author: Hanno Date: Tue Dec 26 17:59:43 2023 +0100 Lennart Nullstellen Skript diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..080a76c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.sobj +*.sage.py diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..499d43c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# Verwende das SageMath-Image als Basis +FROM sagemath/sagemath:latest + +# Setze das Arbeitsverzeichnis im Container +WORKDIR /usr/src/app +RUN chmod -R 777 /usr/src/app + +# Kopiere den gesamten Inhalt in das Arbeitsverzeichnis +COPY . . + +# Führe das Sage-Skript aus +CMD ["sage nullstellen.sage"] diff --git a/bak-nullstellen.sage b/bak-nullstellen.sage new file mode 100755 index 0000000..8587d3f --- /dev/null +++ b/bak-nullstellen.sage @@ -0,0 +1,37 @@ +import os + +def coeffGenerator(deg=1): + if deg==1: + return[[1]] + else: + l=[] + p=coeffGenerator(deg-1) + for i in p: + a=i+[1] + b=i+[-1] + l.append(a) + l.append(b) + return l + +def polyGenerator(deg=1): + var('x') + l=[] + for p in coeffGenerator(deg): + l.append(sum([b*x^a for (a,b) in enumerate(p)])) + return l + +def numericalSolutionsWithSaves(deg=1,batch_sz=10000): + path="polynomials"+str(deg) + if os.path.isfile(path+".sobj") is False: + polynomials=polyGenerator(deg) + save(polynomials,path) + polynomials=load(path) + while len(polynomials)!=0: + solutions=[] + for p in polynomials[:batch_sz]: + solutions.append([s[x].n(20) for s in solve(p,var('x'),solution_dict=True,to_polysolve=True)]) + save(solutions,"deg"+str(deg)+""+str(floor(len(polynomials)/batch_sz))) + polynomials=polynomials[batch_sz:] + save(polynomials,path) + +numericalSolutionsWithSaves(22,50000) diff --git a/commands.txt b/commands.txt new file mode 100644 index 0000000..5440f3e --- /dev/null +++ b/commands.txt @@ -0,0 +1,5 @@ +# BUILD +sudo docker build ./ -t sage-container + +# RUN +sudo docker run -v "$(pwd):/usr/src/app" -t -d sage-container diff --git a/nullstellen.sage b/nullstellen.sage new file mode 100755 index 0000000..6c2a1a4 --- /dev/null +++ b/nullstellen.sage @@ -0,0 +1,37 @@ +import os + +def coeffGenerator(deg=1): + if deg==1: + return[[1]] + else: + l=[] + p=coeffGenerator(deg-1) + for i in p: + a=i+[1] + b=i+[-1] + l.append(a) + l.append(b) + return l + +def polyGenerator(deg=1): + var('x') + l=[] + for p in coeffGenerator(deg): + l.append(sum([b*x^a for (a,b) in enumerate(p)])) + return l + +def numericalSolutionsWithSaves(deg=1,batch_sz=10000): + path="polynomials"+str(deg) + if os.path.isfile(path+".sobj") is False: + polynomials=polyGenerator(deg) + save(polynomials,path) + polynomials=load(path) + while len(polynomials)!=0: + solutions=[] + for p in polynomials[:batch_sz]: + solutions.append([s[x].n(20) for s in solve(p, var('x'), solution_dict=True, to_polysolve=True) if x in s]) + save(solutions,"deg"+str(deg)+""+str(floor(len(polynomials)/batch_sz))) + polynomials=polynomials[batch_sz:] + save(polynomials,path) + +numericalSolutionsWithSaves(22,50000)