from sympy import *
from sympy.abc import n, i, N, x, lamda, phi, z, j, r, k, a, alpha
from commons import *
from matrix_functions import *
from sequences import *
import functions_catalog
init_printing()
from sympy.functions.combinatorial.numbers import stirling
m=8
S2 = define(let=Symbol(r'\mathcal{{S}}_{{ {} }}'.format(m)),
be=Matrix(m, m, lambda n,k: stirling(n,k, kind=2)))
S2 # this version is the pure one
S2 = define(let=Symbol(r'\mathcal{{S}}_{{ {} }}'.format(m)),
be=Matrix(m, m, riordan_matrix_exponential(
riordan_matrix_by_convolution(d=Eq(Function('d')(z), exp(z)),
h=Eq(Function('h')(z), exp(z)-1),
dim=m))))
S2
inspect(S2.rhs)
nature(is_ordinary=False, is_exponential=True)
production_matrix(S2.rhs)
eigendata = spectrum(S2)
eigendata
data, eigenvals, multiplicities = eigendata.rhs
Phi_poly = Phi_poly_ctor(deg=m-1)
Phi_poly
Phi_polynomials = component_polynomials(eigendata, early_eigenvals_subs=True)
Phi_polynomials
cmatrices = component_matrices(S2, Phi_polynomials)
cmatrices
power
function¶f_power, g_power, G_power = functions_catalog.power(eigendata, Phi_polynomials)
S2_power = G_power(S2)
S2_power
define(S2_power.lhs, S2_power.rhs.applyfunc(factor)) # factored
S2_power.rhs[:,0]
assert (S2.rhs**r).applyfunc(simplify) == S2_power.rhs
inspect(S2_power.rhs)
nature(is_ordinary=False, is_exponential=True)
production_matrix(S2_power.rhs).applyfunc(factor)
inverse
function¶f_inverse, g_inverse, G_inverse = functions_catalog.inverse(eigendata, Phi_polynomials)
S2_inverse = G_inverse(S2)
S2_inverse, G_inverse(S2_inverse)
inspect(S2_inverse.rhs)
nature(is_ordinary=False, is_exponential=True)
production_matrix(S2_inverse.rhs)
assert S2_inverse.rhs*S2.rhs == Matrix(m, m, identity_matrix())
assert S2_inverse.rhs == S2_power.rhs.subs({r:-1})
sqrt
function¶f_sqrt, g_sqrt, G_sqrt = functions_catalog.square_root(eigendata, Phi_polynomials)
S2_sqrt = G_sqrt(S2)
S2_sqrt
inspect(S2_sqrt.rhs)
nature(is_ordinary=False, is_exponential=True)
production_matrix(S2_sqrt.rhs)
inspect(S2_sqrt.rhs)
nature(is_ordinary=False, is_exponential=True)
production_matrix(S2_sqrt.rhs, exp=False)
assert S2_sqrt.rhs == S2.rhs**(S(1)/2)
assert S2_sqrt.rhs == S2_power.rhs.subs({r:S(1)/2})
expt
function¶f_exp, g_exp, G_exp = functions_catalog.exp(eigendata, Phi_polynomials)
S2_exp = G_exp(S2)
S2_exp
define(S2_exp.lhs, S2_exp.rhs.applyfunc(factor))
S2_exp1 = define(let=Subs(S2_exp.lhs, alpha, 1), be=S2_exp.rhs.subs({alpha:1}))
S2_exp1
inspect(S2_exp.rhs)
nature(is_ordinary=False, is_exponential=False)
inspect(S2_exp1.rhs)
nature(is_ordinary=False, is_exponential=False)
log
function¶f_log, g_log, G_log = functions_catalog.log(eigendata, Phi_polynomials)
S2_log = G_log(S2)
S2_log
inspect(S2_log.rhs[1:,:-1])
nature(is_ordinary=False, is_exponential=True)
production_matrix(S2_log.rhs[1:,:-1])
sin
function¶f_sin, g_sin, G_sin = functions_catalog.sin(eigendata, Phi_polynomials)
S2_sin = G_sin(S2)
S2_sin
cos
function¶f_cos, g_cos, G_cos = functions_catalog.cos(eigendata, Phi_polynomials)
S2_cos = G_cos(S2)
S2_cos
assert (S2_sin.rhs**2 + S2_cos.rhs**2).applyfunc(trigsimp) == Matrix(m, m, identity_matrix())
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.