# Does orthogonalize! move or create the orthogonality center?

**URL:** <https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265>\
**Category:** ITensor Julia Questions\
**Created:** [February 26, 2025, 11:33am UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265 "2025-02-26T11:33:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielSic](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/danielsic/32/487_2.png) [@DanielSic](https://itensor.discourse.group/u/DanielSic)\
**Post date:** [February 26, 2025, 11:33am UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/1 "2025-02-26T11:33:18Z")

</div>

The documentation says that orthogonalize! _“ **Moves** the orthogonality center of the MPS to site `j`”_. However, it seems to me that the MPS does not remember its orthogonality center in any way, meaning that at each call the complete orthogonalization from the extremities would have to be performed. Am I right then that if one knows the orthogonality center and wants to shift it, say, by only a site, doing an SVD manually could be faster than calling orthogonalize?

Thank you for your work!

---

<div class="post-metadata">

**Author:** ![ryanlevy](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/ryanlevy/32/150_2.png) [@ryanlevy](https://itensor.discourse.group/u/ryanlevy)\
**Post date:** [February 26, 2025, 11:50am UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/2 "2025-02-26T11:50:44Z")

</div>

> [@DanielSic](#):
>
> However, it seems to me that the MPS does not remember its orthogonality center in any way

The MPS knows the orthogonality center through `ortho_lims`, and should be “remembered” throughout a calculation, once it has been set. If you create a new MPS that you know is orthogonalized you can use `set_ortho_lims!` so that `orthogonalize` is efficient. See also `preserve_ortho` for a similar utility.

P.S. `qr` may be more efficient than svd for moving the center without truncating

---

<div class="post-metadata">

**Author:** ![DanielSic](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/danielsic/32/487_2.png) [@DanielSic](https://itensor.discourse.group/u/DanielSic)\
**Post date:** [February 26, 2025, 11:59am UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/3 "2025-02-26T11:59:24Z")

</div>

Oh thank you! I was not aware of those functionalities. Unfortunately if I use the search function on [https://itensor.github.io/ITensors.jl/](https://itensor.github.io/ITensors.jl/) I can’t find anything when typing `ortho_lims`,` set_ortho_lims!`or `preserve_ortho`, am I looking in the wrong place?

---

<div class="post-metadata">

**Author:** ![ryanlevy](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/ryanlevy/32/150_2.png) [@ryanlevy](https://itensor.discourse.group/u/ryanlevy)\
**Post date:** [February 26, 2025, 12:10pm UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/4 "2025-02-26T12:10:43Z")

</div>

The MPS code has been moved to [GitHub - ITensor/ITensorMPS.jl: MPS and MPO methods based on ITensor (ITensors.jl)](https://github.com/ITensor/ITensorMPS.jl)

(be sure to check out the news on how to upgrade codes with the new package setup)

---

<div class="post-metadata">

**Author:** ![DanielSic](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/danielsic/32/487_2.png) [@DanielSic](https://itensor.discourse.group/u/DanielSic)\
**Post date:** [February 26, 2025, 12:20pm UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/5 "2025-02-26T12:20:01Z")

</div>

Thanks again for the quick reply! I was aware of that change, but I thought that [this](https://itensor.github.io/ITensors.jl/) served as documentation also for ITensorMPS, as many other ITensorMPS functions are indeed documented there. Your link points to the ITensorMPS repository, so is there no documentation for it? Should I just look at the source code?

---

<div class="post-metadata">

**Author:** ![ryanlevy](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/ryanlevy/32/150_2.png) [@ryanlevy](https://itensor.discourse.group/u/ryanlevy)\
**Post date:** [February 26, 2025, 12:31pm UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/6 "2025-02-26T12:31:39Z")

</div>

Ahh I see the confusion. That link does have many [ITensorMPS functions](https://itensor.github.io/ITensors.jl/stable/search.html?q=ItensorMPS). Some of them you’ll want to use the help mode in the julia REPL:

```julia
julia> using ITensorMPS

julia> ? #typing a question mark turns this into help mode

help?> ortho_lims
search: ortho_lims set_ortho_lims! reset_ortho_lims! orthogonalize dropdims orthogonalize!

  ortho_lims(::MPS/MPO)

  Returns the range of sites of the orthogonality center of the MPS/MPO.

  Examples
  ≡≡≡≡≡≡≡≡

  s = siteinds("S=½", 5)
  ψ = random_mps(s)
  ψ = orthogonalize(ψ, 3)

  # ortho_lims(ψ) = 3:3
  @show ortho_lims(ψ)

  ψ[2] = random_itensor(inds(ψ[2]))

  # ortho_lims(ψ) = 2:3
  @show ortho_lims(ψ)

help?> set_ortho_lims!
search: set_ortho_lims! reset_ortho_lims! ortho_lims set_rightlim! set_leftlim!

  ITensors.set_ortho_lims!(::MPS/MPO, r::UnitRange{Int})

  Sets the range of sites of the orthogonality center of the MPS/MPO.

  This is not exported and is an advanced feature that should be used with care. Setting the orthogonality limits wrong can lead to incorrect results when using ITensor MPS/MPO functions.

  If you are modifying an MPS/MPO and want the orthogonality limits to be preserved, please see the @preserve_ortho macro.

help?> @preserve_ortho
  @preserve_ortho

  Specify that a block of code preserves the orthogonality limits of an MPS/MPO that is being modified in-place. The first input is either a single MPS/MPO or a tuple of the MPS/MPO whose orthogonality limits
  should be preserved.

  Examples
  ≡≡≡≡≡≡≡≡

  s = siteinds("S=1/2", 4)

  # Make random MPS with bond dimension 2
  ψ₁ = random_mps(s, "↑"; linkdims=2)
  ψ₂ = random_mps(s, "↑"; linkdims=2)
  ψ₁ = orthogonalize(ψ₁, 1)
  ψ₂ = orthogonalize(ψ₂, 1)

  # ortho_lims(ψ₁) = 1:1
  @show ortho_lims(ψ₁)

  # ortho_lims(ψ₂) = 1:1
  @show ortho_lims(ψ₂)

  @preserve_ortho (ψ₁, ψ₂) begin
    ψ₁ .= addtags.(ψ₁, "x₁"; tags = "Link")
    ψ₂ .= addtags.(ψ₂, "x₂"; tags = "Link")
  end

  # ortho_lims(ψ₁) = 1:1
  @show ortho_lims(ψ₁)

  # ortho_lims(ψ₂) = 1:1
  @show ortho_lims(ψ₂)

```

@mtfishman now that there’s the split, maybe the docs should be “rebranded”? Or somehow include exported ITensorMPS functions on the website (like `tdvp` or these)

---

<div class="post-metadata">

**Author:** ![DanielSic](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/danielsic/32/487_2.png) [@DanielSic](https://itensor.discourse.group/u/DanielSic)\
**Post date:** [February 26, 2025, 1:38pm UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/7 "2025-02-26T13:38:57Z")

</div>

Ahh I see, thank you! This is very helpful. Of course, to use the help mode one needs to know the names of these functions, so it would indeed be useful to have them on the same website, or at least point to the fact that there might be more functionalities than the one there, I really did not know there was more than what listed.

---

<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:** [February 26, 2025, 1:46pm UTC](https://itensor.discourse.group/t/does-orthogonalize-move-or-create-the-orthogonality-center/2265/8 "2025-02-26T13:46:55Z")

</div>

Some of these are deliberately not put in the public documentation since they are not meant to be used by end users. In general users shouldn’t be setting orthogonality limits themselves. (Just because a function exists, it doesn’t mean we want people using it! They may be for internal use.)
