# How to compute the multiplicative inverse of a series?

After a formula of Sergei N. Gladkovskii the logarithm of the generating function for the Pell numbers is the multiplicative inverse of sqrt(2) coth(sqrt(2) x)-1 seen as an exponential generating function.

In the words of Maple:

seq(k!*coeff(series(1/(sqrt(2)*coth(sqrt(2)*x)-1),x=0,k+2),x,k),k=0..9);
0, 1, 2, 2, -8, -56, -112, 848, 9088, 25216


How can I do this with Sage?

If I want a compositional inverse this is what I do:

SR -> taylor -> PowerSeriesRing(SR) -> reversion() -> egf_to_ogf() -> padded_list()

If I want a multiplicative inverse this is what I want to do:

SR -> taylor -> PowerSeriesRing(SR) -> inversion() -> egf_to_ogf() -> padded_list()

Isn't this what one expects naturally? But I cannot find an 'inversion'.

Solution d'après kcrisman

x = SR.var('x')
gf = (sqrt(2)*coth(sqrt(2)*x)-1)^-1

edit retag close merge delete

Following a hint of kcrisman I found in the code the function "__invert__(self)". This is exactly what I have been looking for. To support functional notation and to make terminology more uniform and predictable it would be nice to have an function-alias inversion() for this function.

( 2014-11-20 14:53:38 +0200 )edit

This is now trac #17403

( 2014-11-26 15:12:04 +0200 )edit

Sort by » oldest newest most voted

I don't know if Maxima can do it far more directly. I also have ignored the part of your question about the factorials. But I think this should get your started with something.

sage: A(x) = 1/(sqrt(2)*coth(sqrt(2)*x)-1)
sage: B(x) = taylor(A,x,0,10)
sage: B
x |--> -1213/14175*x^10 + 197/2835*x^9 + 71/315*x^8 + 53/315*x^7 - 7/45*x^6 - 7/15*x^5 - 1/3*x^4 + 1/3*x^3 + x^2 + x
sage: C = B^-1
sage: D(x) = taylor(C,x,0,10)
sage: expand(D*B)
x |--> -1374329/86113125*x^20 + 13378492/602791875*x^19 + 4163876/120558375*x^18 + 492028/66976875*x^17 - 634988/13395375*x^16 - 970628/13395375*x^15 - 150044/13395375*x^14 + 163852/1488375*x^13 + 664336/4465125*x^12 + 1  # okay as nothing below x^11
sage: D.coeffs()
[[1, -1],
[-1, 0],
[2/3, 1],
[-4/45, 3],
[16/945, 5],
[-16/4725, 7],
[-4589/42525, 9],
[1133/6075, 10]]


sage: A.series(x,2)
x |--> (1/(sqrt(2)*coth(0) - 1)) + (2*csch(0)^2/(sqrt(2)*coth(0) - 1)^2)*x + Order(x^2)
sage: taylor(A,x,0,2)
x |--> x^2 + x


It would be nice if Taylor also returned something with the + Order(x^2) business.

Edit now that I see what your workflow is:

sage: A = taylor(e^x,x,0,5).power_series(QQ)
sage: A
1 + x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 + 1/120*x^5 + O(x^6)
sage: A^-1
1 - x + 1/2*x^2 - 1/6*x^3 + 1/24*x^4 - 1/120*x^5 + O(x^6)
sage: A*A^-1
1 + O(x^6)


Hope this is what you were looking for.

If you want to know more, do

sage: A.__invert__??


which is the special thing that makes -1 powers work properly, I believe.

more