# trace and partial trace of MPO

**URL:** <https://itensor.discourse.group/t/trace-and-partial-trace-of-mpo/79>\
**Category:** ITensor Julia Questions\
**Tags:** julia, mpo\
**Created:** [April 24, 2022, 11:28pm UTC](https://itensor.discourse.group/t/trace-and-partial-trace-of-mpo/79 "2022-04-24T23:28:32Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jisutich](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@jisutich](https://itensor.discourse.group/u/jisutich)\
**Post date:** [April 25, 2022, 2:26am UTC](https://itensor.discourse.group/t/trace-and-partial-trace-of-mpo/79/3 "2022-04-25T02:26:16Z")

</div>

Hi Miles, thanks a lot for the answer. For the partial trace, I guess what you mean is something like

```auto
n = 10
s = siteinds("Qubit",n)
rho = randomMPS(s)
for i = 1:k #k is the site I stopped. or i = m:length(rho)
rho[i] = rho[i]*delta(s[i],s[i]')
end

```

right? But I am not sure how to transfer this into a smaller MPO. This MPO still has n sites. Can you give more hints?

Yes, the sites I want to trace out are either 1:n or m:length(rho). The question I am considering these days is calculate the Renyi entropy or entanglement negativity or a quantum circuit with both haar random evolution and quantum channels. Due to the existence of quantum channels, I need a mixed state in general. But basically I just want to trace out either left or right half of the sites.

Thanks

---

_[View the full topic](https://itensor.discourse.group/t/trace-and-partial-trace-of-mpo/79)._
