Hi,
I’m new to ITensors and the entire field of MPS and tensor networks, so I might be missing something fundamental.
I’m trying to write code that simulates quantum gates, but when I attempt to initialize an entangled state, the results are not as expected. I referred to this discussion: MPS Initialization Through State Vector and wrote the following code:
N = 2
A = normalize([1, 1, 0, 0])
sites = siteinds("Qubit",N)
m = MPS(A, sites)
gates_mpo = ops(sites, [("H", 1)])
ψ = apply(gates_mpo, m)
After applying the gate, I used the sample
function multiple times (or a custom function based on the example here MPS and MPO Examples · ITensors.jl that returns the amplitude vector). However, the results were always limited to the state [1,1]
, or the amplitude vector:
4-element Vector{ComplexF64}:
0.9999999999999998 + 0.0im
0.0 + 0.0im
0.0 + 0.0im
0.0 + 0.0im
This does not match the expected outcome. It seems as though the Hadamard gate was applied to the second qubit instead of the first.
However, when I replaced A with a computational basis vector, such as [1, 0, 0, 0]
, the result was as expected:
4-element Vector{ComplexF64}:
0.7071067811865475 + 0.0im
0.0 + 0.0im
0.7071067811865475 + 0.0im
0.0 + 0.0im
I tried constructing the MPS as a sum of computational basis MPS states, weighted by their corresponding amplitudes. This approach worked, but I’m concerned that it might not be efficient in terms of runtime.
I would appreciate any insights into why this happens. Thanks!