In [1]:
    
from sympy import *
from sympy.abc import n, i, N, x, lamda, phi, z, j, r, k, a, t, alpha
from sequences import *
init_printing()
    
In [2]:
    
m = 5
d_fn, h_fn = Function('d'), Function('h')
d, h = IndexedBase('d'), IndexedBase('h')
    
In [3]:
    
rows, cols = 5, 5
ctor = lambda i,j: d[i,j]
Matrix(rows, cols, ctor)
    
    Out[3]:
In [4]:
    
d_series = Eq(d_fn(t), 1+sum(d[i]*t**i for i in range(1,m)))
h_series = Eq(h_fn(t), t*(1+sum(h[i]*t**i for i in range(1,m-1)))).expand()
d_series, h_series
    
    Out[4]:
In [5]:
    
R = Matrix(m, m, riordan_matrix_by_convolution(m, d_series, h_series))
R
    
    Out[5]:
In [6]:
    
production_matrix(R) # too verbose to show
    
    Out[6]:
In [7]:
    
d_series = Eq(d_fn(t), 1/(1-t))
h_series = Eq(h_fn(t), t*d_series.rhs)
d_series, h_series
    
    Out[7]:
In [8]:
    
R = Matrix(10, 10, riordan_matrix_by_convolution(10, d_series, h_series))
R
    
    Out[8]:
In [9]:
    
dim = 5
a, b, b_bar, c = symbols(r'a b \bar{b} c')
M = Matrix(dim, dim, 
           riordan_matrix_by_recurrence(
               dim, lambda n, k: {(n-1, k-1):a, 
                                  (n-1, k): b if k else b_bar, 
                                  (n-1, k+1):c}))
M
    
    Out[9]:
In [10]:
    
production_matrix(M)
    
    Out[10]:
In [11]:
    
Msubs = M.subs({a:1, b_bar:b})
Msubs, production_matrix(Msubs)
    
    Out[11]:
In [12]:
    
A, Z = Function('A'), Function('Z')
A_eq = Eq(A(t), 1 + t)
Z_eq = Eq(Z(t),1)
A_eq, Z_eq
    
    Out[12]:
In [13]:
    
R = Matrix(10, 10, riordan_matrix_by_AZ_sequences(10, (Z_eq, A_eq)))
R, production_matrix(R)
    
    Out[13]:
In [14]:
    
A = Function('A')
A_ones = Eq(A(t), 1/(1-t))
R = Matrix(10, 10, riordan_matrix_by_AZ_sequences(10, (A_ones, A_ones)))
R, production_matrix(R)
    
    Out[14]:
In [15]:
    
dim = 5
A = Function('A')
a = IndexedBase('a')
A_gen = Eq(A(t), sum((a[j] if j else 1)*t**j for j in range(dim)))
R = Matrix(dim, dim, riordan_matrix_by_AZ_sequences(dim, (A_gen, A_gen)))
R
    
    Out[15]:
In [16]:
    
z = IndexedBase('z')
A_gen = Eq(A(t), sum((a[j] if j else 1)*t**j for j in range(dim)))
Z_gen = Eq(Z(t), sum((z[j] if j else 1)*t**j for j in range(dim)))
Raz = Matrix(dim, dim, riordan_matrix_by_AZ_sequences(dim, (Z_gen, A_gen)))
Raz
    
    Out[16]:
In [17]:
    
production_matrix(R), production_matrix(Raz)
    
    Out[17]:
In [18]:
    
H = Function('h')
C_eq = Eq(H(t), (1-sqrt(1-4*t))/2)
C_eq, compositional_inverse(C_eq)
    
    Out[18]:
In [19]:
    
P_eq = Eq(H(t), t/(1-t))
(P_eq, 
 compositional_inverse(P_eq), 
 compositional_inverse(compositional_inverse(P_eq), y=t))
    
    Out[19]:
In [20]:
    
d_series = Eq(d_fn(t), 1/(1-t))
h_series = Eq(h_fn(t), t/(1-t))
P_inverse = group_inverse(d_series, h_series)
P_inverse
    
    Out[20]:
In [21]:
    
R = Matrix(10, 10, riordan_matrix_by_convolution(10, *P_inverse))
R, production_matrix(R)
    
    Out[21]:
In [22]:
    
catalan_term = (1-sqrt(1-4*t))/(2*t)
d_series = Eq(d_fn(t), catalan_term)
h_series = Eq(h_fn(t), t*catalan_term)
C_inverse = group_inverse(d_series, h_series, post=radsimp)
C_inverse
    
    Out[22]:
In [23]:
    
R = Matrix(10, 10, riordan_matrix_by_convolution(10, C_inverse[0], C_inverse[1]))
R
    
    Out[23]:
build the triangle of Stirling numbers of the II kind
In [24]:
    
d_series = Eq(d_fn(t), 1)
h_series = Eq(h_fn(t), exp(t)-1)
d_series, h_series
    
    Out[24]:
In [25]:
    
R = Matrix(10, 10, riordan_matrix_exponential(
            riordan_matrix_by_convolution(10, d_series, h_series)))
R
    
    Out[25]:
In [26]:
    
production_matrix(R), production_matrix(R, exp=True)
    
    Out[26]:
In [27]:
    
inspect(R)
    
    Out[27]:
In [30]:
    
d_series = Eq(d_fn(t), 1/(1-t))
h_series = Eq(h_fn(t), t/(1-t))
d_series, h_series
    
    Out[30]:
In [31]:
    
R = Matrix(10, 10, riordan_matrix_exponential(
            riordan_matrix_by_convolution(10, d_series, h_series)))
R
    
    Out[31]:
In [32]:
    
production_matrix(R), production_matrix(R, exp=True)
    
    Out[32]:
In [33]:
    
inspect(R)
    
    Out[33]:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.