Skip to content

Commit

Permalink
Trac #17724: Rename PowerSeries.reversion() in PowerSeries.reverse()
Browse files Browse the repository at this point in the history
The method `PowerSeries.reversion(self)` returns the reverse power
series of `self`. Following the apparent naming convention, I propose to
rename it `PowerSeries.reverse(self)`.

It is more consistent with other method such as (for `PowerSeries`):
`derivative()` (not `derivation`) or `truncate()` (not `truncation`).

URL: http://trac.sagemath.org/17724
Reported by: bruno
Ticket author(s): Bruno Grenet
Reviewer(s): Ralf Stephan
  • Loading branch information
Release Manager authored and vbraun committed Feb 17, 2015
2 parents 0ad1393 + 05bbf4a commit 7fc4cfa
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/sage/calculus/wester.py
Expand Up @@ -582,7 +582,7 @@
sage: f = sin(y) + cos(y)
sage: g = f.taylor(y, 0, 10)
sage: h = g.power_series(QQ)
sage: k = (h - 1).reversion()
sage: k = (h - 1).reverse()
sage: print k
y + 1/2*y^2 + 2/3*y^3 + y^4 + 17/10*y^5 + 37/12*y^6 + 41/7*y^7 + 23/2*y^8 + 1667/72*y^9 + 3803/80*y^10 + O(y^11)
Expand Down
Expand Up @@ -236,7 +236,7 @@ def J_inv_ZZ(self):
q = self._series_ring.gen()

# the current implementation of power series reversion is slow
# J_inv_ZZ = ZZ(1) / ((q*Phi.exp()).reversion())
# J_inv_ZZ = ZZ(1) / ((q*Phi.exp()).reverse())

temp_f = (q*Phi.exp()).polynomial()
new_f = temp_f.revert_series(temp_f.degree()+1)
Expand Down
43 changes: 23 additions & 20 deletions src/sage/rings/power_series_poly.pyx
Expand Up @@ -15,6 +15,7 @@ import arith
from sage.libs.all import PariError
from power_series_ring_element import is_PowerSeries
import rational_field
from sage.misc.superseded import deprecated_function_alias

cdef class PowerSeries_poly(PowerSeries):

Expand Down Expand Up @@ -906,14 +907,14 @@ cdef class PowerSeries_poly(PowerSeries):
return PowerSeries_poly(self._parent, self.__f.integral(var),
self.prec()+1, check=False)

def reversion(self, precision=None):
def reverse(self, precision=None):
"""
Return the reversion of f, i.e., the series g such that g(f(x)) =
x. Given an optional argument ``precision``, return the reversion
with given precision (note that the reversion can have precision at
most ``f.prec()``). If ``f`` has infinite precision, and the argument
``precision`` is not given, then the precision of the reversion
defaults to the default precision of ``f.parent()``.
Return the reverse of f, i.e., the series g such that g(f(x)) = x.
Given an optional argument ``precision``, return the reverse with given
precision (note that the reverse can have precision at most
``f.prec()``). If ``f`` has infinite precision, and the argument
``precision`` is not given, then the precision of the reverse defaults
to the default precision of ``f.parent()``.
Note that this is only possible if the valuation of self is exactly
1.
Expand All @@ -925,14 +926,14 @@ cdef class PowerSeries_poly(PowerSeries):
a message if passing to pari fails.
If the base ring has positive characteristic, then we attempt to
lift to a characteristic zero ring and perform the reversion there.
lift to a characteristic zero ring and perform the reverse there.
If this fails, an error is raised.
EXAMPLES::
sage: R.<x> = PowerSeriesRing(QQ)
sage: f = 2*x + 3*x^2 - x^4 + O(x^5)
sage: g = f.reversion()
sage: g = f.reverse()
sage: g
1/2*x - 3/8*x^2 + 9/16*x^3 - 131/128*x^4 + O(x^5)
sage: f(g)
Expand All @@ -942,7 +943,7 @@ cdef class PowerSeries_poly(PowerSeries):
sage: A.<t> = PowerSeriesRing(ZZ)
sage: a = t - t^2 - 2*t^4 + t^5 + O(t^6)
sage: b = a.reversion(); b
sage: b = a.reverse(); b
t + t^2 + 2*t^3 + 7*t^4 + 25*t^5 + O(t^6)
sage: a(b)
t + O(t^6)
Expand All @@ -952,7 +953,7 @@ cdef class PowerSeries_poly(PowerSeries):
sage: B.<b,c> = PolynomialRing(ZZ)
sage: A.<t> = PowerSeriesRing(B)
sage: f = t + b*t^2 + c*t^3 + O(t^4)
sage: g = f.reversion(); g
sage: g = f.reverse(); g
t - b*t^2 + (2*b^2 - c)*t^3 + O(t^4)
sage: f(g)
t + O(t^4)
Expand All @@ -963,7 +964,7 @@ cdef class PowerSeries_poly(PowerSeries):
sage: B.<s> = A[[]]
sage: f = (1 - 3*t + 4*t^3 + O(t^4))*s + (2 + t + t^2 + O(t^3))*s^2 + O(s^3)
sage: set_verbose(1)
sage: g = f.reversion(); g
sage: g = f.reverse(); g
verbose 1 (<module>) passing to pari failed; trying Lagrange inversion
(1 + 3*t + 9*t^2 + 23*t^3 + O(t^4))*s + (-2 - 19*t - 118*t^2 + O(t^3))*s^2 + O(s^3)
sage: set_verbose(0)
Expand All @@ -975,13 +976,13 @@ cdef class PowerSeries_poly(PowerSeries):
sage: A.<t> = PowerSeriesRing(ZZ)
sage: a = 2*t - 4*t^2 + t^4 - t^5 + O(t^6)
sage: a.reversion()
sage: a.reverse()
1/2*t + 1/2*t^2 + t^3 + 79/32*t^4 + 437/64*t^5 + O(t^6)
sage: B.<b> = PolynomialRing(ZZ)
sage: A.<t> = PowerSeriesRing(B)
sage: f = 2*b*t + b*t^2 + 3*b^2*t^3 + O(t^4)
sage: g = f.reversion(); g
sage: g = f.reverse(); g
1/(2*b)*t - 1/(8*b^2)*t^2 + ((-3*b + 1)/(16*b^3))*t^3 + O(t^4)
sage: f(g)
t + O(t^4)
Expand All @@ -992,7 +993,7 @@ cdef class PowerSeries_poly(PowerSeries):
sage: A8.<t> = PowerSeriesRing(Zmod(8))
sage: a = t - 15*t^2 - 2*t^4 + t^5 + O(t^6)
sage: b = a.reversion(); b
sage: b = a.reverse(); b
t + 7*t^2 + 2*t^3 + 5*t^4 + t^5 + O(t^6)
sage: a(b)
t + O(t^6)
Expand All @@ -1003,7 +1004,7 @@ cdef class PowerSeries_poly(PowerSeries):
sage: R.<x> = PowerSeriesRing(QQ)
sage: f = 2*x + 3*x^2 - 7*x^3 + x^4 + O(x^5)
sage: g = f.reversion(precision=3); g
sage: g = f.reverse(precision=3); g
1/2*x - 3/8*x^2 + O(x^3)
sage: f(g)
x + O(x^3)
Expand All @@ -1015,17 +1016,17 @@ cdef class PowerSeries_poly(PowerSeries):
ring::
sage: R.<x> = PowerSeriesRing(QQ, default_prec=20)
sage: (x - x^2).reversion() # get some Catalan numbers
sage: (x - x^2).reverse() # get some Catalan numbers
x + x^2 + 2*x^3 + 5*x^4 + 14*x^5 + 42*x^6 + 132*x^7 + 429*x^8 + 1430*x^9 + 4862*x^10 + 16796*x^11 + 58786*x^12 + 208012*x^13 + 742900*x^14 + 2674440*x^15 + 9694845*x^16 + 35357670*x^17 + 129644790*x^18 + 477638700*x^19 + O(x^20)
sage: (x - x^2).reversion(precision=3)
sage: (x - x^2).reverse(precision=3)
x + x^2 + O(x^3)
TESTS::
sage: R.<x> = PowerSeriesRing(QQ)
sage: f = 1 + 2*x + 3*x^2 - x^4 + O(x^5)
sage: f.reversion()
sage: f.reverse()
Traceback (most recent call last):
...
ValueError: Series must have valuation one for reversion.
Expand Down Expand Up @@ -1076,7 +1077,7 @@ cdef class PowerSeries_poly(PowerSeries):
verbose("characteristic zero base is "+str(base_lift))
f_lift = f.change_ring(base_lift)
verbose("f_lift is "+str(f_lift))
rev_lift = f_lift.reversion()
rev_lift = f_lift.reverse()
return rev_lift.change_ring(f.base_ring())

t = f.parent().gen()
Expand All @@ -1091,6 +1092,8 @@ cdef class PowerSeries_poly(PowerSeries):
g = g.add_bigoh(out_prec)
return PowerSeries_poly(out_parent, g, out_prec, check=False)

reversion = deprecated_function_alias(17724, reverse)

def pade(self, m, n):
r"""
Returns the Padé approximant of ``self`` of index `(m, n)`.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/ell_tate_curve.py
Expand Up @@ -191,7 +191,7 @@ def parameter(self,prec=20):
Delta = CuspForms(weight=12).basis()[0]
j = (E4.q_expansion(prec+3))**3/Delta.q_expansion(prec+3)
jinv = (1/j).power_series()
q_in_terms_of_jinv = jinv.reversion()
q_in_terms_of_jinv = jinv.reverse()
R = Qp(self._p,prec=prec)
qE = q_in_terms_of_jinv(R(1/self._E.j_invariant()))
self._q = qE
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/formal_group.py
Expand Up @@ -732,7 +732,7 @@ def sigma(self, prec=10):
k = self.curve().base_ring()
fl = self.log(prec)
R = rings.PolynomialRing(k,'c'); c = R.gen()
F = fl.reversion()
F = fl.reverse()

S = rings.LaurentSeriesRing(R,'z')
c = S(c)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/padic_lseries.py
Expand Up @@ -1486,7 +1486,7 @@ def bernardi_sigma_function(self, prec=20):

Eh = E.formal()
lo = Eh.log(prec + 5)
F = lo.reversion()
F = lo.reverse()

S = LaurentSeriesRing(QQ,'z')
z = S.gen()
Expand Down

0 comments on commit 7fc4cfa

Please sign in to comment.