# Question on creating an MPO

**URL:** <https://itensor.discourse.group/t/question-on-creating-an-mpo/1519>\
**Category:** ITensor Julia Questions\
**Tags:** julia, mpo\
**Created:** [March 4, 2024, 2:02pm UTC](https://itensor.discourse.group/t/question-on-creating-an-mpo/1519 "2024-03-04T14:02:23Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [March 19, 2024, 6:27pm UTC](https://itensor.discourse.group/t/question-on-creating-an-mpo/1519/4 "2024-03-19T18:27:27Z")

</div>

A very convenient way to make a controlled gate like CNOT as an MPO using ITensor is to use our “OpSum” system. Here’s an example:

```julia
  n = 10 # 10 qubits, no problem to do more
  s = siteinds("Qubit",n)
  i = 3 # i will be the "control" site
  j = 7 # j will be the site where the gate acts 

  cnot = OpSum()
  cnot += "Proj0",i,"Id",j
  cnot += "Proj1",i,"X",j
  CNOT = MPO(cnot,s)

```

The above is using the following way of writing the CNOT gate:

CNOT\_{i,j} = \ket{0}\_i \bra{0}\_i \otimes I\_j + \ket{1}\_i \bra{1}\_i \otimes X\_j

and the fact that the Pauli X operator is identical to the NOT single-qubit gate.

---

_[View the full topic](https://itensor.discourse.group/t/question-on-creating-an-mpo/1519)._
