By
Lemma 4.3.9, there is a unique symmetric matrix
\(A\) which represents
\(Q\) relative to the standard basis. But the Spectral Theorem then says that
\(A\) is diagonalizable,
the eigenvalues are all real,
there is an eigenbasis which is an orthonormal basis \(\mathcal{B} = \{\mb{v}_1, \ldots, \mb{v}_n\}\text{.}\)
\begin{equation*}
P^{-1} A P = \textnormal{Diag} (\lambda_1 , \ldots, \lambda_n )
\end{equation*}
where the columns of the matrix \(P\) are the eigenvectors \(\mb{v}_1, \ldots, \mb{v}_n\text{.}\) But since these are orthonormal, we have that the matrix \(P^{-1} = P^T\) (check this by writing the rows of \(P^T\) as \(\mb{v}_1^T, \ldots, \mb{v}_n^T\) and observing that the \((i,j)\)-entry of \(P^T P\) is the dot product of the \(i\)-th row of \(P^T\) with the \(j\)-th column of \(P\)). Thus
\begin{equation*}
P^T A P = \textnormal{Diag} (\lambda_1 , \ldots, \lambda_n )
\end{equation*}
and
Lemma 4.3.9 implies that
\(Q\text{,}\) relative to the basis
\(\mathcal{B}\text{,}\) is represented by this diagonal matrix. Thus in this coordinate system,
\begin{equation*}
Q(x_1, \ldots, x_n) = \mb{x}^T \textnormal{Diag} (\lambda_1 , \ldots, \lambda_n ) \mb{x} = \lambda_1 x_1^2 + \cdots + \lambda_n x_n^2 .
\end{equation*}
The last statement is not directly implied by what we have above, since it is a statement about changing to any basis, not just orthonormal bases (and is the main point of Sylvester’s law of inertia). To prove this last statement, consider the pairing
\begin{equation*}
B( \mb{x}, \mb{y} ) = \frac{1}{2} \left[ Q ( \mb{x} + \mb{y} ) - Q ( \mb{x} ) - Q ( \mb{y} ) \right].
\end{equation*}
It is not hard to show that \(B\) satisfies conjugate symmetry (although the conjugate part is not important here because we are working with a real vector space) and linearity. It does not, however, always satisfy the positive definite property.
Suppose exactly \(n_+\) of the eigenvalues \(\lambda_1, \ldots, \lambda_n\) are positive and order them so that these occur as the first ones \(\lambda_1, \ldots, \lambda_{n_+} > 0\) and define the subspace \(V = \textnormal{span} \, \{ \mb{v}_1, \ldots, \mb{v}_{n_+} \}\text{.}\) Observe that \(B\) is in fact a positive definite pairing on \(V\) because if \(\mb{v} = a_1 \mb{v}_1 + \cdots + a_{n_+} \mb{v}_{n_+}\) is non-zero then
\begin{equation*}
B ( \mb{v} , \mb{v} ) = \lambda_1 a_1^2 + \cdots + \lambda_{n_+} a_{n_+}^2 > 0 .
\end{equation*}
Note also that \(V^\perp = \span \{ \mb{v}_{n_+ + 1} , \ldots, \mb{v}_n \}\) (because \(\mathcal{B}\) is an orthonormal basis).
We claim that any vector subspace \(W\) of \(\mathbb{R}^n\) on which \(B\) is positive definite has dimension less than or equal to \(n_+\text{.}\) Indeed, restricting the projection \(\text{proj}_V\) to \(W\) gives a linear transformation
\begin{equation*}
\text{proj}_V : W \to V .
\end{equation*}
Since \(\dim V = n_+\text{,}\) the Rank-Nullity Theorem says that if \(\dim W \gt n_+\) then there is a non-zero element \(\mb{w}\) in the kernel of \(\textnormal{proj}_V\text{.}\) But the kernel of the projection map is \(V^\perp\) so that \(\mb{w}\) is in the span of \(\{ \mb{v}_{n_+ + 1} , \ldots, \mb{v}_n \}\text{.}\) Thus
\begin{equation*}
\mb{w} = b_{n_+ + 1} \mb{v}_{n_+ + 1} + \cdots + b_n \mb{v}_n
\end{equation*}
and
\begin{equation*}
B ( \mb{w} , \mb{w} ) = b_{n_+ + 1}^2 \lambda_{n_+ + 1} + \cdots b_n^2 \lambda_n \leq 0 .
\end{equation*}
This would contradict that \(B\) is positive definite on \(W\text{.}\) Thus \(n_+\) is indeed the maximal dimension of a subspace on which \(B\) is positive definite. Likewise, we can show that the number \(n_-\) of negative \(\lambda\)’s is the largest dimension of a subspace on which \(B\) is `negative definite’ (i.e. \(B( \mb{v} , \mb{v} ) \lt 0\) on non-zero vectors). Finally, \(n_0\) can be calculated as \(\dim V - n_+ - n_-\text{.}\)