# Exact Diagonalization code's link not working

**URL:** <https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416>\
**Category:** DMRG and Numerical Methods\
**Created:** [June 9, 2025, 12:26pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416 "2025-06-09T12:26:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jyoti\_Bisht](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jyoti\_Bisht](https://itensor.discourse.group/u/Jyoti_Bisht)\
**Post date:** [June 9, 2025, 12:26pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/1 "2025-06-09T12:26:55Z")

</div>

[https://github.com/ITensor/ITensors.jl/blob/main/examples/exact\_diagonalization/exact\_diagonalization.jl](https://github.com/ITensor/ITensors.jl/blob/main/examples/exact_diagonalization/exact_diagonalization.jl)

This is the link given on this site for exact diagonalization through ITensor, but now this link is not working.

Can you please check it. If it is available with some other link please let me know.

---

<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:** [June 9, 2025, 1:11pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/2 "2025-06-09T13:11:58Z")

</div>

Hi @Jyoti_Bisht ,  
The example codes related to MPS and MPO (and relatedly ED) have been moved to the ITensorMPS repo. Here is the updated link:  
[https://github.com/ITensor/ITensorMPS.jl/tree/main/examples/exact\_diagonalization](https://github.com/ITensor/ITensorMPS.jl/tree/main/examples/exact_diagonalization)

---

<div class="post-metadata">

**Author:** ![Jyoti\_Bisht](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jyoti\_Bisht](https://itensor.discourse.group/u/Jyoti_Bisht)\
**Post date:** [June 9, 2025, 3:56pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/3 "2025-06-09T15:56:02Z")

</div>

Thank you Miles.  
I have a question on this.  
I tried this code for 2 spin and putting 4 instead of 1 for 4 eigenvalues then only 3 values are appearing in vals()..  
-0.75  
3.885780586188048e-16  
0.24999999999999992

but actually for 2 spin Heisenberg model has 4 eigenvalues which are  
-0.75  
0.25  
0.25  
0.25

then why does this method is giving these eigenvalues. Does it work only for ground state energy ? but not for the whole energy spectrum?

---

<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:** [June 9, 2025, 4:03pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/4 "2025-06-09T16:03:26Z")

</div>

That code uses the Krylov solver from KrylovKit.jl, see the note in their docs about degenerate eigenvalues: [Eigenvalue problems · KrylovKit.jl](https://jutho.github.io/KrylovKit.jl/stable/man/eig/#KrylovKit.eigsolve).

---

<div class="post-metadata">

**Author:** ![Jyoti\_Bisht](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jyoti\_Bisht](https://itensor.discourse.group/u/Jyoti_Bisht)\
**Post date:** [June 9, 2025, 4:12pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/5 "2025-06-09T16:12:01Z")

</div>

Yes , I read about it earlier. But why there is this extra eigenvalue “3.885780586188048e-16” ? , as there are just -0.75 and 0.25(degenerate) values.  
I am sorry if it is a naive question.

---

<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:** [June 9, 2025, 4:15pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/6 "2025-06-09T16:15:29Z")

</div>

I don’t have a good explanation for that, to state the obvious, the only explanations are that the input matrix is wrong or KrylovKit.eigsolve is wrong.

---

<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:** [June 9, 2025, 4:16pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/7 "2025-06-09T16:16:47Z")

</div>

As a sanity check, if the matrix is small, you can directly use `LinearAlgebra.eigen` to compute the full diagonalization with LAPACK.

---

<div class="post-metadata">

**Author:** ![Jyoti\_Bisht](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jyoti\_Bisht](https://itensor.discourse.group/u/Jyoti_Bisht)\
**Post date:** [June 9, 2025, 4:21pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/8 "2025-06-09T16:21:53Z")

</div>

Yes that is right but I need ED for system size of 10.

When you say “input matrix is wrong or KrylovKit.eigsolve is wrong”, I think the input matrix is correct in the code. And is it possible that KrylovKit.eigsolve is not working correctly

---

<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:** [June 9, 2025, 4:42pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/9 "2025-06-09T16:42:31Z")

</div>

We haven’t seen any bugs ourselves but I suppose it is possible. You could double check against another solver like [Arpack.jl](https://github.com/JuliaLinearAlgebra/Arpack.jl).

---

<div class="post-metadata">

**Author:** ![Jyoti\_Bisht](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jyoti\_Bisht](https://itensor.discourse.group/u/Jyoti_Bisht)\
**Post date:** [June 9, 2025, 4:49pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/10 "2025-06-09T16:49:11Z")

</div>

Okay. You mean when you checked this code, it gave correct eigenvalues?  
I will check with solver.

---

<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:** [June 9, 2025, 5:09pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/11 "2025-06-09T17:09:01Z")

</div>

I didn’t check your code, I’m just making a general statement that we use KrylovKit.eigsolve a lot and haven’t seen any bugs where it outputs an eigenvalue that isn’t supposed to be in the spectrum.

---

<div class="post-metadata">

**Author:** ![Jyoti\_Bisht](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@Jyoti\_Bisht](https://itensor.discourse.group/u/Jyoti_Bisht)\
**Post date:** [June 9, 2025, 5:51pm UTC](https://itensor.discourse.group/t/exact-diagonalization-codes-link-not-working/2416/12 "2025-06-09T17:51:20Z")

</div>

Okay . Thank you..
