# MPS Summation behavior

**URL:** <https://itensor.discourse.group/t/mps-summation-behavior/1013>\
**Category:** ITensor Julia Questions\
**Created:** [July 11, 2023, 10:42pm UTC](https://itensor.discourse.group/t/mps-summation-behavior/1013 "2023-07-11T22:42:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ray-l](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/ray-l/32/76_2.png) [@ray-l](https://itensor.discourse.group/u/ray-l)\
**Post date:** [July 11, 2023, 10:42pm UTC](https://itensor.discourse.group/t/mps-summation-behavior/1013/1 "2023-07-11T22:42:54Z")

</div>

I’m trying to run some simple time evolution of my system under some Hamiltonian H, by projecting the initial state onto some energy eigenstates.

Namely, for some initial state |\psi\rangle , I’m consider some lowly excited states of H which will call \{|i\rangle \} by writing:

|\psi \rangle = \sum\_i^N |i\rangle \langle i | \psi \rangle , s.t. \ \ \ e^{-iHt}|\psi \rangle =\sum\_i^N c\_i(\psi )e^{-iE\_it} |i\rangle 

For the system I’m considering, some overlap analysis seems to indicate only N \sim 20 suffice to have a good description of the initial state.

However in the MPS implementation this summation process turns out to be 1. slow 2. produces extremely large wavefunctions.  
I assume this is because the summation is done by simply performing direct sums of the tensors at each site, and presumably without truncation at each step.

How do I potentially control this behavior? A quick look at the “+” operation defined for MPS object makes me think the ‘cutoff’ is hardcoded at 1e-15, and the maxdim seems to be controlled internally, which should not lead to the above behavior.

The relevant code I am using (this produces an error as cutoff is not accepted as kwarg)

```julia
            phase = exp.( -im * dt * staticenergy)
            teeigenwf = phase .* overlaps .* staticwf
            totalwf = sum(teeigenwf; cutoff=cutoff)

```

It could also simply mean that summing MPS is not a good practice in general, and I should explicitly evaluate the observables manually,

---

<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:** [July 31, 2023, 1:42pm UTC](https://itensor.discourse.group/t/mps-summation-behavior/1013/2 "2023-07-31T13:42:14Z")

</div>

I think if the code is running slowly, then you’re right about the `cutoff` not being provided at the lower level of the code that does the MPS summation.

Please try using the ITensor function `add` ([documented here](https://itensor.github.io/ITensors.jl/dev/MPSandMPO.html#Base.:+-Tuple%7BVararg%7BITensors.AbstractMPS%7D%7D)) which can add a set of MPS. You can “splat” the MPS like this:

```julia
result = add(teeigenwf...; cutoff=cutoff)

```

I think what might be going wrong in your code is that `sum` is a generic Julia Base function and is basically calling the `+` operator on the MPS, but not passing `cutoff` since the built-in Julia `sum` function does not know about that keyword argument.
