Today's arXiv has a paper by Pierpaolo Vivo, Index of a matrix, complex logarithms, and multidimensional Fresnel integrals, which asks the question whether it is possible to calculate the number $N(\lambda_1,\lambda_2)$ of eigenvalues of a real symmetric matrix $M$ that lie in the interval $(\lambda_1,\lambda_2)$ , without explicitly diagonalizing the matrix. The author points out that a certain formula in the literature based on the branch-cut structure of the complex logarithm generically fails to produce the correct result.
In a discussion with my colleagues (thank you, Fabian & Inanc) we could fix this branch-cut ambiguity by first differentiating the logarithm and then integrating,
$$N(\lambda_1,\lambda_2)=\frac{1}{2\pi i}\lim_{\epsilon\rightarrow 0^+}\int_{\lambda_1}^{\lambda_2}d\lambda\; \frac{d}{d\lambda}\left[\log\det(M-\lambda+i\epsilon)-\log\det(M-\lambda-i\epsilon)\right].$$
As an example, applied to the matrix $M$ defined in equation 3 of the cited paper this gives the following plot for $N(-15,\lambda)$ as a function of $\lambda$, in agreement with the eigenvalues at $-11.03, -2.80, -0.63, 2.464$.
Question: From a computational point of view, this method to count levels is unlikely to be efficient relative to a direct diagonalization. The cited paper develops a method based on Fresnel integrals. Is there an alternative more efficient approach?
I note an earlier MO question along the same lines, but for the specific case of a random matrix with localized eigenstates; here the idea is to have a method that works generically.