# Explicitly construct the reduced density matrix

**URL:** <https://itensor.discourse.group/t/explicitly-construct-the-reduced-density-matrix/2478>\
**Category:** ITensor Julia Questions\
**Tags:** mps\
**Created:** [August 24, 2025, 2:47pm UTC](https://itensor.discourse.group/t/explicitly-construct-the-reduced-density-matrix/2478 "2025-08-24T14:47:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhouzsh](https://avatars.discourse-cdn.com/v4/letter/z/a88e4f/32.png) [@zhouzsh](https://itensor.discourse.group/u/zhouzsh)\
**Post date:** [August 24, 2025, 2:47pm UTC](https://itensor.discourse.group/t/explicitly-construct-the-reduced-density-matrix/2478/1 "2025-08-24T14:47:07Z")

</div>

Dear ITensor team,

For my specific requirements, I need to explicitly construct the reduced density matrix. The basic procedure I have followed is to first shift the canonical center of the MPS to a particular site, and then perform an SVD to obtain matrices U, S, and V. My goal is to compute U\*S\*U^\dag. To achieve this, I attempted to replace the left index of U^\dag (dagged the right link Index of U) with the left index of V.

```auto
   # the right index of U
    indA = commonind(U, S; tags = "Link")
    # the left index of V
    indB = commonind(V, S; tags = "Link")

    #the left link of Aux MPS tensor is replected by the left index of V
    replaceind!(Udag, dag(indA), indB)

```

However, some problems arise as following

```auto
 LoadError: Attempting to replace the Indices

((dim=2|id=730|"Link,u") <Out>
 1: QN("Sz",2) => 1
 2: QN("Sz",0) => 1,)

with

((dim=2|id=228|"Link,v") <In>
 1: QN("Sz",-2) => 1
 2: QN("Sz",0) => 1,)

in the Index collection

((dim=2|id=412|"Aux,S=1/2,Site,n=12") <In>
 1: QN("Sz",1) => 1
 2: QN("Sz",-1) => 1, (dim=2|id=624|"Link,l=13") <In>
 1: QN("Sz",1) => 1
 2: QN("Sz",-1) => 1, (dim=2|id=730|"Link,u") <Out>
 1: QN("Sz",2) => 1
 2: QN("Sz",0) => 1).

However, the Index

(dim=2|id=730|"Link,u") <Out>
 1: QN("Sz",2) => 1
 2: QN("Sz",0) => 1

has a different space from the Index

(dim=2|id=228|"Link,v") <Out>
 1: QN("Sz",-2) => 1
 2: QN("Sz",0) => 1.

They must have the same spaces to be replaced.

```

In the presence of QN, how can I correctly construct the reduce density matrix explicitly.

Best regards.

ZHOU Zongsheng.

---

<div class="post-metadata">

**Author:** ![ZhouGD2000](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/zhougd2000/32/669_2.png) [@ZhouGD2000](https://itensor.discourse.group/u/ZhouGD2000)\
**Post date:** [August 24, 2025, 6:20pm UTC](https://itensor.discourse.group/t/explicitly-construct-the-reduced-density-matrix/2478/2 "2025-08-24T18:20:56Z")

</div>

I am not 100% sure about your requirement, but since the reduce density matrix is S^2 instead of S, a possible way is to calculate USV^\dagger \* (USV^\dagger)^\dagger or US \* (US)^\dagger and in these ways your contract the (right) left index of V to the (right) left index of V and do not need to replace the index.

If you really want S itself, another way (though not so straightforward) is to define an \tilde{S} by replacing matrix element of S by an identity matrix and then contract it to S (remember to use prime level so that only the link `"Link,v"` is contracted) to obtain a tensor with two legs are all links `"Link,u" `.

(Maybe there is better way to directly replace the `Index` but I am not familiar with it so I just offer some possible solutions. )

---

<div class="post-metadata">

**Author:** ![zhouzsh](https://avatars.discourse-cdn.com/v4/letter/z/a88e4f/32.png) [@zhouzsh](https://itensor.discourse.group/u/zhouzsh)\
**Post date:** [August 26, 2025, 7:28am UTC](https://itensor.discourse.group/t/explicitly-construct-the-reduced-density-matrix/2478/3 "2025-08-26T07:28:54Z")

</div>

Thanks for your help. I am sorry for my unclear description of my problem. In fact, I want to construct \sqrt{\rho}. Your suggestion about redefining a new S seems promising. I will try it.

Thanks again for your help.

Best wishes!

ZHOU Zongsheng
