In [1]:
    
from sympy import *
from sympy.abc import n, i, N, x, lamda, phi, z, j, r, k, a, alpha, beta
from commons import *
from matrix_functions import *
from sequences import *
import functions_catalog
init_printing()
    
In [2]:
    
d,h = IndexedBase('d'), IndexedBase('h')
alpha, beta, gamma = symbols(r'\alpha \beta \gamma')
    
In [3]:
    
m = 16
H = define(Symbol(r'\mathcal{{H}}_{{ {} }}'.format(m)), 
           Matrix(m, m, lambda n, k: 0 if n==m/2 or n!=k+1 else -h[-(k-(m/S(2))+2)] if n<m/2 else h[k-(m/S(2))]))
H
    
    Out[3]:
In [4]:
    
f = Function('E')
f_expt = define(let=f(z), be=exp(z))
f_expt
    
    Out[4]:
In [5]:
    
eigendata = spectrum(H)
eigendata
    
    Out[5]:
In [6]:
    
data, eigenvals, multiplicities = eigendata.rhs
    
In [7]:
    
Phi_polynomials = component_polynomials(eigendata, early_eigenvals_subs=True)
Phi_polynomials
    
    Out[7]:
In [8]:
    
g_expt = Hermite_interpolation_polynomial(f_expt, eigendata, Phi_polynomials)
#g_expt
    
In [9]:
    
g_expt = g_expt.subs(eigenvals)
g_expt
    
    Out[9]:
In [10]:
    
with lift_to_matrix_function(g_expt) as G_expt:
    H_expt = G_expt(H)
H_expt
    
    Out[10]:
In [11]:
    
production_matrix(H_expt.rhs[7:,7:])
    
    Out[11]:
In [12]:
    
H_expt.rhs.subs({h[0]:1,h[1]:1,h[2]:1, h[3]:1,h[4]:1,h[5]:1,h[6]:1})
    
    Out[12]:
In [13]:
    
H_expt.rhs.subs({h[0]:1,h[1]:2,h[2]:3, h[3]:4,h[4]:5,h[5]:6,h[6]:7})
    
    Out[13]:
In [14]:
    
H_expt.rhs.subs({h[0]:1,h[1]:1,h[2]:2, h[3]:3,h[4]:5,h[5]:8,h[6]:13})
    
    Out[14]:
In [15]:
    
H_expt.rhs.subs({h[0]:1,h[1]:1,h[2]:2, h[3]:5,h[4]:14,h[5]:42})
    
    Out[15]:
In [16]:
    
H_expt.rhs.subs({h[0]:factorial(0),h[1]:factorial(1),h[2]:factorial(2), 
                 h[3]:factorial(3),h[4]:factorial(4), h[5]:factorial(5), 
                 h[6]:factorial(6)})
    
    Out[16]:
In [17]:
    
H_expt.rhs.subs({h[0]:2**0,h[1]:2**1,h[2]:2**2, h[3]:2**3,h[4]:2**4,h[5]:2**5,h[6]:2**6})
    
    Out[17]:
In [18]:
    
H_expt.rhs.subs({h[0]:1,h[1]:3,h[2]:6, h[3]:10,h[4]:15,h[5]:21,h[6]:28})
    
    Out[18]:
In [19]:
    
m = 16
H = define(Symbol(r'\mathcal{{H}}_{{ {} }}'.format(m)), 
           Matrix(m, m, lambda n, k: 0 if n==m/2 or n!=k+2 else -h[-(k-(m/S(2))+3)] if n<m/2 else h[k-(m/S(2))+1]))
H
    
    Out[19]:
In [20]:
    
f = Function('E')
f_expt = define(let=f(z), be=exp(z))
f_expt
    
    Out[20]:
In [21]:
    
eigendata = spectrum(H)
eigendata
    
    Out[21]:
In [22]:
    
data, eigenvals, multiplicities = eigendata.rhs
    
In [23]:
    
Phi_polynomials = component_polynomials(eigendata, early_eigenvals_subs=True)
Phi_polynomials
    
    Out[23]:
In [24]:
    
g_expt = Hermite_interpolation_polynomial(f_expt, eigendata, Phi_polynomials)
#g_expt
    
In [25]:
    
g_expt = g_expt.subs(eigenvals)
g_expt
    
    Out[25]:
In [26]:
    
with lift_to_matrix_function(g_expt) as G_expt:
    H_expt = G_expt(H)
H_expt
    
    Out[26]:
In [27]:
    
H_expt.rhs.subs({h[0]:1,h[1]:2,h[2]:3, h[3]:4,h[4]:5,h[5]:6,h[6]:7})
    
    Out[27]:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.