TITLE: Diagonalization of symmetric matrix
QUESTION [6 upvotes]: Suppose we have a symmetric matrix $A \in \mathbb R^{n \times n}$ (for example, the matrix corresponding to a quadratic form) which we want to diagonalize.  
Now the usual way to do this is to find an orthonormal basis of $\mathbb R^n$ constisting of eigenvectors of $A$ (the spectral theorem always guarantees the existence of such) and the resulting matrix $Q \in O_n(\mathbb R)$ is such that $QAQ^{-1}$ is diagonal.  
However, sometimes the task is to diagonalize a quadratic form, but not the way I just described, but by performing simultaneous column and row transformations (we can do that due to Sylvester's inertia theorem).
Now my questions:
Are these procedures completely different from each other or are they doing the same thing? Why don't I use the spectral theorem to diagonalize a quadratic form or why don't I use the $2$nd procedure to diagonalize a general symmetric matrix? 
I suppose this has to do with the type of transformation, i.e. orthogonal or not, but I would like to have some good explanation.

REPLY [5 votes]: This is a good question. From a more abstract and coordinate independent point of view, the two procedures are actually applied to two different objects and result in something different. The two scenarios are:

You have a finite dimensional real inner product space $(V, \left< \cdot, \cdot \right>)$ and a self-adjoint operator $T \colon V \rightarrow V$. You want to find an orthonormal basis $e_1,\dots,e_n$ of $V$ (that is,  $\left< e_i, e_j \right> = \delta_{ij}$) such that $Tv_i = \lambda_i v_i$ for some $\lambda_i \in \mathbb{C}$. In other words, you want to find an orthonormal basis of eigenvectors of $T$.
You have a finite dimensional vector space (over a field of characteristic $\neq 2$) and a symmetric bilinear form $B \colon V \times V \rightarrow \mathbb{F}$. You want to find a basis $e_1,\dots,e_n$ of $V$ such that $B(v_i, v_j) = 0$ for $i \neq j$. Such a basis is called $B$-orthogonal.

This becomes confusing when you represent the objects involved as matrices because unfortunately, both symmetric bilinear forms and self adjoint operators are represented as matrices by the same object - a symmetric matrix. More precisely:

A symmetric operator $T$ is represented with respect to an orthonormal basis $\beta$ by a symmetric matrix $A = [T]_{\beta} \in M_n(\mathbb{R})$. With respect to a different orthonormal basis $\beta'$, it will be represented by a different matrix $[T]_{\beta'} = Q^{-1} A Q$ where $Q$ is the change of basis matrix between $\beta$ and $\beta'$. Since both bases are orthonormal, $Q$ is actually orthogonal so we have $Q^{-1} A Q = Q^T A Q$. If $\beta'$ consists of eigenvectors of $T$, we have $Q^T A Q = D$ where $D$ is diagonal. 
From the matrix point of view, given a symmetric matrix $A \in M_n(\mathbb{R})$, to orthogonally diagonalize $A$ we must find an orthogonal matrix $Q$ such that $Q^T A Q$ is diagonal. Here, there will  be many different orthogonal matrices $Q$ such that $Q^T A Q$ is diagonal but, up to possible reordering, the diagonal elements will always be the same (they are the eigenvalues of $A$).
A symmetric bilinear form $B$ is represented with respect to an arbitrary basis $\beta$ of $V$ also by a symmetric matrix $A = [B]_{\beta}$. With respect to a different basis $\beta'$, it will be represented by a different matrix $[B]_{\beta'} = Q^T A Q$ where $Q$ is the change of basis matrix between $\beta$ and $\beta'$.
From the matrix point of view, given a symmetric matrix $A \in M_n(\mathbb{F})$, to diagonalize $A$ by congruence we must find an invertible matrix $Q$ such that $Q^T A Q$ is diagonal. Here, there will be many invertible matrices $Q$ such that $Q^T A Q$ is diagonal but the diagonal entries won't be the same, even up to reordering.

Finally, let's answer your questions.

Why don't I use the spectral theorem to diagonalize a quadratic form? 
First, the algorithm for diagonalizing a quadratic form works over any field of characteristic $\neq 2$ while the spectral theorem works only over $\mathbb{R}$ so you can't use the spectral theorem unless working with real matrices. Even if you work with real matrices, using the spectral theorem to diagonalize a quadratic form is an overkill. Indeed, the spectral theorem guarantees an orthogonal matrix $Q$ such that $Q^{-1} A Q = Q^T A Q = D$ but to diagonalize the quadratic form, you only need an invertible $Q$, not an orthogonal one. 
If you want to use the spectral theorem, you will have to start by finding the eigenvalues of $A$ which involves find the roots of an $n$ degree polynomial. Since there is no closed formula for the roots, you'll have to approximate them and then find the eigenvectors which will also be approximations and so on. But if you use simultaneous row/column operations, you don't need to find the eigenvalues of $A$! If $A$ has rational entries, you'll get an invertible matrix $Q \in M_n(\mathbb{Q})$ which can be computed exactly (assuming you can do perfect rational arithmetic) such that $Q^T A Q$ is diagonal. Of course, $Q$ won't necessarily be orthogonal but it doesn't matter for the purpose of diagonalizing a quadratic form by congruence.
The only reason to use the spectral theorem to diagonalize a quadratic form is that you are given a symmetric form $B$ on an inner product space $(V, \left< \cdot, \cdot \right>)$ and you want to find a basis $(e_1,\dots,e_n)$ of $V$ which is both $B$-orthogonal and $\left< \cdot, \cdot \right>$-orthonormal. Finding only a $B$-orthogonal basis is much easier using simultaneous row/column operations.
Why don't I use the 2nd procedure to (orthogonally) diagonalize a general symmetric matrix?
The second procedure will only give you an invertible matrix $Q$ such that $Q^T A Q = D$. It won't give you an orthogonal matrix so $Q^T \neq Q^{-1}$ and this is not orthogonal diagonalization (and not even regular diagonalization). This is not surprising because to diagonalize $A$, you must know the eigenvalues of $A$ and the row/column operations procedure just doesn't give you that.