# Methods for simultaneous diagonalization?

**URL:** <https://discourse.julialang.org/t/methods-for-simultaneous-diagonalization/87840>\
**Category:** Numerics\
**Created:** [September 26, 2022, 8:59pm UTC](https://discourse.julialang.org/t/methods-for-simultaneous-diagonalization/87840 "2022-09-26T20:59:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kharing](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kharing/32/26578_2.png) [@kharing](https://discourse.julialang.org/u/kharing)\
**Post date:** [September 26, 2022, 8:59pm UTC](https://discourse.julialang.org/t/methods-for-simultaneous-diagonalization/87840/1 "2022-09-26T20:59:19Z")

</div>

I have two matrices that commute (within machine precision), both of which have eigenvalues that may be either degenerate or very closely spaced. Is there an existing implementation of a simultaneous diagonalization routine in Julia that gives a stable way of computing the eigenvectors? I’m afraid that the (near-)degeneracy will cause serious issues…

To be a bit more specific, I am trying to compute the Bloch-Messiah decomposition of a unitary matrix, which involves putting an antisymmetric matrix into canonical form (block diagonal where each 2x2 block is of the form `[0.0, value; -value, 0.0]`). I am trying to see if simultaneous diagonalization can be used here to stably generate the required decomposition.

---

<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, 2022, 9:19pm UTC](https://discourse.julialang.org/t/methods-for-simultaneous-diagonalization/87840/2 "2022-09-26T21:19:02Z")

</div>

> [@kharing](#):
>
> putting an antisymmetric matrix into canonical form (block diagonal where each 2x2 block is of the form `[0.0, value; -value, 0.0]`).

(See also [GitHub - JuliaLinearAlgebra/SkewLinearAlgebra.jl: Julia Package for skew-symmetric matrices](https://github.com/JuliaLinearAlgebra/SkewLinearAlgebra.jl) for optimized eigensolvers of anti-symmetric matrices. Given the eigen-decomposition you could easily compute the block-diagonal form.)
