Massimo Nocentini

March 2, 2018: compositional inverse
February 26, 2018: splitting from generic nb



Abstract
Ctors for (symbolic) Riordan arrays.

In [ ]:
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 = 8

d_fn, h_fn = Function('d'), Function('h')
d, h = IndexedBase('d'), IndexedBase('h')


In [3]:
from commons import define

In [63]:
%run ../../src/commons.py

In [77]:
at = define(a,t+1)
at


Out[77]:
$$a = t + 1$$

In [82]:
at(return_eq=True)


Out[82]:
$$\left. a = t + 1 \right|_{\substack{ a=t + 1 }}$$

In [64]:
D = define(d_fn(t),sin(t)**2+cos(t)**2)
D


Out[64]:
$$d{\left (t \right )} = \sin^{2}{\left (t \right )} + \cos^{2}{\left (t \right )}$$

In [65]:
D(pi/2, return_eq=False)


Out[65]:
$$1$$

In [66]:
d1 = D(pi/2, return_eq=True)
d1


Out[66]:
$$\left. d{\left (\frac{\pi}{2} \right )} = 1 \right|_{\substack{ d{\left (t \right )}=\sin^{2}{\left (t \right )} + \cos^{2}{\left (t \right )} }}$$

In [71]:
d1.substitution()


Out[71]:
$$d{\left (t \right )} = \sin^{2}{\left (t \right )} + \cos^{2}{\left (t \right )}$$

In [68]:
callable(d1)


Out[68]:
False

In [72]:
s = Subs(t+1,[t,a],[3,4])
s


Out[72]:
$$\left. t + 1 \right|_{\substack{ t=3\\ a=4 }}$$

In [74]:
Lambda([],t+1)


Out[74]:
$$\left( \left ( \right ) \mapsto t + 1 \right)$$

In [31]:
Subs?

By series convolution


In [3]:
d_series = Eq(d_fn(t), sum(d[i]*t**i for i in range(m))).subs({d[0]:1})
h_series = Eq(h_fn(t), t*sum(h[i]*t**i for i in range(m-1))).expand().subs({h[0]:1})

d_series, h_series


Out[3]:
$$\left ( d{\left (t \right )} = t^{7} d_{7} + t^{6} d_{6} + t^{5} d_{5} + t^{4} d_{4} + t^{3} d_{3} + t^{2} d_{2} + t d_{1} + 1, \quad h{\left (t \right )} = t^{7} h_{6} + t^{6} h_{5} + t^{5} h_{4} + t^{4} h_{3} + t^{3} h_{2} + t^{2} h_{1} + t\right )$$

In [4]:
R = Matrix(m, m, riordan_matrix_by_convolution(m, d_series, h_series))
R


Out[4]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\d_{1} & 1 & 0 & 0 & 0 & 0 & 0 & 0\\d_{2} & d_{1} + h_{1} & 1 & 0 & 0 & 0 & 0 & 0\\d_{3} & d_{1} h_{1} + d_{2} + h_{2} & d_{1} + 2 h_{1} & 1 & 0 & 0 & 0 & 0\\d_{4} & d_{1} h_{2} + d_{2} h_{1} + d_{3} + h_{3} & 2 d_{1} h_{1} + d_{2} + h_{1}^{2} + 2 h_{2} & d_{1} + 3 h_{1} & 1 & 0 & 0 & 0\\d_{5} & d_{1} h_{3} + d_{2} h_{2} + d_{3} h_{1} + d_{4} + h_{4} & d_{1} h_{1}^{2} + 2 d_{1} h_{2} + 2 d_{2} h_{1} + d_{3} + 2 h_{1} h_{2} + 2 h_{3} & 3 d_{1} h_{1} + d_{2} + 3 h_{1}^{2} + 3 h_{2} & d_{1} + 4 h_{1} & 1 & 0 & 0\\d_{6} & d_{1} h_{4} + d_{2} h_{3} + d_{3} h_{2} + d_{4} h_{1} + d_{5} + h_{5} & 2 d_{1} h_{1} h_{2} + 2 d_{1} h_{3} + d_{2} h_{1}^{2} + 2 d_{2} h_{2} + 2 d_{3} h_{1} + d_{4} + 2 h_{1} h_{3} + h_{2}^{2} + 2 h_{4} & 3 d_{1} h_{1}^{2} + 3 d_{1} h_{2} + 3 d_{2} h_{1} + d_{3} + h_{1}^{3} + 6 h_{1} h_{2} + 3 h_{3} & 4 d_{1} h_{1} + d_{2} + 6 h_{1}^{2} + 4 h_{2} & d_{1} + 5 h_{1} & 1 & 0\\d_{7} & d_{1} h_{5} + d_{2} h_{4} + d_{3} h_{3} + d_{4} h_{2} + d_{5} h_{1} + d_{6} + h_{6} & 2 d_{1} h_{1} h_{3} + d_{1} h_{2}^{2} + 2 d_{1} h_{4} + 2 d_{2} h_{1} h_{2} + 2 d_{2} h_{3} + d_{3} h_{1}^{2} + 2 d_{3} h_{2} + 2 d_{4} h_{1} + d_{5} + 2 h_{1} h_{4} + 2 h_{2} h_{3} + 2 h_{5} & d_{1} h_{1}^{3} + 6 d_{1} h_{1} h_{2} + 3 d_{1} h_{3} + 3 d_{2} h_{1}^{2} + 3 d_{2} h_{2} + 3 d_{3} h_{1} + d_{4} + 3 h_{1}^{2} h_{2} + 6 h_{1} h_{3} + 3 h_{2}^{2} + 3 h_{4} & 6 d_{1} h_{1}^{2} + 4 d_{1} h_{2} + 4 d_{2} h_{1} + d_{3} + 4 h_{1}^{3} + 12 h_{1} h_{2} + 4 h_{3} & 5 d_{1} h_{1} + d_{2} + 10 h_{1}^{2} + 5 h_{2} & d_{1} + 6 h_{1} & 1\end{matrix}\right]$$

In [ ]:
production_matrix(R) # too verbose to show

In [5]:
d_series = Eq(d_fn(t), 1/(1-t))
h_series = Eq(h_fn(t), t*d_series.rhs)

d_series, h_series


Out[5]:
$$\left ( d{\left (t \right )} = \frac{1}{- t + 1}, \quad h{\left (t \right )} = \frac{t}{- t + 1}\right )$$

In [6]:
R = Matrix(m, m, riordan_matrix_by_convolution(m, d_series, h_series))
R


Out[6]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 2 & 1 & 0 & 0 & 0 & 0 & 0\\1 & 3 & 3 & 1 & 0 & 0 & 0 & 0\\1 & 4 & 6 & 4 & 1 & 0 & 0 & 0\\1 & 5 & 10 & 10 & 5 & 1 & 0 & 0\\1 & 6 & 15 & 20 & 15 & 6 & 1 & 0\\1 & 7 & 21 & 35 & 35 & 21 & 7 & 1\end{matrix}\right]$$

By recurrence relation


In [7]:
dim = m
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[7]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\bar{b} & a & 0 & 0 & 0 & 0 & 0 & 0\\\bar{b}^{2} + a c & \bar{b} a + a b & a^{2} & 0 & 0 & 0 & 0 & 0\\\bar{b}^{3} + 2 \bar{b} a c + a b c & \bar{b}^{2} a + \bar{b} a b + 2 a^{2} c + a b^{2} & \bar{b} a^{2} + 2 a^{2} b & a^{3} & 0 & 0 & 0 & 0\\\bar{b}^{4} + 3 \bar{b}^{2} a c + 2 \bar{b} a b c + 2 a^{2} c^{2} + a b^{2} c & \bar{b}^{3} a + \bar{b}^{2} a b + 3 \bar{b} a^{2} c + \bar{b} a b^{2} + 5 a^{2} b c + a b^{3} & \bar{b}^{2} a^{2} + 2 \bar{b} a^{2} b + 3 a^{3} c + 3 a^{2} b^{2} & \bar{b} a^{3} + 3 a^{3} b & a^{4} & 0 & 0 & 0\\\bar{b}^{5} + 4 \bar{b}^{3} a c + 3 \bar{b}^{2} a b c + 5 \bar{b} a^{2} c^{2} + 2 \bar{b} a b^{2} c + 5 a^{2} b c^{2} + a b^{3} c & \bar{b}^{4} a + \bar{b}^{3} a b + 4 \bar{b}^{2} a^{2} c + \bar{b}^{2} a b^{2} + 7 \bar{b} a^{2} b c + \bar{b} a b^{3} + 5 a^{3} c^{2} + 9 a^{2} b^{2} c + a b^{4} & \bar{b}^{3} a^{2} + 2 \bar{b}^{2} a^{2} b + 4 \bar{b} a^{3} c + 3 \bar{b} a^{2} b^{2} + 11 a^{3} b c + 4 a^{2} b^{3} & \bar{b}^{2} a^{3} + 3 \bar{b} a^{3} b + 4 a^{4} c + 6 a^{3} b^{2} & \bar{b} a^{4} + 4 a^{4} b & a^{5} & 0 & 0\\\bar{b}^{6} + 5 \bar{b}^{4} a c + 4 \bar{b}^{3} a b c + 9 \bar{b}^{2} a^{2} c^{2} + 3 \bar{b}^{2} a b^{2} c + 12 \bar{b} a^{2} b c^{2} + 2 \bar{b} a b^{3} c + 5 a^{3} c^{3} + 9 a^{2} b^{2} c^{2} + a b^{4} c & \bar{b}^{5} a + \bar{b}^{4} a b + 5 \bar{b}^{3} a^{2} c + \bar{b}^{3} a b^{2} + 9 \bar{b}^{2} a^{2} b c + \bar{b}^{2} a b^{3} + 9 \bar{b} a^{3} c^{2} + 12 \bar{b} a^{2} b^{2} c + \bar{b} a b^{4} + 21 a^{3} b c^{2} + 14 a^{2} b^{3} c + a b^{5} & \bar{b}^{4} a^{2} + 2 \bar{b}^{3} a^{2} b + 5 \bar{b}^{2} a^{3} c + 3 \bar{b}^{2} a^{2} b^{2} + 14 \bar{b} a^{3} b c + 4 \bar{b} a^{2} b^{3} + 9 a^{4} c^{2} + 26 a^{3} b^{2} c + 5 a^{2} b^{4} & \bar{b}^{3} a^{3} + 3 \bar{b}^{2} a^{3} b + 5 \bar{b} a^{4} c + 6 \bar{b} a^{3} b^{2} + 19 a^{4} b c + 10 a^{3} b^{3} & \bar{b}^{2} a^{4} + 4 \bar{b} a^{4} b + 5 a^{5} c + 10 a^{4} b^{2} & \bar{b} a^{5} + 5 a^{5} b & a^{6} & 0\\\bar{b}^{7} + 6 \bar{b}^{5} a c + 5 \bar{b}^{4} a b c + 14 \bar{b}^{3} a^{2} c^{2} + 4 \bar{b}^{3} a b^{2} c + 21 \bar{b}^{2} a^{2} b c^{2} + 3 \bar{b}^{2} a b^{3} c + 14 \bar{b} a^{3} c^{3} + 21 \bar{b} a^{2} b^{2} c^{2} + 2 \bar{b} a b^{4} c + 21 a^{3} b c^{3} + 14 a^{2} b^{3} c^{2} + a b^{5} c & \bar{b}^{6} a + \bar{b}^{5} a b + 6 \bar{b}^{4} a^{2} c + \bar{b}^{4} a b^{2} + 11 \bar{b}^{3} a^{2} b c + \bar{b}^{3} a b^{3} + 14 \bar{b}^{2} a^{3} c^{2} + 15 \bar{b}^{2} a^{2} b^{2} c + \bar{b}^{2} a b^{4} + 35 \bar{b} a^{3} b c^{2} + 18 \bar{b} a^{2} b^{3} c + \bar{b} a b^{5} + 14 a^{4} c^{3} + 56 a^{3} b^{2} c^{2} + 20 a^{2} b^{4} c + a b^{6} & \bar{b}^{5} a^{2} + 2 \bar{b}^{4} a^{2} b + 6 \bar{b}^{3} a^{3} c + 3 \bar{b}^{3} a^{2} b^{2} + 17 \bar{b}^{2} a^{3} b c + 4 \bar{b}^{2} a^{2} b^{3} + 14 \bar{b} a^{4} c^{2} + 32 \bar{b} a^{3} b^{2} c + 5 \bar{b} a^{2} b^{4} + 49 a^{4} b c^{2} + 50 a^{3} b^{3} c + 6 a^{2} b^{5} & \bar{b}^{4} a^{3} + 3 \bar{b}^{3} a^{3} b + 6 \bar{b}^{2} a^{4} c + 6 \bar{b}^{2} a^{3} b^{2} + 23 \bar{b} a^{4} b c + 10 \bar{b} a^{3} b^{3} + 14 a^{5} c^{2} + 55 a^{4} b^{2} c + 15 a^{3} b^{4} & \bar{b}^{3} a^{4} + 4 \bar{b}^{2} a^{4} b + 6 \bar{b} a^{5} c + 10 \bar{b} a^{4} b^{2} + 29 a^{5} b c + 20 a^{4} b^{3} & \bar{b}^{2} a^{5} + 5 \bar{b} a^{5} b + 6 a^{6} c + 15 a^{5} b^{2} & \bar{b} a^{6} + 6 a^{6} b & a^{7}\end{matrix}\right]$$

In [8]:
production_matrix(M)


Out[8]:
$$\left[\begin{matrix}\bar{b} & a & 0 & 0 & 0 & 0 & 0\\c & b & a & 0 & 0 & 0 & 0\\0 & c & b & a & 0 & 0 & 0\\0 & 0 & c & b & a & 0 & 0\\0 & 0 & 0 & c & b & a & 0\\0 & 0 & 0 & 0 & c & b & a\\0 & 0 & 0 & 0 & 0 & c & b\end{matrix}\right]$$

By $A, Z$ sequences

$\mathcal{P}$


In [9]:
A = Function('A')
A_one_t = Eq(A(t), 1 + t)
A_one = Eq(A(t),1)
A_one, A_one_t


Out[9]:
$$\left ( A{\left (t \right )} = 1, \quad A{\left (t \right )} = t + 1\right )$$

In [10]:
R = Matrix(m, m, riordan_matrix_by_AZ_sequences(dim, (A_one, A_one_t)))
R


Out[10]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 2 & 1 & 0 & 0 & 0 & 0 & 0\\1 & 3 & 3 & 1 & 0 & 0 & 0 & 0\\1 & 4 & 6 & 4 & 1 & 0 & 0 & 0\\1 & 5 & 10 & 10 & 5 & 1 & 0 & 0\\1 & 6 & 15 & 20 & 15 & 6 & 1 & 0\\1 & 7 & 21 & 35 & 35 & 21 & 7 & 1\end{matrix}\right]$$

In [11]:
production_matrix(R)


Out[11]:
$$\left[\begin{matrix}1 & 1 & 0 & 0 & 0 & 0 & 0\\0 & 1 & 1 & 0 & 0 & 0 & 0\\0 & 0 & 1 & 1 & 0 & 0 & 0\\0 & 0 & 0 & 1 & 1 & 0 & 0\\0 & 0 & 0 & 0 & 1 & 1 & 0\\0 & 0 & 0 & 0 & 0 & 1 & 1\\0 & 0 & 0 & 0 & 0 & 0 & 1\end{matrix}\right]$$

$\mathcal{C}$


In [12]:
A = Function('A')
A_ones = Eq(A(t), 1/(1-t))
R = Matrix(m, m, riordan_matrix_by_AZ_sequences(dim, (A_ones, A_ones)))
R


Out[12]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\2 & 2 & 1 & 0 & 0 & 0 & 0 & 0\\5 & 5 & 3 & 1 & 0 & 0 & 0 & 0\\14 & 14 & 9 & 4 & 1 & 0 & 0 & 0\\42 & 42 & 28 & 14 & 5 & 1 & 0 & 0\\132 & 132 & 90 & 48 & 20 & 6 & 1 & 0\\429 & 429 & 297 & 165 & 75 & 27 & 7 & 1\end{matrix}\right]$$

In [13]:
production_matrix(R)


Out[13]:
$$\left[\begin{matrix}1 & 1 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 1 & 0 & 0 & 0 & 0\\1 & 1 & 1 & 1 & 0 & 0 & 0\\1 & 1 & 1 & 1 & 1 & 0 & 0\\1 & 1 & 1 & 1 & 1 & 1 & 0\\1 & 1 & 1 & 1 & 1 & 1 & 1\\1 & 1 & 1 & 1 & 1 & 1 & 1\end{matrix}\right]$$

$\mathcal{R}$


In [14]:
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(m, m, riordan_matrix_by_AZ_sequences(dim, (A_gen, A_gen)))
R


Out[14]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\a_{1} + 1 & a_{1} + 1 & 1 & 0 & 0 & 0 & 0 & 0\\a_{1}^{2} + 2 a_{1} + a_{2} + 1 & a_{1}^{2} + 2 a_{1} + a_{2} + 1 & 2 a_{1} + 1 & 1 & 0 & 0 & 0 & 0\\a_{1}^{3} + 3 a_{1}^{2} + 3 a_{1} a_{2} + 3 a_{1} + 2 a_{2} + a_{3} + 1 & a_{1}^{3} + 3 a_{1}^{2} + 3 a_{1} a_{2} + 3 a_{1} + 2 a_{2} + a_{3} + 1 & 3 a_{1}^{2} + 3 a_{1} + 2 a_{2} + 1 & 3 a_{1} + 1 & 1 & 0 & 0 & 0\\a_{1}^{4} + 4 a_{1}^{3} + 6 a_{1}^{2} a_{2} + 6 a_{1}^{2} + 8 a_{1} a_{2} + 4 a_{1} a_{3} + 4 a_{1} + 2 a_{2}^{2} + 3 a_{2} + 2 a_{3} + a_{4} + 1 & a_{1}^{4} + 4 a_{1}^{3} + 6 a_{1}^{2} a_{2} + 6 a_{1}^{2} + 8 a_{1} a_{2} + 4 a_{1} a_{3} + 4 a_{1} + 2 a_{2}^{2} + 3 a_{2} + 2 a_{3} + a_{4} + 1 & 4 a_{1}^{3} + 6 a_{1}^{2} + 8 a_{1} a_{2} + 4 a_{1} + 3 a_{2} + 2 a_{3} + 1 & 6 a_{1}^{2} + 4 a_{1} + 3 a_{2} + 1 & 4 a_{1} + 1 & 1 & 0 & 0\\a_{1}^{5} + 5 a_{1}^{4} + 10 a_{1}^{3} a_{2} + 10 a_{1}^{3} + 20 a_{1}^{2} a_{2} + 10 a_{1}^{2} a_{3} + 10 a_{1}^{2} + 10 a_{1} a_{2}^{2} + 15 a_{1} a_{2} + 10 a_{1} a_{3} + 5 a_{1} a_{4} + 5 a_{1} + 5 a_{2}^{2} + 5 a_{2} a_{3} + 4 a_{2} + 3 a_{3} + 2 a_{4} + a_{5} + 1 & a_{1}^{5} + 5 a_{1}^{4} + 10 a_{1}^{3} a_{2} + 10 a_{1}^{3} + 20 a_{1}^{2} a_{2} + 10 a_{1}^{2} a_{3} + 10 a_{1}^{2} + 10 a_{1} a_{2}^{2} + 15 a_{1} a_{2} + 10 a_{1} a_{3} + 5 a_{1} a_{4} + 5 a_{1} + 5 a_{2}^{2} + 5 a_{2} a_{3} + 4 a_{2} + 3 a_{3} + 2 a_{4} + a_{5} + 1 & 5 a_{1}^{4} + 10 a_{1}^{3} + 20 a_{1}^{2} a_{2} + 10 a_{1}^{2} + 15 a_{1} a_{2} + 10 a_{1} a_{3} + 5 a_{1} + 5 a_{2}^{2} + 4 a_{2} + 3 a_{3} + 2 a_{4} + 1 & 10 a_{1}^{3} + 10 a_{1}^{2} + 15 a_{1} a_{2} + 5 a_{1} + 4 a_{2} + 3 a_{3} + 1 & 10 a_{1}^{2} + 5 a_{1} + 4 a_{2} + 1 & 5 a_{1} + 1 & 1 & 0\\a_{1}^{6} + 6 a_{1}^{5} + 15 a_{1}^{4} a_{2} + 15 a_{1}^{4} + 40 a_{1}^{3} a_{2} + 20 a_{1}^{3} a_{3} + 20 a_{1}^{3} + 30 a_{1}^{2} a_{2}^{2} + 45 a_{1}^{2} a_{2} + 30 a_{1}^{2} a_{3} + 15 a_{1}^{2} a_{4} + 15 a_{1}^{2} + 30 a_{1} a_{2}^{2} + 30 a_{1} a_{2} a_{3} + 24 a_{1} a_{2} + 18 a_{1} a_{3} + 12 a_{1} a_{4} + 6 a_{1} a_{5} + 6 a_{1} + 5 a_{2}^{3} + 9 a_{2}^{2} + 12 a_{2} a_{3} + 6 a_{2} a_{4} + 5 a_{2} + 3 a_{3}^{2} + 4 a_{3} + 3 a_{4} + 2 a_{5} + a_{6} + 1 & a_{1}^{6} + 6 a_{1}^{5} + 15 a_{1}^{4} a_{2} + 15 a_{1}^{4} + 40 a_{1}^{3} a_{2} + 20 a_{1}^{3} a_{3} + 20 a_{1}^{3} + 30 a_{1}^{2} a_{2}^{2} + 45 a_{1}^{2} a_{2} + 30 a_{1}^{2} a_{3} + 15 a_{1}^{2} a_{4} + 15 a_{1}^{2} + 30 a_{1} a_{2}^{2} + 30 a_{1} a_{2} a_{3} + 24 a_{1} a_{2} + 18 a_{1} a_{3} + 12 a_{1} a_{4} + 6 a_{1} a_{5} + 6 a_{1} + 5 a_{2}^{3} + 9 a_{2}^{2} + 12 a_{2} a_{3} + 6 a_{2} a_{4} + 5 a_{2} + 3 a_{3}^{2} + 4 a_{3} + 3 a_{4} + 2 a_{5} + a_{6} + 1 & 6 a_{1}^{5} + 15 a_{1}^{4} + 40 a_{1}^{3} a_{2} + 20 a_{1}^{3} + 45 a_{1}^{2} a_{2} + 30 a_{1}^{2} a_{3} + 15 a_{1}^{2} + 30 a_{1} a_{2}^{2} + 24 a_{1} a_{2} + 18 a_{1} a_{3} + 12 a_{1} a_{4} + 6 a_{1} + 9 a_{2}^{2} + 12 a_{2} a_{3} + 5 a_{2} + 4 a_{3} + 3 a_{4} + 2 a_{5} + 1 & 15 a_{1}^{4} + 20 a_{1}^{3} + 45 a_{1}^{2} a_{2} + 15 a_{1}^{2} + 24 a_{1} a_{2} + 18 a_{1} a_{3} + 6 a_{1} + 9 a_{2}^{2} + 5 a_{2} + 4 a_{3} + 3 a_{4} + 1 & 20 a_{1}^{3} + 15 a_{1}^{2} + 24 a_{1} a_{2} + 6 a_{1} + 5 a_{2} + 4 a_{3} + 1 & 15 a_{1}^{2} + 6 a_{1} + 5 a_{2} + 1 & 6 a_{1} + 1 & 1\end{matrix}\right]$$

In [15]:
production_matrix(R)


Out[15]:
$$\left[\begin{matrix}1 & 1 & 0 & 0 & 0 & 0 & 0\\a_{1} & a_{1} & 1 & 0 & 0 & 0 & 0\\a_{2} & a_{2} & a_{1} & 1 & 0 & 0 & 0\\a_{3} & a_{3} & a_{2} & a_{1} & 1 & 0 & 0\\a_{4} & a_{4} & a_{3} & a_{2} & a_{1} & 1 & 0\\a_{5} & a_{5} & a_{4} & a_{3} & a_{2} & a_{1} & 1\\a_{6} & a_{6} & a_{5} & a_{4} & a_{3} & a_{2} & a_{1}\end{matrix}\right]$$

In [16]:
A, Z = Function('A'), Function('Z')
a, z = IndexedBase('a'), 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)))
R = Matrix(m, m, riordan_matrix_by_AZ_sequences(dim, (Z_gen, A_gen)))
R


Out[16]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\z_{1} + 1 & a_{1} + 1 & 1 & 0 & 0 & 0 & 0 & 0\\a_{1} z_{1} + 2 z_{1} + z_{2} + 1 & a_{1}^{2} + a_{1} + a_{2} + z_{1} + 1 & 2 a_{1} + 1 & 1 & 0 & 0 & 0 & 0\\a_{1}^{2} z_{1} + 2 a_{1} z_{1} + 2 a_{1} z_{2} + a_{2} z_{1} + z_{1}^{2} + 3 z_{1} + 2 z_{2} + z_{3} + 1 & a_{1}^{3} + a_{1}^{2} + 3 a_{1} a_{2} + 2 a_{1} z_{1} + a_{1} + a_{2} + a_{3} + 2 z_{1} + z_{2} + 1 & 3 a_{1}^{2} + 2 a_{1} + 2 a_{2} + z_{1} + 1 & 3 a_{1} + 1 & 1 & 0 & 0 & 0\\a_{1}^{3} z_{1} + 2 a_{1}^{2} z_{1} + 3 a_{1}^{2} z_{2} + 3 a_{1} a_{2} z_{1} + 2 a_{1} z_{1}^{2} + 3 a_{1} z_{1} + 4 a_{1} z_{2} + 3 a_{1} z_{3} + 2 a_{2} z_{1} + 2 a_{2} z_{2} + a_{3} z_{1} + 3 z_{1}^{2} + 2 z_{1} z_{2} + 4 z_{1} + 3 z_{2} + 2 z_{3} + z_{4} + 1 & a_{1}^{4} + a_{1}^{3} + 6 a_{1}^{2} a_{2} + 3 a_{1}^{2} z_{1} + a_{1}^{2} + 3 a_{1} a_{2} + 4 a_{1} a_{3} + 4 a_{1} z_{1} + 3 a_{1} z_{2} + a_{1} + 2 a_{2}^{2} + 2 a_{2} z_{1} + a_{2} + a_{3} + a_{4} + z_{1}^{2} + 3 z_{1} + 2 z_{2} + z_{3} + 1 & 4 a_{1}^{3} + 3 a_{1}^{2} + 8 a_{1} a_{2} + 3 a_{1} z_{1} + 2 a_{1} + 2 a_{2} + 2 a_{3} + 2 z_{1} + z_{2} + 1 & 6 a_{1}^{2} + 3 a_{1} + 3 a_{2} + z_{1} + 1 & 4 a_{1} + 1 & 1 & 0 & 0\\a_{1}^{4} z_{1} + 2 a_{1}^{3} z_{1} + 4 a_{1}^{3} z_{2} + 6 a_{1}^{2} a_{2} z_{1} + 3 a_{1}^{2} z_{1}^{2} + 3 a_{1}^{2} z_{1} + 6 a_{1}^{2} z_{2} + 6 a_{1}^{2} z_{3} + 6 a_{1} a_{2} z_{1} + 8 a_{1} a_{2} z_{2} + 4 a_{1} a_{3} z_{1} + 6 a_{1} z_{1}^{2} + 6 a_{1} z_{1} z_{2} + 4 a_{1} z_{1} + 6 a_{1} z_{2} + 6 a_{1} z_{3} + 4 a_{1} z_{4} + 2 a_{2}^{2} z_{1} + 2 a_{2} z_{1}^{2} + 3 a_{2} z_{1} + 4 a_{2} z_{2} + 3 a_{2} z_{3} + 2 a_{3} z_{1} + 2 a_{3} z_{2} + a_{4} z_{1} + z_{1}^{3} + 6 z_{1}^{2} + 6 z_{1} z_{2} + 2 z_{1} z_{3} + 5 z_{1} + z_{2}^{2} + 4 z_{2} + 3 z_{3} + 2 z_{4} + z_{5} + 1 & a_{1}^{5} + a_{1}^{4} + 10 a_{1}^{3} a_{2} + 4 a_{1}^{3} z_{1} + a_{1}^{3} + 6 a_{1}^{2} a_{2} + 10 a_{1}^{2} a_{3} + 6 a_{1}^{2} z_{1} + 6 a_{1}^{2} z_{2} + a_{1}^{2} + 10 a_{1} a_{2}^{2} + 8 a_{1} a_{2} z_{1} + 3 a_{1} a_{2} + 4 a_{1} a_{3} + 5 a_{1} a_{4} + 3 a_{1} z_{1}^{2} + 6 a_{1} z_{1} + 6 a_{1} z_{2} + 4 a_{1} z_{3} + a_{1} + 2 a_{2}^{2} + 5 a_{2} a_{3} + 4 a_{2} z_{1} + 3 a_{2} z_{2} + a_{2} + 2 a_{3} z_{1} + a_{3} + a_{4} + a_{5} + 3 z_{1}^{2} + 2 z_{1} z_{2} + 4 z_{1} + 3 z_{2} + 2 z_{3} + z_{4} + 1 & 5 a_{1}^{4} + 4 a_{1}^{3} + 20 a_{1}^{2} a_{2} + 6 a_{1}^{2} z_{1} + 3 a_{1}^{2} + 8 a_{1} a_{2} + 10 a_{1} a_{3} + 6 a_{1} z_{1} + 4 a_{1} z_{2} + 2 a_{1} + 5 a_{2}^{2} + 3 a_{2} z_{1} + 2 a_{2} + 2 a_{3} + 2 a_{4} + z_{1}^{2} + 3 z_{1} + 2 z_{2} + z_{3} + 1 & 10 a_{1}^{3} + 6 a_{1}^{2} + 15 a_{1} a_{2} + 4 a_{1} z_{1} + 3 a_{1} + 3 a_{2} + 3 a_{3} + 2 z_{1} + z_{2} + 1 & 10 a_{1}^{2} + 4 a_{1} + 4 a_{2} + z_{1} + 1 & 5 a_{1} + 1 & 1 & 0\\a_{1}^{5} z_{1} + 2 a_{1}^{4} z_{1} + 5 a_{1}^{4} z_{2} + 10 a_{1}^{3} a_{2} z_{1} + 4 a_{1}^{3} z_{1}^{2} + 3 a_{1}^{3} z_{1} + 8 a_{1}^{3} z_{2} + 10 a_{1}^{3} z_{3} + 12 a_{1}^{2} a_{2} z_{1} + 20 a_{1}^{2} a_{2} z_{2} + 10 a_{1}^{2} a_{3} z_{1} + 9 a_{1}^{2} z_{1}^{2} + 12 a_{1}^{2} z_{1} z_{2} + 4 a_{1}^{2} z_{1} + 9 a_{1}^{2} z_{2} + 12 a_{1}^{2} z_{3} + 10 a_{1}^{2} z_{4} + 10 a_{1} a_{2}^{2} z_{1} + 8 a_{1} a_{2} z_{1}^{2} + 9 a_{1} a_{2} z_{1} + 16 a_{1} a_{2} z_{2} + 15 a_{1} a_{2} z_{3} + 8 a_{1} a_{3} z_{1} + 10 a_{1} a_{3} z_{2} + 5 a_{1} a_{4} z_{1} + 3 a_{1} z_{1}^{3} + 12 a_{1} z_{1}^{2} + 18 a_{1} z_{1} z_{2} + 8 a_{1} z_{1} z_{3} + 5 a_{1} z_{1} + 4 a_{1} z_{2}^{2} + 8 a_{1} z_{2} + 9 a_{1} z_{3} + 8 a_{1} z_{4} + 5 a_{1} z_{5} + 4 a_{2}^{2} z_{1} + 5 a_{2}^{2} z_{2} + 5 a_{2} a_{3} z_{1} + 6 a_{2} z_{1}^{2} + 6 a_{2} z_{1} z_{2} + 4 a_{2} z_{1} + 6 a_{2} z_{2} + 6 a_{2} z_{3} + 4 a_{2} z_{4} + 2 a_{3} z_{1}^{2} + 3 a_{3} z_{1} + 4 a_{3} z_{2} + 3 a_{3} z_{3} + 2 a_{4} z_{1} + 2 a_{4} z_{2} + a_{5} z_{1} + 4 z_{1}^{3} + 3 z_{1}^{2} z_{2} + 10 z_{1}^{2} + 12 z_{1} z_{2} + 6 z_{1} z_{3} + 2 z_{1} z_{4} + 6 z_{1} + 3 z_{2}^{2} + 2 z_{2} z_{3} + 5 z_{2} + 4 z_{3} + 3 z_{4} + 2 z_{5} + z_{6} + 1 & a_{1}^{6} + a_{1}^{5} + 15 a_{1}^{4} a_{2} + 5 a_{1}^{4} z_{1} + a_{1}^{4} + 10 a_{1}^{3} a_{2} + 20 a_{1}^{3} a_{3} + 8 a_{1}^{3} z_{1} + 10 a_{1}^{3} z_{2} + a_{1}^{3} + 30 a_{1}^{2} a_{2}^{2} + 20 a_{1}^{2} a_{2} z_{1} + 6 a_{1}^{2} a_{2} + 10 a_{1}^{2} a_{3} + 15 a_{1}^{2} a_{4} + 6 a_{1}^{2} z_{1}^{2} + 9 a_{1}^{2} z_{1} + 12 a_{1}^{2} z_{2} + 10 a_{1}^{2} z_{3} + a_{1}^{2} + 10 a_{1} a_{2}^{2} + 30 a_{1} a_{2} a_{3} + 16 a_{1} a_{2} z_{1} + 15 a_{1} a_{2} z_{2} + 3 a_{1} a_{2} + 10 a_{1} a_{3} z_{1} + 4 a_{1} a_{3} + 5 a_{1} a_{4} + 6 a_{1} a_{5} + 9 a_{1} z_{1}^{2} + 8 a_{1} z_{1} z_{2} + 8 a_{1} z_{1} + 9 a_{1} z_{2} + 8 a_{1} z_{3} + 5 a_{1} z_{4} + a_{1} + 5 a_{2}^{3} + 5 a_{2}^{2} z_{1} + 2 a_{2}^{2} + 5 a_{2} a_{3} + 6 a_{2} a_{4} + 3 a_{2} z_{1}^{2} + 6 a_{2} z_{1} + 6 a_{2} z_{2} + 4 a_{2} z_{3} + a_{2} + 3 a_{3}^{2} + 4 a_{3} z_{1} + 3 a_{3} z_{2} + a_{3} + 2 a_{4} z_{1} + a_{4} + a_{5} + a_{6} + z_{1}^{3} + 6 z_{1}^{2} + 6 z_{1} z_{2} + 2 z_{1} z_{3} + 5 z_{1} + z_{2}^{2} + 4 z_{2} + 3 z_{3} + 2 z_{4} + z_{5} + 1 & 6 a_{1}^{5} + 5 a_{1}^{4} + 40 a_{1}^{3} a_{2} + 10 a_{1}^{3} z_{1} + 4 a_{1}^{3} + 20 a_{1}^{2} a_{2} + 30 a_{1}^{2} a_{3} + 12 a_{1}^{2} z_{1} + 10 a_{1}^{2} z_{2} + 3 a_{1}^{2} + 30 a_{1} a_{2}^{2} + 15 a_{1} a_{2} z_{1} + 8 a_{1} a_{2} + 10 a_{1} a_{3} + 12 a_{1} a_{4} + 4 a_{1} z_{1}^{2} + 9 a_{1} z_{1} + 8 a_{1} z_{2} + 5 a_{1} z_{3} + 2 a_{1} + 5 a_{2}^{2} + 12 a_{2} a_{3} + 6 a_{2} z_{1} + 4 a_{2} z_{2} + 2 a_{2} + 3 a_{3} z_{1} + 2 a_{3} + 2 a_{4} + 2 a_{5} + 3 z_{1}^{2} + 2 z_{1} z_{2} + 4 z_{1} + 3 z_{2} + 2 z_{3} + z_{4} + 1 & 15 a_{1}^{4} + 10 a_{1}^{3} + 45 a_{1}^{2} a_{2} + 10 a_{1}^{2} z_{1} + 6 a_{1}^{2} + 15 a_{1} a_{2} + 18 a_{1} a_{3} + 8 a_{1} z_{1} + 5 a_{1} z_{2} + 3 a_{1} + 9 a_{2}^{2} + 4 a_{2} z_{1} + 3 a_{2} + 3 a_{3} + 3 a_{4} + z_{1}^{2} + 3 z_{1} + 2 z_{2} + z_{3} + 1 & 20 a_{1}^{3} + 10 a_{1}^{2} + 24 a_{1} a_{2} + 5 a_{1} z_{1} + 4 a_{1} + 4 a_{2} + 4 a_{3} + 2 z_{1} + z_{2} + 1 & 15 a_{1}^{2} + 5 a_{1} + 5 a_{2} + z_{1} + 1 & 6 a_{1} + 1 & 1\end{matrix}\right]$$

In [17]:
production_matrix(R)


Out[17]:
$$\left[\begin{matrix}1 & 1 & 0 & 0 & 0 & 0 & 0\\z_{1} & a_{1} & 1 & 0 & 0 & 0 & 0\\z_{2} & a_{2} & a_{1} & 1 & 0 & 0 & 0\\z_{3} & a_{3} & a_{2} & a_{1} & 1 & 0 & 0\\z_{4} & a_{4} & a_{3} & a_{2} & a_{1} & 1 & 0\\z_{5} & a_{5} & a_{4} & a_{3} & a_{2} & a_{1} & 1\\z_{6} & a_{6} & a_{5} & a_{4} & a_{3} & a_{2} & a_{1}\end{matrix}\right]$$

Compositional inverse


In [18]:
H = Function('h')
C_eq = Eq(H(t), (1-sqrt(1-4*t))/2)
C_eq, compositional_inverse(C_eq)


Out[18]:
$$\left ( h{\left (t \right )} = - \frac{1}{2} \sqrt{- 4 t + 1} + \frac{1}{2}, \quad \bar{ h }{\left (y \right )} = - y \left(y - 1\right)\right )$$

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]:
$$\left ( h{\left (t \right )} = \frac{t}{- t + 1}, \quad \bar{ h }{\left (y \right )} = \frac{y}{y + 1}, \quad \bar{ \bar{ h } }{\left (t \right )} = - \frac{t}{t - 1}\right )$$

Exponential RA


In [20]:
d_series = Eq(d_fn(t), 1)
h_series = Eq(h_fn(t), exp(t)-1)
d_series, h_series # build the triangle of Stirling numbers of the II kind


Out[20]:
$$\left ( d{\left (t \right )} = 1, \quad h{\left (t \right )} = e^{t} - 1\right )$$

In [21]:
R = Matrix(m, m, riordan_matrix_exponential(
            riordan_matrix_by_convolution(m, d_series, h_series)))
R


Out[21]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 1 & 1 & 0 & 0 & 0 & 0 & 0\\0 & 1 & 3 & 1 & 0 & 0 & 0 & 0\\0 & 1 & 7 & 6 & 1 & 0 & 0 & 0\\0 & 1 & 15 & 25 & 10 & 1 & 0 & 0\\0 & 1 & 31 & 90 & 65 & 15 & 1 & 0\\0 & 1 & 63 & 301 & 350 & 140 & 21 & 1\end{matrix}\right]$$