Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Expanding a bivariate exponential generating function

Expanding an univariate exponential generating function can be done like this:

def egfExpand1(f, size):
    x = var('x')
    return taylor(f(x), x, 0, size).power_series(SR).egf_to_ogf().list()

For example egfExpand1(sec, 10) returns [1, 0, 1, 0, 5, 0, 61, 0, 1385, 0, 50521].

But how can I expand a bivariate exponential generating function? Say

def f(x, y): return exp(x * y) * sec(x)

def egfExpand2(f, size):
    return ...

The expected output is an integer triangle (i.e. a list of integer lists).

The example would return an unsigned version of A119879, which starts:

                           1
                          0, 1
                        1, 0, 1
                       0, 3, 0, 1
                     5, 0, 6, 0, 1

In Maple this can be done with:

egf := exp(x * y) * sec(x): ser := series(egf, x, 11):
poly := n -> n! * coeff(ser, x, n): 
row := n -> seq(coeff(poly(n), y, k), k = 0..n):
for n from 0 to 9 do row(n) od;

Expanding a bivariate exponential generating function

Expanding an univariate exponential generating function can be done like this:

def egfExpand1(f, size):
    x = var('x')
    return taylor(f(x), x, 0, size).power_series(SR).egf_to_ogf().list()

For example egfExpand1(sec, 10) returns [1, 0, 1, 0, 5, 0, 61, 0, 1385, 0, 50521].

But how can I expand a bivariate exponential generating function? Say

def f(x, y): return exp(x * y) * sec(x)

def egfExpand2(f, size):
    return ...

The expected output is an integer triangle (i.e. a list of integer lists).

The example would return an unsigned version of A119879, which starts:

                           1
                          0, 1
                        1, 0, 1
                       0, 3, 0, 1
                     5, 0, 6, 0, 1

In Maple this can be done with:Edit:

Frédéric suggested the following solution, slightly rewritten here.

egf := exp(x * y) * sec(x): ser := series(egf, x, 11):
poly := n -> n! * coeff(ser, x, n): 
row := n -> seq(coeff(poly(n), y, k), k def egfExpand2(f, size):
    y = 0..n):
polygen(QQ, "y")
    x = LazyPowerSeriesRing(y.parent(), "x").gen()
    return [list(f(x, y)[n] * factorial(n)) for n from 0 to 9 do row(n) od;
in range(size)]

f = lambda x, y: exp(x * y) * sec(x)
egfExpand2(f, 10)

The univariate case can also be written more elegantly with this method:

def egfExpand1(f, size: int):
    x = LazyPowerSeriesRing(QQ, "x").gen()
    return [f(x)[n] * factorial(n) for n in range(size)]

egfExpand1(sec, 11)