Massimo Nocentini

November 20, 2018: cleanup, `sin` and `cos` $g$ polys
November 16 and 18, 2016: classic $g$ polys



Abstract
Theory of matrix functions, with applications to Stirling array $\mathcal{S}$.

In [1]:
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()

Stirling array $\mathcal{S}$


In [2]:
from sympy.functions.combinatorial.numbers import stirling

In [3]:
m=8

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


Out[4]:
$$\mathcal{S}_{ 8 } = \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]$$

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


Out[5]:
$$\mathcal{S}_{ 8 } = \left[\begin{matrix}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 & 0\\1 & 127 & 966 & 1701 & 1050 & 266 & 28 & 1\end{matrix}\right]$$

In [6]:
inspect(S2.rhs)


Out[6]:
nature(is_ordinary=False, is_exponential=True)

In [7]:
production_matrix(S2.rhs)


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

In [8]:
eigendata = spectrum(S2)
eigendata


Out[8]:
$$\sigma{\left (\mathcal{S}_{ 8 } \right )} = \left ( \left \{ 1 : \left ( \lambda_{1}, \quad m_{1}\right )\right \}, \quad \left \{ \lambda_{1} : 1\right \}, \quad \left \{ m_{1} : 8\right \}\right )$$

In [9]:
data, eigenvals, multiplicities = eigendata.rhs

In [10]:
Phi_poly = Phi_poly_ctor(deg=m-1)
Phi_poly


Out[10]:
$$\Phi{\left (z,i,j \right )} = z^{7} \phi_{i,j,0} + z^{6} \phi_{i,j,1} + z^{5} \phi_{i,j,2} + z^{4} \phi_{i,j,3} + z^{3} \phi_{i,j,4} + z^{2} \phi_{i,j,5} + z \phi_{i,j,6} + \phi_{i,j,7}$$

In [11]:
Phi_polynomials = component_polynomials(eigendata, early_eigenvals_subs=True)
Phi_polynomials


Out[11]:
$$\left \{ \left ( 1, \quad 1\right ) : \Phi_{ 1, 1 }{\left (z \right )} = 1, \quad \left ( 1, \quad 2\right ) : \Phi_{ 1, 2 }{\left (z \right )} = z - 1, \quad \left ( 1, \quad 3\right ) : \Phi_{ 1, 3 }{\left (z \right )} = \frac{z^{2}}{2} - z + \frac{1}{2}, \quad \left ( 1, \quad 4\right ) : \Phi_{ 1, 4 }{\left (z \right )} = \frac{z^{3}}{6} - \frac{z^{2}}{2} + \frac{z}{2} - \frac{1}{6}, \quad \left ( 1, \quad 5\right ) : \Phi_{ 1, 5 }{\left (z \right )} = \frac{z^{4}}{24} - \frac{z^{3}}{6} + \frac{z^{2}}{4} - \frac{z}{6} + \frac{1}{24}, \quad \left ( 1, \quad 6\right ) : \Phi_{ 1, 6 }{\left (z \right )} = \frac{z^{5}}{120} - \frac{z^{4}}{24} + \frac{z^{3}}{12} - \frac{z^{2}}{12} + \frac{z}{24} - \frac{1}{120}, \quad \left ( 1, \quad 7\right ) : \Phi_{ 1, 7 }{\left (z \right )} = \frac{z^{6}}{720} - \frac{z^{5}}{120} + \frac{z^{4}}{48} - \frac{z^{3}}{36} + \frac{z^{2}}{48} - \frac{z}{120} + \frac{1}{720}, \quad \left ( 1, \quad 8\right ) : \Phi_{ 1, 8 }{\left (z \right )} = \frac{z^{7}}{5040} - \frac{z^{6}}{720} + \frac{z^{5}}{240} - \frac{z^{4}}{144} + \frac{z^{3}}{144} - \frac{z^{2}}{240} + \frac{z}{720} - \frac{1}{5040}\right \}$$

In [12]:
cmatrices = component_matrices(S2, Phi_polynomials)
cmatrices


Out[12]:
$$\left \{ \left ( 1, \quad 1\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,1} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\end{matrix}\right], \quad \left ( 1, \quad 2\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,2} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 3 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 7 & 6 & 0 & 0 & 0 & 0 & 0\\1 & 15 & 25 & 10 & 0 & 0 & 0 & 0\\1 & 31 & 90 & 65 & 15 & 0 & 0 & 0\\1 & 63 & 301 & 350 & 140 & 21 & 0 & 0\\1 & 127 & 966 & 1701 & 1050 & 266 & 28 & 0\end{matrix}\right], \quad \left ( 1, \quad 3\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,3} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{3}{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{13}{2} & 9 & 0 & 0 & 0 & 0 & 0 & 0\\25 & \frac{145}{2} & 30 & 0 & 0 & 0 & 0 & 0\\\frac{201}{2} & 475 & \frac{765}{2} & 75 & 0 & 0 & 0 & 0\\\frac{875}{2} & 3052 & 3745 & \frac{2765}{2} & \frac{315}{2} & 0 & 0 & 0\\2069 & \frac{40565}{2} & 34412 & 18795 & 3955 & 294 & 0 & 0\end{matrix}\right], \quad \left ( 1, \quad 4\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,4} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\3 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{205}{6} & 30 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1865}{6} & \frac{1115}{2} & 150 & 0 & 0 & 0 & 0 & 0\\2779 & \frac{23275}{3} & \frac{8155}{2} & 525 & 0 & 0 & 0 & 0\\\frac{155477}{6} & 101080 & \frac{238105}{3} & \frac{58660}{3} & 1470 & 0 & 0 & 0\end{matrix}\right], \quad \left ( 1, \quad 5\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,5} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{15}{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1415}{8} & \frac{225}{2} & 0 & 0 & 0 & 0 & 0 & 0\\\frac{74165}{24} & \frac{31815}{8} & \frac{1575}{2} & 0 & 0 & 0 & 0 & 0\\\frac{604415}{12} & \frac{1191085}{12} & \frac{77035}{2} & 3675 & 0 & 0 & 0 & 0\end{matrix}\right], \quad \left ( 1, \quad 6\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,6} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{45}{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{7623}{8} & \frac{945}{2} & 0 & 0 & 0 & 0 & 0 & 0\\\frac{339479}{12} & \frac{56511}{2} & 4410 & 0 & 0 & 0 & 0 & 0\end{matrix}\right], \quad \left ( 1, \quad 7\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,7} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{315}{4} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{21777}{4} & 2205 & 0 & 0 & 0 & 0 & 0 & 0\end{matrix}\right], \quad \left ( 1, \quad 8\right ) : Z^{\left[ \mathcal{S}_{ 8 } \right]}_{1,8} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\315 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{matrix}\right]\right \}$$

power function


In [13]:
f_power, g_power, G_power = functions_catalog.power(eigendata, Phi_polynomials)

In [16]:
S2_power = G_power(S2)
S2_power


Out[16]:
$$\operatorname{P_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\r & 1 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{r}{2} \left(3 r - 1\right) & 3 r & 1 & 0 & 0 & 0 & 0 & 0\\\frac{r}{2} \left(6 r^{2} - 5 r + 1\right) & r \left(9 r - 2\right) & 6 r & 1 & 0 & 0 & 0 & 0\\\frac{r}{6} \left(45 r^{3} - 65 r^{2} + 30 r - 4\right) & \frac{5 r}{2} \left(12 r^{2} - 7 r + 1\right) & 5 r \left(6 r - 1\right) & 10 r & 1 & 0 & 0 & 0\\\frac{r}{24} \left(540 r^{4} - 1155 r^{3} + 890 r^{2} - 273 r + 22\right) & \frac{r}{2} \left(225 r^{3} - 235 r^{2} + 80 r - 8\right) & \frac{15 r}{2} \left(20 r^{2} - 9 r + 1\right) & 5 r \left(15 r - 2\right) & 15 r & 1 & 0 & 0\\\frac{r}{24} \left(1890 r^{5} - 5481 r^{4} + 6125 r^{3} - 3129 r^{2} + 637 r - 18\right) & \frac{7 r}{24} \left(1620 r^{4} - 2565 r^{3} + 1490 r^{2} - 351 r + 22\right) & \frac{7 r}{2} \left(225 r^{3} - 185 r^{2} + 50 r - 4\right) & \frac{35 r}{2} \left(30 r^{2} - 11 r + 1\right) & \frac{35 r}{2} \left(9 r - 1\right) & 21 r & 1 & 0\\\frac{r}{12} \left(3780 r^{6} - 14049 r^{5} + 21014 r^{4} - 15540 r^{3} + 5474 r^{2} - 645 r - 22\right) & \frac{r}{12} \left(26460 r^{5} - 57834 r^{4} + 49525 r^{3} - 19740 r^{2} + 3185 r - 72\right) & \frac{7 r}{6} \left(3780 r^{4} - 4785 r^{3} + 2240 r^{2} - 429 r + 22\right) & \frac{7 r}{3} \left(1575 r^{3} - 1070 r^{2} + 240 r - 16\right) & 35 r \left(42 r^{2} - 13 r + 1\right) & 14 r \left(21 r - 2\right) & 28 r & 1\end{matrix}\right]$$

In [17]:
define(S2_power.lhs, S2_power.rhs.applyfunc(factor)) # factored


Out[17]:
$$\operatorname{P_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\r & 1 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{r}{2} \left(3 r - 1\right) & 3 r & 1 & 0 & 0 & 0 & 0 & 0\\\frac{r}{2} \left(2 r - 1\right) \left(3 r - 1\right) & r \left(9 r - 2\right) & 6 r & 1 & 0 & 0 & 0 & 0\\\frac{r}{6} \left(45 r^{3} - 65 r^{2} + 30 r - 4\right) & \frac{5 r}{2} \left(3 r - 1\right) \left(4 r - 1\right) & 5 r \left(6 r - 1\right) & 10 r & 1 & 0 & 0 & 0\\\frac{r}{24} \left(3 r - 2\right) \left(180 r^{3} - 265 r^{2} + 120 r - 11\right) & \frac{r}{2} \left(225 r^{3} - 235 r^{2} + 80 r - 8\right) & \frac{15 r}{2} \left(4 r - 1\right) \left(5 r - 1\right) & 5 r \left(15 r - 2\right) & 15 r & 1 & 0 & 0\\\frac{r}{24} \left(1890 r^{5} - 5481 r^{4} + 6125 r^{3} - 3129 r^{2} + 637 r - 18\right) & \frac{7 r}{24} \left(1620 r^{4} - 2565 r^{3} + 1490 r^{2} - 351 r + 22\right) & \frac{7 r}{2} \left(225 r^{3} - 185 r^{2} + 50 r - 4\right) & \frac{35 r}{2} \left(5 r - 1\right) \left(6 r - 1\right) & \frac{35 r}{2} \left(9 r - 1\right) & 21 r & 1 & 0\\\frac{r}{12} \left(3780 r^{6} - 14049 r^{5} + 21014 r^{4} - 15540 r^{3} + 5474 r^{2} - 645 r - 22\right) & \frac{r}{12} \left(26460 r^{5} - 57834 r^{4} + 49525 r^{3} - 19740 r^{2} + 3185 r - 72\right) & \frac{7 r}{6} \left(3780 r^{4} - 4785 r^{3} + 2240 r^{2} - 429 r + 22\right) & \frac{7 r}{3} \left(1575 r^{3} - 1070 r^{2} + 240 r - 16\right) & 35 r \left(6 r - 1\right) \left(7 r - 1\right) & 14 r \left(21 r - 2\right) & 28 r & 1\end{matrix}\right]$$

In [18]:
S2_power.rhs[:,0]


Out[18]:
$$\left[\begin{matrix}1\\r\\\frac{r}{2} \left(3 r - 1\right)\\\frac{r}{2} \left(6 r^{2} - 5 r + 1\right)\\\frac{r}{6} \left(45 r^{3} - 65 r^{2} + 30 r - 4\right)\\\frac{r}{24} \left(540 r^{4} - 1155 r^{3} + 890 r^{2} - 273 r + 22\right)\\\frac{r}{24} \left(1890 r^{5} - 5481 r^{4} + 6125 r^{3} - 3129 r^{2} + 637 r - 18\right)\\\frac{r}{12} \left(3780 r^{6} - 14049 r^{5} + 21014 r^{4} - 15540 r^{3} + 5474 r^{2} - 645 r - 22\right)\end{matrix}\right]$$

In [19]:
assert (S2.rhs**r).applyfunc(simplify) == S2_power.rhs

In [20]:
inspect(S2_power.rhs)


Out[20]:
nature(is_ordinary=False, is_exponential=True)

In [21]:
production_matrix(S2_power.rhs).applyfunc(factor)


Out[21]:
$$\left[\begin{matrix}r & 1 & 0 & 0 & 0 & 0 & 0\\\frac{r}{2} \left(r - 1\right) & 2 r & 1 & 0 & 0 & 0 & 0\\- \frac{r}{2} \left(r - 1\right) & \frac{3 r}{2} \left(r - 1\right) & 3 r & 1 & 0 & 0 & 0\\\frac{r}{6} \left(r - 1\right) \left(r + 4\right) & - 2 r \left(r - 1\right) & 3 r \left(r - 1\right) & 4 r & 1 & 0 & 0\\- \frac{r}{24} \left(r - 1\right) \left(5 r^{2} + 15 r + 22\right) & \frac{5 r}{6} \left(r - 1\right) \left(r + 4\right) & - 5 r \left(r - 1\right) & 5 r \left(r - 1\right) & 5 r & 1 & 0\\\frac{r}{24} \left(r - 1\right) \left(9 r^{3} + 34 r^{2} + 31 r + 18\right) & - \frac{r}{4} \left(r - 1\right) \left(5 r^{2} + 15 r + 22\right) & \frac{5 r}{2} \left(r - 1\right) \left(r + 4\right) & - 10 r \left(r - 1\right) & \frac{15 r}{2} \left(r - 1\right) & 6 r & 1\\- \frac{r}{24} \left(r - 1\right) \left(21 r^{4} + 98 r^{3} + 105 r^{2} - 28 r - 44\right) & \frac{7 r}{24} \left(r - 1\right) \left(9 r^{3} + 34 r^{2} + 31 r + 18\right) & - \frac{7 r}{8} \left(r - 1\right) \left(5 r^{2} + 15 r + 22\right) & \frac{35 r}{6} \left(r - 1\right) \left(r + 4\right) & - \frac{35 r}{2} \left(r - 1\right) & \frac{21 r}{2} \left(r - 1\right) & 7 r\end{matrix}\right]$$

inverse function


In [22]:
f_inverse, g_inverse, G_inverse = functions_catalog.inverse(eigendata, Phi_polynomials)

In [23]:
S2_inverse = G_inverse(S2)
S2_inverse, G_inverse(S2_inverse)


Out[23]:
$$\left ( \operatorname{I_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\-1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\2 & -3 & 1 & 0 & 0 & 0 & 0 & 0\\-6 & 11 & -6 & 1 & 0 & 0 & 0 & 0\\24 & -50 & 35 & -10 & 1 & 0 & 0 & 0\\-120 & 274 & -225 & 85 & -15 & 1 & 0 & 0\\720 & -1764 & 1624 & -735 & 175 & -21 & 1 & 0\\-5040 & 13068 & -13132 & 6769 & -1960 & 322 & -28 & 1\end{matrix}\right], \quad \operatorname{I_{ 8 }}{\left (\operatorname{I_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} \right )} = \left[\begin{matrix}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 & 0\\1 & 127 & 966 & 1701 & 1050 & 266 & 28 & 1\end{matrix}\right]\right )$$

In [24]:
inspect(S2_inverse.rhs)


Out[24]:
nature(is_ordinary=False, is_exponential=True)

In [25]:
production_matrix(S2_inverse.rhs)


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

In [26]:
assert S2_inverse.rhs*S2.rhs == Matrix(m, m, identity_matrix())
assert S2_inverse.rhs == S2_power.rhs.subs({r:-1})

sqrt function


In [27]:
f_sqrt, g_sqrt, G_sqrt = functions_catalog.square_root(eigendata, Phi_polynomials)

In [28]:
S2_sqrt = G_sqrt(S2)
S2_sqrt


Out[28]:
$$\operatorname{R_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{2} & 1 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{8} & \frac{3}{2} & 1 & 0 & 0 & 0 & 0 & 0\\0 & \frac{5}{4} & 3 & 1 & 0 & 0 & 0 & 0\\\frac{1}{32} & \frac{5}{8} & 5 & 5 & 1 & 0 & 0 & 0\\- \frac{7}{128} & \frac{11}{32} & \frac{45}{8} & \frac{55}{4} & \frac{15}{2} & 1 & 0 & 0\\\frac{1}{128} & - \frac{7}{128} & \frac{161}{32} & \frac{105}{4} & \frac{245}{8} & \frac{21}{2} & 1 & 0\\\frac{159}{256} & - \frac{31}{64} & \frac{105}{32} & \frac{623}{16} & \frac{175}{2} & \frac{119}{2} & 14 & 1\end{matrix}\right]$$

In [29]:
inspect(S2_sqrt.rhs)


Out[29]:
nature(is_ordinary=False, is_exponential=True)

In [30]:
production_matrix(S2_sqrt.rhs)


Out[30]:
$$\left[\begin{matrix}\frac{1}{2} & 1 & 0 & 0 & 0 & 0 & 0\\- \frac{1}{8} & 1 & 1 & 0 & 0 & 0 & 0\\\frac{1}{8} & - \frac{3}{8} & \frac{3}{2} & 1 & 0 & 0 & 0\\- \frac{3}{16} & \frac{1}{2} & - \frac{3}{4} & 2 & 1 & 0 & 0\\\frac{41}{128} & - \frac{15}{16} & \frac{5}{4} & - \frac{5}{4} & \frac{5}{2} & 1 & 0\\- \frac{115}{256} & \frac{123}{64} & - \frac{45}{16} & \frac{5}{2} & - \frac{15}{8} & 3 & 1\\- \frac{97}{512} & - \frac{805}{256} & \frac{861}{128} & - \frac{105}{16} & \frac{35}{8} & - \frac{21}{8} & \frac{7}{2}\end{matrix}\right]$$

In [40]:
inspect(S2_sqrt.rhs)


Out[40]:
nature(is_ordinary=False, is_exponential=True)

In [33]:
production_matrix(S2_sqrt.rhs, exp=False)


Out[33]:
$$\left[\begin{matrix}\frac{1}{2} & 1 & 0 & 0 & 0 & 0 & 0\\- \frac{1}{8} & 1 & 1 & 0 & 0 & 0 & 0\\\frac{1}{8} & - \frac{3}{8} & \frac{3}{2} & 1 & 0 & 0 & 0\\- \frac{3}{16} & \frac{1}{2} & - \frac{3}{4} & 2 & 1 & 0 & 0\\\frac{41}{128} & - \frac{15}{16} & \frac{5}{4} & - \frac{5}{4} & \frac{5}{2} & 1 & 0\\- \frac{115}{256} & \frac{123}{64} & - \frac{45}{16} & \frac{5}{2} & - \frac{15}{8} & 3 & 1\\- \frac{97}{512} & - \frac{805}{256} & \frac{861}{128} & - \frac{105}{16} & \frac{35}{8} & - \frac{21}{8} & \frac{7}{2}\end{matrix}\right]$$

In [34]:
assert S2_sqrt.rhs == S2.rhs**(S(1)/2)
assert S2_sqrt.rhs == S2_power.rhs.subs({r:S(1)/2})

expt function


In [35]:
f_exp, g_exp, G_exp = functions_catalog.exp(eigendata, Phi_polynomials)

In [36]:
S2_exp = G_exp(S2)
S2_exp


Out[36]:
$$\operatorname{E_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}e^{\alpha} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0 & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{2} \left(3 \alpha + 2\right) & 3 \alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{2} \left(6 \alpha^{2} + 13 \alpha + 2\right) & \alpha \left(9 \alpha + 7\right) e^{\alpha} & 6 \alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{6} \left(45 \alpha^{3} + 205 \alpha^{2} + 150 \alpha + 6\right) & \frac{5 \alpha}{2} \left(12 \alpha^{2} + 29 \alpha + 6\right) e^{\alpha} & 5 \alpha \left(6 \alpha + 5\right) e^{\alpha} & 10 \alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{24} \left(540 \alpha^{4} + 4245 \alpha^{3} + 7460 \alpha^{2} + 2412 \alpha + 24\right) & \frac{\alpha e^{\alpha}}{2} \left(225 \alpha^{3} + 1115 \alpha^{2} + 950 \alpha + 62\right) & \frac{15 \alpha}{2} \left(20 \alpha^{2} + 51 \alpha + 12\right) e^{\alpha} & 5 \alpha \left(15 \alpha + 13\right) e^{\alpha} & 15 \alpha e^{\alpha} & e^{\alpha} & 0 & 0\\\frac{\alpha e^{\alpha}}{24} \left(1890 \alpha^{5} + 22869 \alpha^{4} + 74165 \alpha^{3} + 66696 \alpha^{2} + 10500 \alpha + 24\right) & \frac{7 \alpha}{24} \left(1620 \alpha^{4} + 13635 \alpha^{3} + 26600 \alpha^{2} + 10464 \alpha + 216\right) e^{\alpha} & \frac{7 \alpha}{2} \left(225 \alpha^{3} + 1165 \alpha^{2} + 1070 \alpha + 86\right) e^{\alpha} & \frac{35 \alpha}{2} \left(30 \alpha^{2} + 79 \alpha + 20\right) e^{\alpha} & \frac{35 \alpha}{2} \left(9 \alpha + 8\right) e^{\alpha} & 21 \alpha e^{\alpha} & e^{\alpha} & 0\\\frac{\alpha e^{\alpha}}{12} \left(3780 \alpha^{6} + 65331 \alpha^{5} + 339479 \alpha^{4} + 604415 \alpha^{3} + 310954 \alpha^{2} + 24828 \alpha + 12\right) & \frac{\alpha e^{\alpha}}{12} \left(26460 \alpha^{5} + 339066 \alpha^{4} + 1191085 \alpha^{3} + 1212960 \alpha^{2} + 243390 \alpha + 1524\right) & \frac{7 \alpha}{6} \left(3780 \alpha^{4} + 33015 \alpha^{3} + 68030 \alpha^{2} + 29496 \alpha + 828\right) e^{\alpha} & \frac{7 \alpha}{3} \left(1575 \alpha^{3} + 8380 \alpha^{2} + 8055 \alpha + 729\right) e^{\alpha} & 35 \alpha \left(42 \alpha^{2} + 113 \alpha + 30\right) e^{\alpha} & 14 \alpha \left(21 \alpha + 19\right) e^{\alpha} & 28 \alpha e^{\alpha} & e^{\alpha}\end{matrix}\right]$$

In [37]:
define(S2_exp.lhs, S2_exp.rhs.applyfunc(factor))


Out[37]:
$$\operatorname{E_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}e^{\alpha} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0 & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{2} \left(3 \alpha + 2\right) & 3 \alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{2} \left(\alpha + 2\right) \left(6 \alpha + 1\right) & \alpha \left(9 \alpha + 7\right) e^{\alpha} & 6 \alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{6} \left(45 \alpha^{3} + 205 \alpha^{2} + 150 \alpha + 6\right) & \frac{5 \alpha}{2} \left(12 \alpha^{2} + 29 \alpha + 6\right) e^{\alpha} & 5 \alpha \left(6 \alpha + 5\right) e^{\alpha} & 10 \alpha e^{\alpha} & e^{\alpha} & 0 & 0 & 0\\\frac{\alpha e^{\alpha}}{24} \left(540 \alpha^{4} + 4245 \alpha^{3} + 7460 \alpha^{2} + 2412 \alpha + 24\right) & \frac{\alpha e^{\alpha}}{2} \left(225 \alpha^{3} + 1115 \alpha^{2} + 950 \alpha + 62\right) & \frac{15 \alpha}{2} \left(20 \alpha^{2} + 51 \alpha + 12\right) e^{\alpha} & 5 \alpha \left(15 \alpha + 13\right) e^{\alpha} & 15 \alpha e^{\alpha} & e^{\alpha} & 0 & 0\\\frac{\alpha e^{\alpha}}{24} \left(1890 \alpha^{5} + 22869 \alpha^{4} + 74165 \alpha^{3} + 66696 \alpha^{2} + 10500 \alpha + 24\right) & \frac{7 \alpha}{24} \left(1620 \alpha^{4} + 13635 \alpha^{3} + 26600 \alpha^{2} + 10464 \alpha + 216\right) e^{\alpha} & \frac{7 \alpha}{2} \left(225 \alpha^{3} + 1165 \alpha^{2} + 1070 \alpha + 86\right) e^{\alpha} & \frac{35 \alpha}{2} \left(30 \alpha^{2} + 79 \alpha + 20\right) e^{\alpha} & \frac{35 \alpha}{2} \left(9 \alpha + 8\right) e^{\alpha} & 21 \alpha e^{\alpha} & e^{\alpha} & 0\\\frac{\alpha e^{\alpha}}{12} \left(3780 \alpha^{6} + 65331 \alpha^{5} + 339479 \alpha^{4} + 604415 \alpha^{3} + 310954 \alpha^{2} + 24828 \alpha + 12\right) & \frac{\alpha e^{\alpha}}{12} \left(26460 \alpha^{5} + 339066 \alpha^{4} + 1191085 \alpha^{3} + 1212960 \alpha^{2} + 243390 \alpha + 1524\right) & \frac{7 \alpha}{6} \left(3780 \alpha^{4} + 33015 \alpha^{3} + 68030 \alpha^{2} + 29496 \alpha + 828\right) e^{\alpha} & \frac{7 \alpha}{3} \left(1575 \alpha^{3} + 8380 \alpha^{2} + 8055 \alpha + 729\right) e^{\alpha} & 35 \alpha \left(42 \alpha^{2} + 113 \alpha + 30\right) e^{\alpha} & 14 \alpha \left(21 \alpha + 19\right) e^{\alpha} & 28 \alpha e^{\alpha} & e^{\alpha}\end{matrix}\right]$$

In [38]:
S2_exp1 = define(let=Subs(S2_exp.lhs, alpha, 1), be=S2_exp.rhs.subs({alpha:1}))
S2_exp1


Out[38]:
$$\left. \operatorname{E_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} \right|_{\substack{ \alpha=1 }} = \left[\begin{matrix}e & 0 & 0 & 0 & 0 & 0 & 0 & 0\\e & e & 0 & 0 & 0 & 0 & 0 & 0\\\frac{5 e}{2} & 3 e & e & 0 & 0 & 0 & 0 & 0\\\frac{21 e}{2} & 16 e & 6 e & e & 0 & 0 & 0 & 0\\\frac{203 e}{3} & \frac{235 e}{2} & 55 e & 10 e & e & 0 & 0 & 0\\\frac{14681 e}{24} & 1176 e & \frac{1245 e}{2} & 140 e & 15 e & e & 0 & 0\\\frac{22018 e}{3} & \frac{367745 e}{24} & 8911 e & \frac{4515 e}{2} & \frac{595 e}{2} & 21 e & e & 0\\\frac{1348799 e}{12} & \frac{3014485 e}{12} & \frac{946043 e}{6} & \frac{131173 e}{3} & 6475 e & 560 e & 28 e & e\end{matrix}\right]$$

In [39]:
inspect(S2_exp.rhs)


Out[39]:
nature(is_ordinary=False, is_exponential=False)

In [40]:
inspect(S2_exp1.rhs)


Out[40]:
nature(is_ordinary=False, is_exponential=False)

log function


In [41]:
f_log, g_log, G_log = functions_catalog.log(eigendata, Phi_polynomials)

In [42]:
S2_log = G_log(S2)
S2_log


Out[42]:
$$\operatorname{L_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\- \frac{1}{2} & 3 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{2} & -2 & 6 & 0 & 0 & 0 & 0 & 0\\- \frac{2}{3} & \frac{5}{2} & -5 & 10 & 0 & 0 & 0 & 0\\\frac{11}{12} & -4 & \frac{15}{2} & -10 & 15 & 0 & 0 & 0\\- \frac{3}{4} & \frac{77}{12} & -14 & \frac{35}{2} & - \frac{35}{2} & 21 & 0 & 0\\- \frac{11}{6} & -6 & \frac{77}{3} & - \frac{112}{3} & 35 & -28 & 28 & 0\end{matrix}\right]$$

In [43]:
inspect(S2_log.rhs[1:,:-1])


Out[43]:
nature(is_ordinary=False, is_exponential=True)

In [44]:
production_matrix(S2_log.rhs[1:,:-1])


Out[44]:
$$\left[\begin{matrix}- \frac{1}{2} & 3 & 0 & 0 & 0 & 0\\\frac{1}{12} & - \frac{1}{6} & 2 & 0 & 0 & 0\\- \frac{1}{24} & \frac{1}{9} & - \frac{1}{6} & \frac{5}{3} & 0 & 0\\\frac{1}{60} & - \frac{37}{360} & \frac{1}{6} & - \frac{1}{6} & \frac{3}{2} & 0\\\frac{5}{144} & \frac{41}{540} & - \frac{37}{180} & \frac{2}{9} & - \frac{1}{6} & \frac{7}{5}\\- \frac{289}{2016} & \frac{865}{9072} & \frac{41}{216} & - \frac{37}{108} & \frac{5}{18} & - \frac{1}{6}\end{matrix}\right]$$

sin function


In [45]:
f_sin, g_sin, G_sin = functions_catalog.sin(eigendata, Phi_polynomials)

In [46]:
S2_sin = G_sin(S2)    
S2_sin


Out[46]:
$$\operatorname{S_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}\sin{\left (1 \right )} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\cos{\left (1 \right )} & \sin{\left (1 \right )} & 0 & 0 & 0 & 0 & 0 & 0\\- \frac{3}{2} \sin{\left (1 \right )} + \cos{\left (1 \right )} & 3 \cos{\left (1 \right )} & \sin{\left (1 \right )} & 0 & 0 & 0 & 0 & 0\\- \frac{13}{2} \sin{\left (1 \right )} - 2 \cos{\left (1 \right )} & - 9 \sin{\left (1 \right )} + 7 \cos{\left (1 \right )} & 6 \cos{\left (1 \right )} & \sin{\left (1 \right )} & 0 & 0 & 0 & 0\\- \frac{199}{6} \cos{\left (1 \right )} - \frac{35}{2} \sin{\left (1 \right )} & - \frac{145}{2} \sin{\left (1 \right )} - 15 \cos{\left (1 \right )} & - 30 \sin{\left (1 \right )} + 25 \cos{\left (1 \right )} & 10 \cos{\left (1 \right )} & \sin{\left (1 \right )} & 0 & 0 & 0\\- \frac{862}{3} \cos{\left (1 \right )} + \frac{611}{8} \sin{\left (1 \right )} & - \frac{725}{2} \sin{\left (1 \right )} - \frac{1053}{2} \cos{\left (1 \right )} & - \frac{765}{2} \sin{\left (1 \right )} - 60 \cos{\left (1 \right )} & - 75 \sin{\left (1 \right )} + 65 \cos{\left (1 \right )} & 15 \cos{\left (1 \right )} & \sin{\left (1 \right )} & 0 & 0\\- \frac{14601}{8} \cos{\left (1 \right )} + \frac{61775}{24} \sin{\left (1 \right )} & - \frac{43337}{6} \cos{\left (1 \right )} + \frac{7399}{8} \sin{\left (1 \right )} & - \frac{5915}{2} \sin{\left (1 \right )} - \frac{7553}{2} \cos{\left (1 \right )} & - \frac{2765}{2} \sin{\left (1 \right )} - 175 \cos{\left (1 \right )} & - \frac{315}{2} \sin{\left (1 \right )} + 140 \cos{\left (1 \right )} & 21 \cos{\left (1 \right )} & \sin{\left (1 \right )} & 0\\\frac{24757}{12} \cos{\left (1 \right )} + \frac{128564}{3} \sin{\left (1 \right )} & - \frac{145395}{2} \cos{\left (1 \right )} + \frac{921235}{12} \sin{\left (1 \right )} & - \frac{221977}{3} \cos{\left (1 \right )} + \frac{8211}{2} \sin{\left (1 \right )} & - 15120 \sin{\left (1 \right )} - \frac{53557}{3} \cos{\left (1 \right )} & - 3955 \sin{\left (1 \right )} - 420 \cos{\left (1 \right )} & - 294 \sin{\left (1 \right )} + 266 \cos{\left (1 \right )} & 28 \cos{\left (1 \right )} & \sin{\left (1 \right )}\end{matrix}\right]$$

cos function


In [47]:
f_cos, g_cos, G_cos = functions_catalog.cos(eigendata, Phi_polynomials)

In [48]:
S2_cos = G_cos(S2)    
S2_cos


Out[48]:
$$\operatorname{C_{ 8 }}{\left (\mathcal{S}_{ 8 } \right )} = \left[\begin{matrix}\cos{\left (1 \right )} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\- \sin{\left (1 \right )} & \cos{\left (1 \right )} & 0 & 0 & 0 & 0 & 0 & 0\\- \sin{\left (1 \right )} - \frac{3}{2} \cos{\left (1 \right )} & - 3 \sin{\left (1 \right )} & \cos{\left (1 \right )} & 0 & 0 & 0 & 0 & 0\\- \frac{13}{2} \cos{\left (1 \right )} + 2 \sin{\left (1 \right )} & - 7 \sin{\left (1 \right )} - 9 \cos{\left (1 \right )} & - 6 \sin{\left (1 \right )} & \cos{\left (1 \right )} & 0 & 0 & 0 & 0\\- \frac{35}{2} \cos{\left (1 \right )} + \frac{199}{6} \sin{\left (1 \right )} & - \frac{145}{2} \cos{\left (1 \right )} + 15 \sin{\left (1 \right )} & - 25 \sin{\left (1 \right )} - 30 \cos{\left (1 \right )} & - 10 \sin{\left (1 \right )} & \cos{\left (1 \right )} & 0 & 0 & 0\\\frac{611}{8} \cos{\left (1 \right )} + \frac{862}{3} \sin{\left (1 \right )} & - \frac{725}{2} \cos{\left (1 \right )} + \frac{1053}{2} \sin{\left (1 \right )} & - \frac{765}{2} \cos{\left (1 \right )} + 60 \sin{\left (1 \right )} & - 65 \sin{\left (1 \right )} - 75 \cos{\left (1 \right )} & - 15 \sin{\left (1 \right )} & \cos{\left (1 \right )} & 0 & 0\\\frac{61775}{24} \cos{\left (1 \right )} + \frac{14601}{8} \sin{\left (1 \right )} & \frac{7399}{8} \cos{\left (1 \right )} + \frac{43337}{6} \sin{\left (1 \right )} & - \frac{5915}{2} \cos{\left (1 \right )} + \frac{7553}{2} \sin{\left (1 \right )} & - \frac{2765}{2} \cos{\left (1 \right )} + 175 \sin{\left (1 \right )} & - 140 \sin{\left (1 \right )} - \frac{315}{2} \cos{\left (1 \right )} & - 21 \sin{\left (1 \right )} & \cos{\left (1 \right )} & 0\\- \frac{24757}{12} \sin{\left (1 \right )} + \frac{128564}{3} \cos{\left (1 \right )} & \frac{921235}{12} \cos{\left (1 \right )} + \frac{145395}{2} \sin{\left (1 \right )} & \frac{8211}{2} \cos{\left (1 \right )} + \frac{221977}{3} \sin{\left (1 \right )} & - 15120 \cos{\left (1 \right )} + \frac{53557}{3} \sin{\left (1 \right )} & - 3955 \cos{\left (1 \right )} + 420 \sin{\left (1 \right )} & - 266 \sin{\left (1 \right )} - 294 \cos{\left (1 \right )} & - 28 \sin{\left (1 \right )} & \cos{\left (1 \right )}\end{matrix}\right]$$

In [49]:
assert (S2_sin.rhs**2 + S2_cos.rhs**2).applyfunc(trigsimp) == Matrix(m, m, identity_matrix())