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]:
In [82]:
    
at(return_eq=True)
    
    Out[82]:
In [64]:
    
D = define(d_fn(t),sin(t)**2+cos(t)**2)
D
    
    Out[64]:
In [65]:
    
D(pi/2, return_eq=False)
    
    Out[65]:
In [66]:
    
d1 = D(pi/2, return_eq=True)
d1
    
    Out[66]:
In [71]:
    
d1.substitution()
    
    Out[71]:
In [68]:
    
callable(d1)
    
    Out[68]:
In [72]:
    
s = Subs(t+1,[t,a],[3,4])
s
    
    Out[72]:
In [74]:
    
Lambda([],t+1)
    
    Out[74]:
In [31]:
    
Subs?
    
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]:
In [4]:
    
R = Matrix(m, m, riordan_matrix_by_convolution(m, d_series, h_series))
R
    
    Out[4]:
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]:
In [6]:
    
R = Matrix(m, m, riordan_matrix_by_convolution(m, d_series, h_series))
R
    
    Out[6]:
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]:
In [8]:
    
production_matrix(M)
    
    Out[8]:
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]:
In [10]:
    
R = Matrix(m, m, riordan_matrix_by_AZ_sequences(dim, (A_one, A_one_t)))
R
    
    Out[10]:
In [11]:
    
production_matrix(R)
    
    Out[11]:
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]:
In [13]:
    
production_matrix(R)
    
    Out[13]:
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]:
In [15]:
    
production_matrix(R)
    
    Out[15]:
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]:
In [17]:
    
production_matrix(R)
    
    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)
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]:
In [21]:
    
R = Matrix(m, m, riordan_matrix_exponential(
            riordan_matrix_by_convolution(m, d_series, h_series)))
R
    
    Out[21]:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.