+1 vote
asked by (680 points)


I was wondering the difference between these two methods? I am writing code that implements a Lanczos algorithm, and thus I need to multiply an MPS by an MPO many times. However, I noticed that using the Fit method, I actually get the wrong answer, while with DensityMatrix I get the correct answer. Any idea why?

commented by (70.1k points)
Related to Matt's answer, I just updated this documentation page with a little more information (I added the scaling of the Fit method and some additional comments about the cases where it might work better):
commented by (680 points)
Wonderful, thank you Miles!

1 Answer

+1 vote
answered by (14.1k points)


The "DensityMatrix" algorithm is described here:


It is a direct method (in that it only requires one sweep over the system), and is very reliable. However, it's accuracy may be limited to around 1e-8, because it relies on forming the density matrix which involves squaring the singular values, which can decrease the precision (but that is only an issue if you need very high precision).

The "Fit" algorithm involves variationally optimizing the overlap between an initial guess MPS and the MPO*MPS you are interesting in approximating with a sweeping algorithm similar to DMRG. It is known to get "stuck" (i.e. not find the correct MPS approximation) if the initial guess is not very good, or may take a lot of sweeps to converge (so you may want to try increasing the number of sweeps). This algorithm scales better with the bond dimensions of the input MPS/MPO compared to the "DensityMatrix" method.

If in your code applying the MPO to the MPS is not a performance bottleneck, and you do not need very high precision for your final MPS, then the "DensityMatrix" method is better to use. Otherwise, you will need to use the "Fit" method (and possibly play around with finding a better initial guess in order to get it to converge properly).


commented by (680 points)
Hi Matt,

Thank you for the answer. The MPO MPS products is essentially my entire calculation, so efficiency is ideal. I was unaware that it is known to get stuck, so I will play around with the options!

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.