# Search for eigenvalues under a specific upper boundary

**URL:** <https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913>\
**Category:** Numerics\
**Tags:** eigenvalue-problem\
**Created:** [September 26, 2024, 12:02pm UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913 "2024-09-26T12:02:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tianyi\_zhang](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@tianyi\_zhang](https://discourse.julialang.org/u/tianyi_zhang)\
**Post date:** [September 26, 2024, 12:02pm UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913/1 "2024-09-26T12:02:46Z")

</div>

Hello, I am trying to solve an eigenvalue problem in which eigenvalues lesser than a upper boundary are solved.

The linear operator is hermitian or real symmetric, and the eigenvalues are guaranteed to be positive, so I just need to specify a upper bound. Because the problem is large and I only need the lowest eigenvalues, I have used iterative methods, specifically [KrylovKit.jl](https://jutho.github.io/KrylovKit.jl/stable/man/eig/). My state vectors are structured so turning it into `AbstractVector` would lose all the structure, and [VectorInterface.jl](https://github.com/Jutho/VectorInterface.jl) solved the problem for me.

As for the iterative eigensolves I’ve investigated ([KrylovKit.jl](https://jutho.github.io/KrylovKit.jl/stable/man/eig/), [ArnoldiMethod.jl](https://github.com/JuliaLinearAlgebra/ArnoldiMethod.jl)), they have the `EigSorter` argument which specifies the requirement for the first eigenvalue.

From my very small understanding we could write a restart algorithm where the Krylov subspace are saved and reused.

Sorry for the clumped post, is there any solver out there that can use a generic `Vector` and calculate eigenvalues in a bound?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 26, 2024, 2:13pm UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913/2 "2024-09-26T14:13:52Z")

</div>

It sounds like you have already solved the problem? What is wrong with KrylovKit and VectorInterface for your task?

---

<div class="post-metadata">

**Author:** ![tianyi\_zhang](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@tianyi\_zhang](https://discourse.julialang.org/u/tianyi_zhang)\
**Post date:** [September 27, 2024, 1:40am UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913/3 "2024-09-27T01:40:09Z")

</div>

Sorry, it seems like I didn’t state the problem clearly. The **problem** is I can specify the number of eigenvalues, but not all the values (generally an **unknown** number of) under a certain boundary.

With the current algorithm, to calculate all eigenvalues under a upper bound, say `bound`, I have to specify a guessed number to solve, say `n`, in the solver, but the problem is:

1. if the largest eigenvalue in total `n` of them is way larger than `bound`, then I wasted calculation time;
2. else the largest eigenvalue is still lesser than `bound`, then without a restart algorithm(in my knowledge), I’ll have to specify a larger `n` and start the calculation all over again, which may not even be enough this time, and the process goes on and on…

Well, in my knowledge the krylov algorithm needs a `krylovdim` parameter to build the krylov subspace, and calculating eigenvalues in a range means unknown number of solutions. So determining `krylovdim` could be tricky and not enough. But I think a new algorithm could be where user specifies `krylovdim` and `bound`, and once the algorithm uses all krylov space it just expands it(could it work?), and continue until the largest eigenvalue reaches `bound`. (This paragraph is just me rumbling 🙂)

Sorry for another clumped reply.

---

<div class="post-metadata">

**Author:** ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)\
**Post date:** [September 27, 2024, 10:07am UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913/4 "2024-09-27T10:07:39Z")

</div>

KrylovKit main developer here. While what you request is certainly feasible within the current implementation (provided that at least `krylovdim` is large enough to capture all the eigenvalues smaller `bound`), it is indeed currently not supported in the way the function is called and the arguments are specified.

As is often the case, the hardest part is coming up with a good interface to support these different ways of specifying the problem. Asking for a fixed number of eigenvalues is the typical interface provided by these Krylov eigensolvers.

Maybe you can open an issue about this on the KrylovKit github repository?

PS: Note that KrylovKit already returns all the eigenvalues that have converged, when more than the requested number have converged.

---

<div class="post-metadata">

**Author:** ![tianyi\_zhang](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@tianyi\_zhang](https://discourse.julialang.org/u/tianyi_zhang)\
**Post date:** [September 27, 2024, 1:21pm UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913/5 "2024-09-27T13:21:25Z")

</div>

Would love to open an issue for this.

You said that `krylovdim` must be large enoigh, so dynamically adjusting the krylov subspace is not possible? Does this mean a restart algorithm that reuses and expands krylov subspace is not possible?

---

<div class="post-metadata">

**Author:** ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)\
**Post date:** [September 27, 2024, 1:32pm UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913/6 "2024-09-27T13:32:56Z")

</div>

The krylov subspace is of course expanded and shrunk and expanded again during the course of the `eigsolve` algorithm. It is just that the maximal dimension of the Krylov subspace to which it is expanded before there it is shrunk and restarted, is currently also a fixed parameter that you specify.

But since the `eigsolve` interface and implementation would anyway need to be changed to accommodate a `bound` argument, I guess making the `krylovdim` dynamic at the same time is also possible. It is just not easy to do this in a “black box” manner, i.e. what are reasonable values for the maximal dimension of the Krylov subspace? That can be very much problem dependent.

---

<div class="post-metadata">

**Author:** ![tianyi\_zhang](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@tianyi\_zhang](https://discourse.julialang.org/u/tianyi_zhang)\
**Post date:** [September 27, 2024, 2:58pm UTC](https://discourse.julialang.org/t/search-for-eigenvalues-under-a-specific-upper-boundary/119913/7 "2024-09-27T14:58:27Z")

</div>

I guess one way to do this is let user specify an initial `krylovdim` and an increment size `n`. So that once all `krylovdim` eigenvalues have converged and still not enough, just increment it by `n`.
