# Operating on an MPO from the right

**URL:** <https://itensor.discourse.group/t/operating-on-an-mpo-from-the-right/1977>\
**Category:** ITensor Julia Questions\
**Created:** [September 10, 2024, 11:59am UTC](https://itensor.discourse.group/t/operating-on-an-mpo-from-the-right/1977 "2024-09-10T11:59:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ile20](https://avatars.discourse-cdn.com/v4/letter/i/bc8723/32.png) [@ile20](https://itensor.discourse.group/u/ile20)\
**Post date:** [September 10, 2024, 11:59am UTC](https://itensor.discourse.group/t/operating-on-an-mpo-from-the-right/1977/1 "2024-09-10T11:59:06Z")

</div>

Hi,

Is it possible to operate on an MPO from both directions? It seems that the following is correct:

```auto
using ITensors, ITensorMPS

let
    s = siteinds("Qubit",2)
    
    oper = op("Rx", s[1], θ=π/5)

    mpo = MPO(s, "I")

    mpo =apply(oper, mpo)

end

```

However, changing the `apply` command to `mpo = apply(mpo, oper)` throws an error. In some cases it would be useful to build an MPO from both directions, not only by applying the operators naively from left to right.

---

<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:** [September 11, 2024, 12:33am UTC](https://itensor.discourse.group/t/operating-on-an-mpo-from-the-right/1977/2 "2024-09-11T00:33:10Z")

</div>

You can use `mpot = swapprime(mpo, 0 => 1)` and `opert = swapprime(oper, 0 => 1)` to transpose the MPO and operator so that `swapprime(apply(opert, mpot), 0 => 1)` applies the operator on the other side (and transposes back).

Though probably we should support `apply(mpo, oper)` as a shorthand for that.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/d3072b13e047cd06df7f3981547c0917d940dfa4.png) [@system](https://itensor.discourse.group/u/system)\
**Post date:** [September 21, 2024, 12:33am UTC](https://itensor.discourse.group/t/operating-on-an-mpo-from-the-right/1977/3 "2024-09-21T00:33:38Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
