def naive_hensel(fct, F, start = 1, prec=10): '''given field F and polynomial fct over F((t)), find root of this polynomial in F((t)), using Hensel method with first value equal to start.''' Rt. = LaurentSeriesRing(F, default_prec=prec) RtQ = FractionField(Rt) RptW. = PolynomialRing(RtQ) RptWQ = FractionField(RptW) fct = RptWQ(fct) fct = RptW(numerator(fct)) #return(fct) #while fct not in RptW: # print(fct) # fct *= W alpha = (fct.derivative())(W = start) w0 = Rt(start) i = 1 while(i < prec): w0 = w0 - fct(W = w0)/alpha + O(t^(prec)) i += 1 return w0 def nth_root2(fct, n, prec=10): '''Given power series in F((t)), find its n-th root up to precision prec.''' F= parent(fct).base_ring() Rt. = LaurentSeriesRing(F, default_prec=prec) RW. = PolynomialRing(Rt) v = fct.valuation() fct1 = Rt(fct*t^(-v)) a0 = fct1[0] if v%n != 0: raise ValueError('The valuation of the power series is not divisible by n.') return t^(v//n)*naive_hensel(W^n - fct1, F, start = a0.nth_root(n), prec=prec)