# Measurement of local obervables

**URL:** <https://itensor.discourse.group/t/measurement-of-local-obervables/1090>\
**Category:** ITensor C++ Questions\
**Created:** [August 16, 2023, 8:54am UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090 "2023-08-16T08:54:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vrushali.k](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Post date:** [August 16, 2023, 8:54am UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090/1 "2023-08-16T08:54:21Z")

</div>

Hello,  
I am using heisenberg AFM spin-\frac{1}{2} model. I calculated expectation values of all spin components. I expect \<S^x\_j\>=\<S^y\_j\>=\<S^z\_j\> at j^{th} site.  
Following is the part of code.

```auto
    for(int j = 1; j < N; ++j)
        {
        ampo += 0.5,"S+",j,"S-",j+1;
        ampo += 0.5,"S-",j,"S+",j+1;
        ampo += "Sz",j,"Sz",j+1;
        }
    auto H = toMPO(ampo);
    auto psi0 = randomMPS(sites);

    auto [energy,psi] = dmrg(H,psi0,sweeps);

```

```auto
    psi.position(j);

        auto ket = psi(j);
        auto bra = dag(prime(ket,"Site"));

        auto Sxjop = op(sites,"Sx",j);
        auto Syjop = op(sites,"Sy",j);
        auto Szjop = op(sites,"Sz",j);

        //take an inner product
        auto sxj = eltC(bra*Sxjop*ket);
        auto syj = eltC(bra*Syjop*ket);
        auto szj = eltC(bra*Szjop*ket);

```

output obtained is:

```auto

site sxj syj szj
1 (-0.085879786270,0.000000000000) (0.000000000000,0.000000000000) (0.524500286661,0.000000000000)
2 (0.052269631567,0.000000000000) (0.000000000000,0.000000000000) (-0.317076879182,0.000000000000)
3 (-0.061021765784,0.000000000000) (0.000000000000,-0.000000000000) (0.369026870114,0.000000000000)
4 (0.044076181082,0.000000000000) (0.000000000000,0.000000000000) (-0.263437612825,0.000000000000)
5 (-0.044070844096,0.000000000000) (0.000000000000,-0.000000000000) (0.261660807326,0.000000000000)
6 (0.034740648756,0.000000000000) (0.000000000000,0.000000000000) (-0.201093290816,0.000000000000)
7 (-0.033097508882,0.000000000000) (0.000000000000,-0.000000000000) (0.187972360981,0.000000000000)
8 (0.027798850184,0.000000000000) (0.000000000000,0.000000000000) (-0.151213984075,0.000000000000)
9 (-0.026266199085,0.000000000000) (0.000000000000,0.000000000000) (0.137606259785,0.000000000000)
10 (0.023422322342,0.000000000000) (0.000000000000,0.000000000000) (-0.114767090540,0.000000000000)
11 (-0.022604446358,0.000000000000) (0.000000000000,-0.000000000000) (0.103957656846,0.000000000000)
12 (0.021517400728,0.000000000000) (0.000000000000,-0.000000000000) (-0.089911906053,0.000000000000)
13 (-0.021631676509,0.000000000000) (0.000000000000,-0.000000000000) (0.082492019101,0.000000000000)
14 (0.022014881161,0.000000000000) (0.000000000000,-0.000000000000) (-0.074554770328,0.000000000000)
15 (-0.023165510846,0.000000000000) (0.000000000000,0.000000000000) (0.070475409087,0.000000000000)
16 (0.025001185922,0.000000000000) (0.000000000000,-0.000000000000) (-0.067285420429,0.000000000000)
17 (-0.027319618034,0.000000000000) (0.000000000000,0.000000000000) (0.066398761413,0.000000000000)
18 (0.030833746946,0.000000000000) (0.000000000000,0.000000000000) (-0.067450748744,0.000000000000)
19 (-0.034497740499,0.000000000000) (0.000000000000,0.000000000000) (0.069689182423,0.000000000000)
20 (0.040197909615,0.000000000000) (0.000000000000,0.000000000000) (-0.075191674420,0.000000000000)
21 (-0.045410357418,0.000000000000) (0.000000000000,-0.000000000000) (0.080574504932,0.000000000000)
22 (0.054218627438,0.000000000000) (0.000000000000,-0.000000000000) (-0.091524846115,0.000000000000)
23 (-0.061092524561,0.000000000000) (0.000000000000,-0.000000000000) (0.099997638642,0.000000000000)
24 (0.074637750447,0.000000000000) (0.000000000000,0.000000000000) (-0.118564227015,0.000000000000)
25 (-0.082856408373,0.000000000000) (0.000000000000,-0.000000000000) (0.129499434728,0.000000000000)
26 (0.104086278356,0.000000000000) (0.000000000000,-0.000000000000) (-0.159896684056,0.000000000000)
27 (-0.111959278422,0.000000000000) (0.000000000000,-0.000000000000) (0.170666095141,0.000000000000)
28 (0.146558032998,0.000000000000) (0.000000000000,-0.000000000000) (-0.221241065119,0.000000000000)
29 (-0.147943534745,0.000000000000) (0.000000000000,-0.000000000000) (0.222623127552,0.000000000000)
30 (0.207953185334,0.000000000000) (0.000000000000,0.000000000000) (-0.311257802061,0.000000000000)
31 (-0.178737544373,0.000000000000) (0.000000000000,-0.000000000000) (0.267281948676,0.000000000000)
32 (0.296136653948,0.000000000000) (0.000000000000,0.000000000000) (-0.441729543539,0.000000000000)

```

---

<div class="post-metadata">

**Author:** ![vrushali.k](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Post date:** [August 19, 2023, 6:07am UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090/2 "2023-08-19T06:07:01Z")

</div>

Why \<S^y\> is zero(both real and imaginary part)?

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [August 19, 2023, 8:04am UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090/3 "2023-08-19T08:04:14Z")

</div>

Is your wave function real-valued? It looks like it may be. In that case, Sy will always have a zero expectation value.

---

<div class="post-metadata">

**Author:** ![vrushali.k](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Post date:** [August 19, 2023, 1:29pm UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090/4 "2023-08-19T13:29:46Z")

</div>

can you please explain why \<S^y\> will have zero expectation value for real valued wave function?

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [August 21, 2023, 1:08am UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090/5 "2023-08-21T01:08:08Z")

</div>

I would suggest working through an example of a general single site wave function to see why.

I think the reason is related to the fact that Sy goes to -Sy under complex conjugation. If you write the expectation value \<psi|Sy|psi\> and write Sy as i times a real-valued matrix, then take the complex conjugate, this expression will go to the negative of itself. This could be non-zero if the expression was itself imaginary. But expected values of Hermitian operators are always real. So it must be zero.

---

<div class="post-metadata">

**Author:** ![vrushali.k](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@vrushali.k](https://itensor.discourse.group/u/vrushali.k)\
**Post date:** [August 21, 2023, 3:54am UTC](https://itensor.discourse.group/t/measurement-of-local-obervables/1090/6 "2023-08-21T03:54:54Z")

</div>

Okay. Thanks a lot.
