Guest User

Untitled

a guest
Aug 5th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. """
  2. This is an implementation of the algorithm described in
  3. Lehobey's
  4. "Resolvent Computations by Resultants Without Extraneous Powers"
  5. """
  6.  
  7.  
  8. def interpolating_functions(f):
  9. """
  10. Build a list of interpolating functions for f
  11.  
  12. We require f : K[x1,...,xn][x]
  13. """
  14. R = f.parent().base_ring()
  15. xs = R.gens()
  16.  
  17. n = f.degree()
  18.  
  19. out = [f]
  20. for k in range(f.degree()):
  21. fk = (out[-1] - out[-1].subs(x=xs[n-k-1]))/(x - xs[n-k-1])
  22. out += [f.parent()(fk.simplify_full())]
  23.  
  24. return out[::-1]
  25.  
  26.  
  27. def stabilizer(G,p):
  28. """
  29. Compute the stabilizer of p by G
  30. """
  31. elems = []
  32. for g in G:
  33. if p * g == p:
  34. elems += [g]
  35. return G.subgroup(elems)
  36.  
  37.  
  38.  
  39. def truncated_root(p,r,d):
  40. """
  41. Compute q so that q^r = p (working mod x^d)
  42.  
  43. Assumes p : A[t] has constant term 1
  44. and that such a q : A[t] actually exists!
  45. """
  46.  
  47. r = int(r)
  48.  
  49. t = p.variables()[0]
  50.  
  51. n = p.degree()
  52. # print("n: ", n)
  53.  
  54. p = p.truncate(d)
  55.  
  56. # print("truncating root -- ")
  57. # print("p: ", p)
  58. # print("r: ", r)
  59. # print("d: ", d)
  60.  
  61. ps = p.coefficients(sparse=False)
  62.  
  63. # these will be the coefficients of q
  64. qs = [1]
  65.  
  66. for k in range(n // r):
  67. qs += [1/(k+1) * sum([(k+1 - (r+1)*j) * qs[j] * ps[k+1-j] / r for j in range(k+1)])]
  68.  
  69. return sum([qs[j] * t^j for j in range(len(qs))])
  70.  
  71.  
  72.  
  73. def resolvent(f,Theta):
  74. """
  75. Compute mathcal{L}_{Theta,f} as per the paper
  76.  
  77. Assumes f : K[x1,...,xn][x] and Theta : K[x1,...,xn]
  78. """
  79. R = Theta.parent()
  80. K = R.base_ring()
  81. xs = R.gens()
  82.  
  83. SIterated.<t> = PolynomialRing(R)
  84. S = SIterated.flattening_morphism().codomain()
  85.  
  86. T = K[t]
  87.  
  88. Rj = (t - SIterated(Theta)).reverse()
  89. Rj = S(Rj)
  90.  
  91. fs = interpolating_functions(f)
  92.  
  93. HprevOrder = 1
  94.  
  95. n = f.degree()
  96.  
  97. for j in range(1,n+1):
  98. print("j: ", j)
  99. Sj = SymmetricGroup(j)
  100. Hj = stabilizer(Sj,Theta)
  101. dj = factorial(j) / Hj.order()
  102. mj = Hj.order() / HprevOrder
  103.  
  104. # print("Sj: ", Sj)
  105. # print("Hj: ", Hj)
  106. # print("dj: ", dj)
  107. # print("mj: ", mj)
  108.  
  109. # update the previous order for the next cycle
  110. HprevOrder = Hj.order()
  111.  
  112. # there's an annoying off-by-one error with the variable names
  113. # compared to everything else
  114. fj = S(fs[j].subs(x=xs[j-1]))
  115.  
  116. # print("fj: ", fj)
  117.  
  118. res = fj.resultant(Rj, S(xs[j-1]))
  119.  
  120. # print("res: ", res)
  121.  
  122. Rj = truncated_root(SIterated(res),mj,dj+1)
  123. # print("Rj: ", Rj)
  124.  
  125. Rj = S(Rj)
  126.  
  127. # print("-----")
  128.  
  129. # print("about to return: ")
  130. # print(Rj)
  131. return T(Rj).reverse()
  132.  
  133.  
  134. def solveByRadicals(f):
  135. """
  136. Compute a root of f using radicals
  137. """
  138.  
  139. n = int(f.degree(x))
  140. K.<w> = CyclotomicField(n)
  141.  
  142. R = PolynomialRing(K,n,'x')
  143. xs = R.gens()
  144.  
  145. R1 = R[x]
  146. f = R1(f)
  147.  
  148. Theta = sum(xs[k] * w^(k) for k in range(n))
  149. print("Theta: ", Theta)
  150.  
  151. # Theta^5 is preserved under the action of the galois group,
  152. # while Theta itself is an eigenvector with eigenvalue w
  153. L = resolvent(f,Theta^n)
  154.  
  155. print("L: ", L)
  156.  
  157. psis = [-list(f)[-2]] + L.roots(multiplicities=False)
  158.  
  159. print("psis: ")
  160. print([psi.n() for psi in psis])
  161.  
  162. thetas = [psi^(1/n) for psi in psis]
  163.  
  164. r = sum(thetas) / n
  165.  
  166. print("purported root r: ", r)
  167. print("f(r): ", f(r).n())
  168.  
  169.  
  170. R = QQ[x]
  171.  
  172.  
  173. # f = x^3 + x^2 - 2*x - 1
  174. # f = x^5 + x^4 -4*x^3 - 3*x^2 + 3*x + 1
  175.  
  176. # this works for degree 3 polynomials
  177. # fs = [x^3 - x^2 - a*x + b for (a,b) in [(26,-41), (32,79), (34,61), (36,4), (42,-80), (46,-103)]]
  178.  
  179. # what about degree 5?
  180. fs = [x^5 + x^4 - 4*x^3 - 3*x^2 + 3*x + 1, # this one doesn't
  181. x^5 + x^4 - 12*x^3 - 21*x^2 + 1*x + 5, # this one works
  182. x^5 + x^4 - 16*x^3 + 5*x^2 + 21*x - 9, # this one doesn't work
  183. x^5 + x^4 - 24*x^3 - 17*x^2 + 41*x - 13]
  184.  
  185.  
  186. for f in fs:
  187. print("f: ", f)
  188. print("Gf: ", R(f).galois_group().structure_description())
  189. solveByRadicals(f)
  190. print("--------------")
  191.  
Advertisement
Add Comment
Please, Sign In to add comment