1 | initial version |
def as_ogf(f, prec):
pari.set_series_precision(prec)
C = pari("Vec(serlaplace(" + repr(f(x)) + "))")
S.<z> = PowerSeriesRing(ZZ)
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.
2 | No.2 Revision |
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:
Unfortunately this does not work.
f(x) = (3*x + 8)*sinh(2*x)/4; as_ogf(f, 4)
returns 4 + 3z + 16z^2 + 24z^3 istead of the correct 4z + 3z^2 + 16z^3 + 24*z^4. Pari seems to swallow the constant coefficient if it is '0'? How can this be corrected?
3 | No.3 Revision |
def as_ogf(f, prec): pari.set_series_precision(prec) C = pari("Vec(serlaplace(" + repr(f(x)) + "))") S.<z> = PowerSeriesRing(ZZ) 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:
EDIT: Unfortunately this does not work.
f(x) = (3*x + 8)*sinh(2*x)/4; as_ogf(f, 4)
returns 4 + 3z + 16z^2 + 24z^3 istead of the correct 4z + 3z^2 + 16z^3 + 24*z^4. Pari seems to swallow the constant coefficient if it is '0'? How can this be corrected?
4 | No.4 Revision |
def as_ogf(f, prec): pari.set_series_precision(prec) C = pari("Vec(serlaplace(" + repr(f(x)) + "))") S.<z> = PowerSeriesRing(ZZ) 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: Unfortunately this does not work.
f(x) = (3*x + 8)*sinh(2*x)/4; as_ogf(f, 4)
returns 4 + 3z + 16z^2 + 24z^3 istead of the correct 4z + 3z^2 + 16z^3 + 24*z^4. Pari seems to swallow the constant coefficient if it is '0'? How can this be corrected?
5 | No.5 Revision |
Here a potential solution:
def as_ogf(f, prec):
pari.set_series_precision(prec)
C = pari("Vec(serlaplace(" + repr(f(x)) + "))")
S.<z> = PowerSeriesRing(ZZ)
return S(C)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: Unfortunately this does not work.
f(x) = (3*x + 8)*sinh(2*x)/4; as_ogf(f, 4)
returns 4 + 3z + 16z^2 + 24z^3 istead of the correct 4z + 3z^2 + 16z^3 + 24*z^4. Pari seems to swallow the constant coefficient if it is '0'? How can this be corrected?
6 | No.6 Revision |
Here a potential solution:
def as_ogf(f, prec):
S.<z> = PowerSeriesRing(ZZ)
pari.set_series_precision(prec)
C = pari("Vec(serlaplace(" pari("serlaplace(" + repr(f(x)) str(f(x)) + "))")
S.<z> = PowerSeriesRing(ZZ)
")")
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: Unfortunately After an edit this does not work. now works also with
f(x) = (3*x + 8)*sinh(2*x)/4; as_ogf(f, 4)
and returns 4 + 34z + 163z^2 + 2416z^3 istead of the correct 4+ 24z z^4 + 3z^2 + 16z^3 + 24*z^4. Pari seems to swallow the constant coefficient if it is '0'? How can this be corrected?O(z^5), as desired.