Solution (source code)

= Solution

Multiplication by $\mathbf v^*$ gives
$$
\lambda=\frac{\mathbf v^*A\mathbf v}{\mathbf v^*B\mathbf v}.
$$
The numerator is real because $A$ is symmetric, while the denominator is strictly positive because $B$ is <positive-definite matrix>[positive definite]. Hence $\lambda$ is real. As $A-\lambda B$ is real and singular, its kernel contains a nonzero real generalized eigenvector.