19 lines
553 B
Python
19 lines
553 B
Python
# Given power_series, find its reverse (g with g \circ power_series = id) with given precision
|
|
|
|
def new_reverse(power_series, prec = 10):
|
|
F = power_series.parent().base()
|
|
Rt.<t> = LaurentSeriesRing(F, default_prec=prec)
|
|
RtQ = FractionField(Rt)
|
|
power_series = RtQ(power_series)
|
|
a = power_series.list()[0]
|
|
g = 1/a*t
|
|
n = 2
|
|
while(n <= prec):
|
|
aux = power_series(t = g) - t
|
|
if aux.valuation() > n:
|
|
b = 0
|
|
else:
|
|
b = aux.list()[0]
|
|
g = g - b/a*t^n
|
|
n += 1
|
|
return g |