# Creating the right MPS/MPO and how to do so manually.

**URL:** <https://itensor.discourse.group/t/creating-the-right-mps-mpo-and-how-to-do-so-manually/2173>\
**Category:** ITensor Julia Questions\
**Tags:** julia, mps, mpo\
**Created:** [December 16, 2024, 11:29pm UTC](https://itensor.discourse.group/t/creating-the-right-mps-mpo-and-how-to-do-so-manually/2173 "2024-12-16T23:29:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtl2164](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jtl2164](https://itensor.discourse.group/u/jtl2164)\
**Post date:** [December 16, 2024, 11:29pm UTC](https://itensor.discourse.group/t/creating-the-right-mps-mpo-and-how-to-do-so-manually/2173/1 "2024-12-16T23:29:15Z")

</div>

I have a few questions on how iTensor works. I’ve been working on some code that runs quite slowly, so I suspect it’s some inner workings I don’t fully understand.

Firstly, I have seen the following code example for representing a string of N spin ups for a spin 1/2 system:

```auto
state = ["Up" for n=1:N]                                      
s = siteinds("S=1/2", N; conserve_qns=true)     
psi = MPS(s, state)   

```

My understanding is that this that `psi` will be this state written as an MPS, **but what exactly is this MPS?** Is it possible to write down what it is? There should be numerous ways to write this down, so I’m a bit lost on what exactly this code is doing.

Secondly, how does iTensor create MPOs? If I want to create the following operator: \sum\_{j=1}^N \sigma\_-^j

I can construct my MPO to be: \sum\_{i\_1,i\_2,\dots i\_N} \langle 0 | A^{i\_1}A^{i\_2}\dots A^{i\_N}|1\rangle \tau^{i\_1} \otimes \tau^{i\_2}\otimes \dots \otimes \tau^{i\_N}, where each i\_k=\{0, 1\}, and \tau^0=1, \tau^1 = \sigma\_-, A^0=1,$ and A^1 = \sigma\_-. This makes it so that \langle 0 | A^{i\_1}A^{i\_2}\dots A^{i\_N}|1\rangle=1 if and only if just one of the i\_k=1. In this case, A^0, A^1 are 2\times 2 matrices, so I’m working with bond dimension 2.

Based on tutorials, I would implement this similarly using

```auto
S_minus = OpSum()
for i in 1:N
    S_minus += 1.,"S-", i 
end

s = siteinds("S=1/2", N; conserve_qns=true) 
S_minus_MPO = MPO(Jmin, s)

```

**What exactly does this create? How would I write down what this is?**

**Also, if I know the form of the MPO I want (as I do above), is there some way to implement this MPO manually (i.e. literally specifying the matrices A^0,A^1, etc.)?**
