+1 vote
asked by (300 points)

Given an initial state written, in the full Hilber Space, as

|\psi\rangle = \otimes_{j=1}^{L/2}|\leftarrow\rangle \otimes_{j=L/2+1}^L |\rightarrow\rangle,

such that,

\hat{\sigma}_x |\leftarrow\rangle = +|\leftarrow\rangle\

\hat{\sigma}_x |\rightarrow\rangle = -|\rightarrow\rangle.

How can I write it in the form of an MPS?

2 Answers

+2 votes
answered by (680 points)
selected by
Best answer

One way is to set all qubits in this form (left half of the chain spin up, right half with spin down):

SpinHalf sites = SpinHalf(N);

auto init = InitState(sites);
for(auto n : range1(N)) {
    if (n <= N/2) { 
        init.set(n, "Up"); 
    } else { 
        init.set(n, "Dn");
auto psi = MPS(init);

and then applying the Hadamard gate in all the qubits:

for(int n = 1; n <= N; ++n)
    auto ind = sites(n);
    auto indP = prime(sites(n));
    auto Had = ITensor(ind,indP);
    Had.set(ind(1),indP(1), ISqrt2);
    Had.set(ind(1),indP(2), ISqrt2);
    Had.set(ind(2),indP(1), ISqrt2);
    Had.set(ind(2),indP(2), -ISqrt2);

You should get the desired product state.

commented by (300 points)
Thank you very much.
I implemented it, but something strange happened: iIn order to control if the states is the desired one, I calculate @@\langle \hat{sigma}\_x (j) \rangle@@ with @@j=1,2,...,L@@. I obtain the right values from @@[1,L-1]@@, but not for @@L@@, for which @@\langle \sigma\_x(L) \rangle = 0@@.

Does it happen also to you? If you could check it would be great.
commented by (680 points)
I just tested and it work as desired, including the last site. Here is my code:

    for(int j = 1; j <= N; ++j)
    Real Sxj = (psi.A(j)
               * sites.op("Sx",j)
               * dag(prime(psi.A(j),Site))).real();
    println("Sx_",j," = ",Sxj);

and the result for 10 sites:

Sx_1 = 0.5
Sx_2 = 0.5
Sx_3 = 0.5
Sx_4 = 0.5
Sx_5 = 0.5
Sx_6 = -0.5
Sx_7 = -0.5
Sx_8 = -0.5
Sx_9 = -0.5
Sx_10 = -0.5
commented by (300 points)
Okok, it works fine.  Thank you very much!
commented by (310 points)
how can we do the same for julia version?
0 votes
answered by (70.1k points)

Diego's answer is a good one.

Another way to do what you want, setting the tensor elements directly, is to use similar code to what olabaz provides in his question here:

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.