# Eigvals pinv

**URL:** <https://discourse.julialang.org/t/eigvals-pinv/67373>\
**Category:** Numerics\
**Tags:** linearalgebra\
**Created:** [August 30, 2021, 4:57pm UTC](https://discourse.julialang.org/t/eigvals-pinv/67373 "2021-08-30T16:57:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge\_Silva](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jorge_silva/32/14976_2.png) [@Jorge\_Silva](https://discourse.julialang.org/u/Jorge_Silva)\
**Post date:** [August 30, 2021, 4:57pm UTC](https://discourse.julialang.org/t/eigvals-pinv/67373/1 "2021-08-30T16:57:22Z")

</div>

I´m trying to implement a relatively complex model that I found in literature. It involves to calculate the spectrum of a linearized system in order to evaluate the stability of the steady-state solution.  
Thus I´m using  
`eigvals(pinv(A)*B)`  
The figure below shows a comparision between my results and literature. Mainly for high eigenvalues there is a large shift/ scatering. Is there a problem with my implementation or is it something related with eigvals or pinv functions?

![Sem título](https://global.discourse-cdn.com/julialang/original/3X/6/f/6f0c31038544f7b7e9fca94ce303b7481e597055.png)

---

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [August 30, 2021, 10:15pm UTC](https://discourse.julialang.org/t/eigvals-pinv/67373/2 "2021-08-30T22:15:09Z")

</div>

To summarize: you compute `eigvals(pinv(A)*(B))`. You do not tell us, what kind of matrices `A` and `B` are. Square? Tall? Wide? Large? Small? Then you tell us, that in some literature they obtain slightly different results. So, what kind of feedback are you expecting here?

By the way, in those unspecified papers are they also solving the problem of finding eigenvalues of exactly `pinv(A)*B`? I can only guess that perhaps the original problem is to solve the [generalized eigenvalue problem](https://en.wikipedia.org/wiki/Eigendecomposition_of_a_matrix#Generalized_eigenvalue_problem), that is, find a (tuple of) scalars `λ`, where for each `λ` there is a corresponding (generalized) eigenvector `v`, that is, (following your usage of `A` and `B`) the equation `λAv = Bv` must be satisfied. Is my guess correct? If yes, the good news for you is that the Julia [eigvals](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.eigvals) function accepts two arguments too, that is, it is ready to solve the generalized eigenvalue problem without the need to explicitly compute (pseudo)inverse and solve the standard eigenvalue problem.

---

<div class="post-metadata">

**Author:** ![Jorge\_Silva](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jorge_silva/32/14976_2.png) [@Jorge\_Silva](https://discourse.julialang.org/u/Jorge_Silva)\
**Post date:** [September 1, 2021, 12:36am UTC](https://discourse.julialang.org/t/eigvals-pinv/67373/3 "2021-09-01T00:36:07Z")

</div>

Thank you.  
Yes, it is a generalized eigenvalue problem, λAv = Bv, but A e B are tall matrices, would say 404x402. eigvals does not accept not square matrices, then it seem it is necessary to use pinv, also.

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [November 18, 2021, 6:18am UTC](https://discourse.julialang.org/t/eigvals-pinv/67373/4 "2021-11-18T06:18:32Z")

</div>

One other option could be to rewrite the problem as B^T A v = m B^T B v, where the matrices now should be square. This is essentially what `pinv ` does I think, but without evaluating an explicit inversion (which might face numerical stability issues)
