# Counting Eigenvalues

When solving a generalised eigenvalue problem

$\mathbf{K}\boldsymbol{\phi} - \lambda\mathbf{M}\boldsymbol{\phi} = 0$

as in modal analysis, we can count the number of eigenpairs we will find in some interval $[a,b]$.

This is done using a Sylvester inertia check [1]. Sylvester's law of inertia tells us that the number of eigenvalues in $[0,a]$ is equal to the number of negative diagonal entries in the diagonal (D) matrix of the LDL decomposition [2] of $\mathbf{K}-a\mathbf{M}$. We can easily compute the latter, and therefore by counting the eigenvalues in $[0,a]$ ($count_a$) and $[0,b]$ ($count_b$) the number of eigenvalues in $[a,b]$ will be $count_b-count_a$.

This is a useful tool for checking that we have indeed correctly found all eigenvalues that we were looking for, and is also required for the frequency interval solver in modal analysis.

[1] Ostrowski, Alexander M. "A quantitative formulation of Sylvester's law of inertia." Proceedings of the National Academy of Sciences 45.5 (1959): 740-744.

[2] Golub, Gene H., and Charles F. Van Loan. Matrix computations. JHU press, 2013.