# Generalised eigenvalue problem with BigFloat

**URL:** <https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197>\
**Category:** Numerics\
**Tags:** eigenvalues, eigenvalue-problem\
**Created:** [February 22, 2025, 9:14pm UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197 "2025-02-22T21:14:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![fionah](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@fionah](https://discourse.julialang.org/u/fionah)\
**Post date:** [February 22, 2025, 9:14pm UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/1 "2025-02-22T21:14:19Z")

</div>

I am trying to solve the **generalised** eigenvalue problem in arbitrary precision, using the BigFloat data type.

```julia
using LinearAlgebra
using GenericLinearAlgebra

setprecision(128)

println(eigen(Hermitian(rand(BigFloat, 2, 2)), Hermitian(rand(BigFloat, 2, 2))))

```

It produces this error:

```julia
Exception has occurred: MethodError

MethodError: no method matching eigen!(::Hermitian{BigFloat, Matrix{BigFloat}}, ::Hermitian{BigFloat, Matrix{BigFloat}}) 
The function `eigen!` exists, but no method is defined for this combination of argument types.

```

However, using BigFloat for the **standard** eigenvalue problem works

```julia
println(eigen(Hermitian(rand(BigFloat, 2, 2))))

```

Does anyone know why this is or how I could fix it? Thanks so much for any help, I’ve been asked to use Julia for my masters project and have no experience using it!

---

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [February 22, 2025, 10:16pm UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/2 "2025-02-22T22:16:56Z")

</div>

The symmetric eigenvalue problem is easier to implement

Arb.jl has a general eigenvalue solver with its own arbitrary precision ball arithmetic, getting rigorous bounds too. This might suit your needs

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [February 23, 2025, 12:09am UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/3 "2025-02-23T00:09:01Z")

</div>

> [@dlfivefifty](#):
>
> [Arb.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/Arb) has a

I don’t think such a package exists. I guess at least one of Arblib.jl or ArbNumerics.jl should suffice, though.

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [February 23, 2025, 1:29am UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/4 "2025-02-23T01:29:33Z")

</div>

There are methods for generalized eigensystems of complex matrices with arbitrary precision in GenericSchur.jl. I haven’t gotten around to writing all the conventional wrappers but you can do something like

```julia
using LinearAlgebra, GenericSchur
A = rand(Complex{BigFloat},n,n)
B = rand(Complex{BigFloat},n,n)
S = schur(A,B)
V = eigvecs(S)
# check result:
resid = norm(A * V - V * B * Diagonal(S.values))

```

I haven’t implemented methods for the plain real or Hermitian cases.

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)\
**Post date:** [February 23, 2025, 10:06am UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/5 "2025-02-23T10:06:02Z")

</div>

In the Hermitian/real symmetric case, you usually transform the problem by Cholesky factorizing the B matrix. I.e. something like

```julia
julia> using LinearAlgebra

julia> using GenericLinearAlgebra

julia> setprecision(128)
128

julia> A = Hermitian(rand(BigFloat, 2, 2))
2×2 Hermitian{BigFloat, Matrix{BigFloat}}:
 0.750726 0.800863
 0.800863 0.146439

julia> B = Hermitian(rand(BigFloat, 2, 2))
2×2 Hermitian{BigFloat, Matrix{BigFloat}}:
 0.497388 0.0396879
 0.0396879 0.298677

julia> Fchol = cholesky(B)
Cholesky{BigFloat, Matrix{BigFloat}}
U factor:
2×2 UpperTriangular{BigFloat, Matrix{BigFloat}}:
 0.705257 0.0562743
  ⋅ 0.543609

julia> Ã = Fchol.U'\A/Fchol.U
2×2 Matrix{BigFloat}:
 1.50934 1.93268
 1.93268 0.0792299

julia> Feigen = eigen(Ã)
Eigen{BigFloat, BigFloat, Matrix{BigFloat}, Vector{BigFloat}}
values:
2-element Vector{BigFloat}:
 -1.266437199907713533384656554486557838751
  2.855004257222210224062038053659169376169
vectors:
2×2 Matrix{BigFloat}:
  0.571405 -0.820668
 -0.820668 -0.571405

julia> V = Fchol.U\Feigen.vectors
2×2 Matrix{BigFloat}:
  0.930669 -1.07977
 -1.50967 -1.05113

julia> norm(A*V - B*V*Diagonal(Feigen.values))
4.156000133564589919546802616566101790705e-39

```

---

<div class="post-metadata">

**Author:** ![fionah](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@fionah](https://discourse.julialang.org/u/fionah)\
**Post date:** [February 23, 2025, 11:36am UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/6 "2025-02-23T11:36:46Z")

</div>

Thankyou! Are you aware of any additional time constraints the cholsesky factorisation would have on the calculation? I am using matrix sizes of \> (30)^3. If not don’t worry I can do some analysis 🙂

---

<div class="post-metadata">

**Author:** ![fionah](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@fionah](https://discourse.julialang.org/u/fionah)\
**Post date:** [February 23, 2025, 11:37am UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/7 "2025-02-23T11:37:24Z")

</div>

Thanks so much !! :))

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)\
**Post date:** [February 23, 2025, 12:31pm UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/8 "2025-02-23T12:31:03Z")

</div>

The Cholesky factorization wouldn’t be the limiting factor here. The eigenvalue computation would be much more costly than the Cholesky. Using a symmetric eigen solver, as would be available when transforming the problem with the Cholesky factor, is also typically much faster than using a general solver. However, if the dimension is ~30^3 then I think it will be almost prohibitively costly to solve with `BigFloat` elements. Do you need all the eigenvalues? If not, then you should probably consider an iterative solver.

---

<div class="post-metadata">

**Author:** ![fionah](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@fionah](https://discourse.julialang.org/u/fionah)\
**Post date:** [February 23, 2025, 2:27pm UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/9 "2025-02-23T14:27:35Z")

</div>

I am aware of the computational cost required, this code has already been used in python to solve the non-BO Schrodinger equation (w/ Float64). Implementation into Julia is in order to increase precision, as it has been extraordinarily difficult in python. The python code also uses sparse matrices, but as far as I am aware, there is no package that allows for solving the eigenvalue problem with precision \> 64 bits for sparse matrices in Julia. For this purpose, only the minimum eigenvalue(s) is required. Do you know an iterative solver that would work using the BigFloat type?

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)\
**Post date:** [February 23, 2025, 2:50pm UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/10 "2025-02-23T14:50:21Z")

</div>

> Do you know an iterative solver that would work using the BigFloat type?

I believe that should be possible with either [Home · ArnoldiMethod.jl](https://julialinearalgebra.github.io/ArnoldiMethod.jl/stable/) or [Home · KrylovKit.jl](https://jutho.github.io/KrylovKit.jl/stable/) but I haven’t tested it.

---

<div class="post-metadata">

**Author:** ![fionah](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@fionah](https://discourse.julialang.org/u/fionah)\
**Post date:** [March 12, 2025, 11:56am UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/11 "2025-03-12T11:56:31Z")

</div>

Hi, sorry to bother you but I’m having some trouble again. the

```julia
Ã = Fchol.U'\A/Fchol.U

```

line doesn’t provide a symmetric matrix for me (differs in the last few decimal digits) and therefore

```julia
Feigen = eigen(Ã)

```

produces the error

```julia
ERROR: LoadError: MethodError: no method matching eigen!(::Matrix{BigFloat}; permute::Bool, scale::Bool, sortby::typeof(LinearAlgebra.eigsortby))

```

Making `Ã` hermitian resolves this issue, however I dont want to do that. Do you have any ideas on how to fix it?

---

<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:** [March 12, 2025, 12:33pm UTC](https://discourse.julialang.org/t/generalised-eigenvalue-problem-with-bigfloat/126197/12 "2025-03-12T12:33:40Z")

</div>

> [@fionah](#):
>
> line doesn’t provide a symmetric matrix for me (differs in the last few decimal digits) and therefore

That’s probably just roundoff errors. Just do `Ã = Hermitian(Fchol.U'\A/Fchol.U)`.
