Ask Your Question
1

An analog to Pari's serlaplace

asked 2019-10-20 04:21:38 -0600

Peter Luschny gravatar image

updated 2019-10-20 06:04:18 -0600

With PARI I can do this:

f(x) = ((3*x + 8)*sinh(2*x) + (2*x^2 + 16*(x + 1))*cosh(2*x))/16;
serlaplace(f('x + O('x^5)))

PARI returns 1 + 2x + 5x^2 + 16x^3 + 28x^4 + O(x^5).

How to achieve this with Sage? Note that I want the returned value to live in the 'Power Series Ring' over the 'Integer Ring'.

def serlaplace(f, prec):
    t = taylor(f, x, 0, prec)
    C = [c[0] for c in t.coefficients()]
    R.<u> = PowerSeriesRing(QQ)
    S.<z> = PowerSeriesRing(ZZ)
    return S(R(C).egf_to_ogf())

f(x) = ((3*x + 8)*sinh(2*x) + (2*x^2 + 16*(x + 1))*cosh(2*x))/16    
serlaplace(f, 4) returns 1 + 2*z + 5*z^2 + 16*z^3 + 28*z^4.

The question is: Is there a more direct, more efficient way to achieve this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-10-20 06:50:10 -0600

Peter Luschny gravatar image

updated 2019-10-20 12:36:05 -0600

Here a potential solution:

def as_ogf(f, prec):
    S.<z> = PowerSeriesRing(ZZ)
    pari.set_series_precision(prec)
    C = pari("serlaplace(" + str(f(x)) + ")")
    return S(C)

f(x) = ((3*x + 8)*sinh(2*x) + (2*x^2 + 16*(x + 1))*cosh(2*x))/16    
as_ogf(f, 4) returns 1 + 2*z + 5*z^2 + 16*z^3 + 28*z^4 and is of the required type.

It seems to me it would be worthwhile to include such a function in Sage.

EDIT: After an edit this now works also with

f(x) = (3*x + 8)*sinh(2*x)/4; as_ogf(f, 4)

and returns 4z + 3z^2 + 16z^3 + 24z^4 + O(z^5), as desired.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-10-20 04:21:38 -0600

Seen: 45 times

Last updated: Oct 20 '19

Related questions