Thanks again for the suggestion. I developed a function that reproduces the Chebysev polynomials as functions:
function Chebyshev_polynomial_mpo(sites, H::MPO, BondDimension::Int, MinBondDimension::Int, precision::Number, order::Int)
T_list = Vector{Function}(undef, order + 1) # Create an empty list of functions
os_I = OpSum()
os_I += "Id", 1
I = MPO(os_I, sites)
T_list[1] = x -> truncate!(I; maxdim=BondDimension, mindim=MinBondDimension, cutoff=precision) # T_0(x) = I
T_list[2] = x -> truncate!(H; maxdim=BondDimension, mindim=MinBondDimension, cutoff=precision) # T_1(x) = H
for k in 2:order
T_list[k + 1] = x -> truncate!(2 * apply(T_list[k](x), H; maxdim=BondDimension, cutoff=precision) - T_list[k - 1](x); maxdim=BondDimension, mindim= MinBondDimension, cutoff=precision)
end
return T_list
end
and it works without giving error if applied to H, (an MPO represntation of the LR Ising chain). If I print the function applied to H I obtain the following:
julia> Chebyshev_polynomial_mpo(sites, H, 10, 10, 1e-6, 5)[6](H)
MPO
[1] ((dim=2|id=745|"S=1/2,Site,n=1")', (dim=2|id=745|"S=1/2,Site,n=1"), (dim=4|id=245|"Link,l=1"))
[2] ((dim=2|id=454|"S=1/2,Site,n=2")', (dim=2|id=454|"S=1/2,Site,n=2"), (dim=4|id=17|"Link,l=2"), (dim=4|id=245|"Link,l=1"))
[3] ((dim=2|id=110|"S=1/2,Site,n=3")', (dim=2|id=110|"S=1/2,Site,n=3"), (dim=4|id=17|"Link,l=2"))
julia> Chebyshev_polynomial_mpo(sites, H, 10, 10, 1e-6, 5)[5](H)
MPO
[1] ((dim=2|id=745|"S=1/2,Site,n=1")', (dim=2|id=745|"S=1/2,Site,n=1"), (dim=4|id=631|"Link,l=1"))
[2] ((dim=2|id=454|"S=1/2,Site,n=2")', (dim=2|id=454|"S=1/2,Site,n=2"), (dim=4|id=94|"Link,l=2"), (dim=4|id=631|"Link,l=1"))
[3] ((dim=2|id=110|"S=1/2,Site,n=3")', (dim=2|id=110|"S=1/2,Site,n=3"), (dim=4|id=94|"Link,l=2"))
julia> Chebyshev_polynomial_mpo(sites, H, 10, 10, 1e-6, 5)[4](H)
MPO
[1] ((dim=2|id=745|"S=1/2,Site,n=1")', (dim=2|id=745|"S=1/2,Site,n=1"), (dim=4|id=310|"Link,l=1"))
[2] ((dim=2|id=454|"S=1/2,Site,n=2")', (dim=2|id=454|"S=1/2,Site,n=2"), (dim=4|id=451|"Link,l=2"), (dim=4|id=310|"Link,l=1"))
[3] ((dim=2|id=110|"S=1/2,Site,n=3")', (dim=2|id=110|"S=1/2,Site,n=3"), (dim=4|id=451|"Link,l=2"))
julia> Chebyshev_polynomial_mpo(sites, H, 10, 10, 1e-6, 5)[3](H)
MPO
[1] ((dim=2|id=745|"S=1/2,Site,n=1")', (dim=2|id=745|"S=1/2,Site,n=1"), (dim=4|id=501|"Link,l=1"))
[2] ((dim=2|id=454|"S=1/2,Site,n=2")', (dim=2|id=454|"S=1/2,Site,n=2"), (dim=3|id=320|"Link,l=2"), (dim=4|id=501|"Link,l=1"))
[3] ((dim=2|id=110|"S=1/2,Site,n=3")', (dim=2|id=110|"S=1/2,Site,n=3"), (dim=3|id=320|"Link,l=2"))
julia> Chebyshev_polynomial_mpo(sites, H, 10, 10, 1e-6, 5)[2](H)
MPO
[1] ((dim=2|id=745|"S=1/2,Site,n=1")', (dim=2|id=745|"S=1/2,Site,n=1"), (dim=4|id=44|"Link,l=1"))
[2] ((dim=2|id=454|"S=1/2,Site,n=2")', (dim=2|id=454|"S=1/2,Site,n=2"), (dim=4|id=846|"Link,l=2"), (dim=4|id=44|"Link,l=1"))
[3] ((dim=2|id=110|"S=1/2,Site,n=3")', (dim=2|id=110|"S=1/2,Site,n=3"), (dim=4|id=846|"Link,l=2"))
julia> Chebyshev_polynomial_mpo(sites, H, 10, 10, 1e-6, 5)[1](H)
MPO
[1] ((dim=2|id=745|"S=1/2,Site,n=1")', (dim=2|id=745|"S=1/2,Site,n=1"), (dim=2|id=464|"Link,l=1"))
[2] ((dim=2|id=454|"S=1/2,Site,n=2")', (dim=2|id=454|"S=1/2,Site,n=2"), (dim=2|id=747|"Link,l=2"), (dim=2|id=464|"Link,l=1"))
[3] ((dim=2|id=110|"S=1/2,Site,n=3")', (dim=2|id=110|"S=1/2,Site,n=3"), (dim=2|id=747|"Link,l=2"))
Here comes my question: If the link indices are of different dimension depending on the order, how it is possible that the sum operation performs correctly? What is the code doing that I am missing?
Thanks again for the help, I really appreciate it!