TITLE: A conjecture regarding the eigenvalues of real symmetric matrices
QUESTION [7 upvotes]: It is well-known that the solutions of
$$|M-\lambda I|=0$$
are purely real if $M$ is real symmetric.

Conjecture This is still true if we replace the identity matrix by a diagonal matrix $D$ whose diagonal elements are either $0$ or $1$:
$$\left. \begin{matrix}|M-\lambda D|=0 \\ M\text{ is real symmetric}\\M\text{ and }D\text{ do not have a common nullspace}\end{matrix}\right\}\implies \lambda \in \mathbb{R}\text{ (if a solution exists)}$$

Partial proof
Without loss of generality we can assume
$$D=\text{diag}(1,1,\cdots,1,1,0,0,\cdots,0,0)$$
If $M$ is symmetric,
$$|M-\lambda D|=\left|\begin{matrix}M_1-\lambda I & M_2 \\ M_2^T & M_3\end{matrix}\right|$$
with $M_1,M_3$ symmetric. If $M_3$ is invertible,
$$\left|\begin{matrix}M_1-\lambda I & M_2 \\ M_2^T & M_3\end{matrix}\right|=|M_3||M_1-M_2 M_3^{-1}M_2^T -\lambda I|$$
$|M_3|\neq 0$ by hypothesis, so
$$|M-\lambda D|=0\implies |M_1-M_2 M_3^{-1}M_2^T -\lambda I|=0$$
thus $\lambda$ is an eigenvalue of the symmetric matrix $M_1-M_2 M_3^{-1}M_2^T$, and is therefore real.
Question
What if $M_3$ is not invertible? The condition that $M_3$ is invertible does not appear to be necessary, for example
$$\left|
\begin{array}{ccc}
 e-\lambda  & a & b \\
 a & d-\lambda  & c \\
 b & c & 0 \\
\end{array}
\right|=0$$
has a single real solution. Another example, where $M_3$ is $2\times 2$ and nonzero:
$$\left|
\begin{array}{cccc}
 1-\lambda & 2 & 5 & 4 \\
 2 & 1-\lambda & 3 & 6 \\
 5 & 3 & 1 & 1 \\
 4 & 6 & 1 & 1 \\
\end{array}
\right|=0$$
$$\lambda=-\frac{151}{5}$$

REPLY [2 votes]: The result can be proven using the same arguments as in the proof that the eigenvalues of symmetric matrices are real.
Let $x\ne0$ solve $Mx=\lambda Dx$ for some possibly complex $\lambda$. 
If $Dx=0$, then it holds $Mx=0$, and $\lambda$ can be arbitrary. This corresponds to an infinite generalized eigenvalue of the matrix pencil $(M,D)$.
Under your assumption, that $M$ and $D$ do not have common null space, then this case cannot happen.
Now let $Dx\ne0$. Since $D$ is diagonal with non-negative entries, it follows $x^HDx\ne0$. Then
$$
\lambda x^HDx = x^HMx = (Mx)^Hx= (\lambda Dx)^Hx=\bar\lambda x^HDx.
$$
This implies $\lambda=\bar\lambda$, and $\lambda$ is a real number.
Note, that this argument also works if $D$ is assumed to be symmetric positive semidefinite, as then $Dx\ne0$ implies $x^HDx\ne0$.