TITLE: Matrix Representation of Inner Product
QUESTION [9 upvotes]: In my readings I have on several occasions encountered references to a linear algebra theorem that runs as follows:
Let $g$ be a non-degenerate inner product on the real vector space $V$. Then, there exists a basis $e_1, \dots, e_n$ such that the matrix of $g$ is diagonal and whose diagonal entries are all either $-1$ or $1$
Despite having encountered this result several times, unfortunately, I have not had the luck of finding a precise reference to where this theorem is stated/proved. Can anyone provide a reference that proves this claim?

REPLY [5 votes]: Here's a proof. Let $B : V \times V \to \mathbb{R}$ be a symmetric bilinear form. It suffices to show by induction that we can write $V = \text{span}(v) \oplus W$ for some nonzero vector $v$ such that $B(v, w) = 0$ for any $w \in W$ and such that $B(v, v) = 0, 1, -1$. 
Choose an inner product $\langle \cdot, \cdot \rangle$ on $V$ (unrelated to $B$) and let $S^{n-1}$ denote its unit sphere. Let $v \in S^{n-1}$ be such that $B(v, v)$ is maximal. Let $w$ be a unit vector orthogonal to $v$; then
$$B(v + tw, v + tw) = B(v, v) + 2t B(v, w) + t^2 B(w, w) \le (1 + t^2) B(v, v)$$
by hypothesis, hence $2 B(v, w) \le t(B(v, v) - B(w, w))$. Taking $t = 0$ gives $B(v, w) \le 0$, and applying this result to $-w$ gives $B(v, w) = 0$. Depending on the value of $B(v, v)$ we can rescale $v$ so that $B(v, v) = 0, 1, -1$ and take $W$ to be the orthogonal complement of $v$ (with respect to the inner product). 
Taking $B = \langle v, Aw \rangle$ where $A$ is symmetric and positive-definite, the intuitive content of the above proof is that $v$ is an axis of the ellipse $B(v, v) = 1$. Note that I haven't actually proven the full content of the law of inertia, which states in addition that the number of times $0, 1, -1$ appears doesn't depend on the choice of decomposition.