# Contracting ITensors with non-fitting index objects

**URL:** <https://itensor.discourse.group/t/contracting-itensors-with-non-fitting-index-objects/1724>\
**Category:** ITensor Julia Questions\
**Tags:** julia\
**Created:** [May 17, 2024, 3:01pm UTC](https://itensor.discourse.group/t/contracting-itensors-with-non-fitting-index-objects/1724 "2024-05-17T15:01:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pia](https://avatars.discourse-cdn.com/v4/letter/p/6a8cbe/32.png) [@Pia](https://itensor.discourse.group/u/Pia)\
**Post date:** [May 17, 2024, 3:01pm UTC](https://itensor.discourse.group/t/contracting-itensors-with-non-fitting-index-objects/1724/1 "2024-05-17T15:01:03Z")

</div>

Dear ITensor Team,

I wanted to ask whether there is a possibility to contract two ITensors which do not have the same index-object but e.g. have the same index-tag?  
Minimal example:

> using ITensors
> 
> i1 = Index(2, “i”)  
> i2 = Index(2, “i”)
> 
> A = ITensor(i1)  
> B = ITensor(i2)

> A\*B

Any chance that I can contract A and B using the tag “i” and get a dim 1 Tensor instead of (2,2)?  
If not, is there a way to contract ITensors with respect to the position of the index?  
Or is there a way to replace efficiently specific indices of Itensors (ideally identifified over their tag)?  
Thank you already in advance

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [May 17, 2024, 3:07pm UTC](https://itensor.discourse.group/t/contracting-itensors-with-non-fitting-index-objects/1724/2 "2024-05-17T15:07:40Z")

</div>

You can use `A * replaceinds(B, i2 => i1)` or `A * (B * delta(i2, i1))`.

---

<div class="post-metadata">

**Author:** ![Pia](https://avatars.discourse-cdn.com/v4/letter/p/6a8cbe/32.png) [@Pia](https://itensor.discourse.group/u/Pia)\
**Post date:** [May 17, 2024, 3:47pm UTC](https://itensor.discourse.group/t/contracting-itensors-with-non-fitting-index-objects/1724/3 "2024-05-17T15:47:38Z")

</div>

Thanks a lot
