DeRhamComputation/sage/auxilliaries/hensel.sage

19 lines
648 B
Python
Raw Normal View History

2022-11-18 15:00:34 +01:00
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.<t> = LaurentSeriesRing(F, default_prec=prec)
RtQ = FractionField(Rt)
RptW.<W> = 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