# why can't I exponantiate this ?

+1 vote

Hey all!
Maybe someone can tell me waht is the problem in my code here with the expo ?
using ITensors
N=8
s= siteinds("S=1/2",N)
J=randn(N,N)
cutoff = 1E-8
tau = 0.1
ttotal = 5.0

## Compute the number of steps to do

Nsteps = Int(ttotal/tau)
gates= ITensor[] #creating an empty array for Trotter gate

for i=1:N-1
for j=2:N
hj= op("Sz",s[i])op("Sz",s[j])
Gj = exp(-1.0im
tau/2*hj)
push!(gates,Gj)
end
end

commented by (62.7k points)
What is the error you are getting? Does the answer by JR below solve your problem?

edited by

The code "Gj = exp(-1.0imtau/2*hj) " should be replaced by "Gj = exp(-1.0im*tau/2*hj)" .

the apply function can handle non-nearest-neighbor gates, I am not sure that Trotter gates cannot deal with long-range interactions in the versions of ITensor?

commented by (62.7k points)
Thanks for answering. Yes, in the Julia version of ITensor, which is what tsegev appears to be using, the apply function can accept gates acting on any sites i and j no matter how far apart they are.
commented by (450 points)
edited by
Thanks for your reply!  This looks very good.  Like  the method TDVP or Time Evolving an MPS with an MPO, we can use apply function handle with time evolution of a system with next-nearest-neighbor or long-range interactions.
commented by (62.7k points)
Yes, that is true and it's a very useful feature of ITensor.

One caution though: while Trotter gates are excellent for short range Hamiltonians or Hamiltonians with further-neighbor terms, for truly long-range Hamiltonians where there is a non-zero interaction connecting every pair of sites (so N^2 interactions in total for N sites), then it can be much more efficient to use a technique based on MPOs, such as the TDVP technique. So I would definitely recommend TDVP for truly long-range Hamiltonians or cases like quasi-2d systems.

Best regards,
Miles