Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

An analog to Pari's serlaplace

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 can 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, 20) 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?

An analog to Pari's serlaplace

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 can 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, 20) 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?

An analog to Pari's serlaplace

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 can 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?