def triangulation(S):
T=[]
while S!=[]:
m=max([s.lm() for s in S])
L = [s for s in S if s.lm() == m]
S = [s for s in S if s.lm() < m]
f=L[0]
T.append(f)
for g in L[1:]:
g=f.lc()*g-g.lc()*f
if g!=0:
S.append(g)
D=[s for s in S if s.degree()==0]
if D!=[]:
return D
return T
def tsolve(T):
T.reverse()
D={}
while T!=[]:
g=T[0]
D[g.lm()] = -(g-g.lt())/g.lc()
T=[t.subs(D) for t in T[1:]]
return D
def quo_rem_poly(f,q):
K=f.parent()
n=0
while f.degree()>=q.degree():
ni=K(f.lt()/q.lt())
n=n+ni
f=f-ni*q
return (n,f)
def prime_list(P):
N=[n for n in range(2,P)]
for i in range(2,floor(sqrt(P))+1):
N=[n for n in N if n % i !=0 or n==i]
return N