# Orthogonal matrix Q of A such that $Q^T A Q$ is a diagonal matrix

Given a matrix $A$, how could I find an orthogonal matrix $Q$ such that $Q^t A Q$ is a diagonal matrix?

-
This is called diagonalization and will require an iterative method for dimension greater than $4$. Dimension $2$ can use a formula (almost exactly) related to the quadratic formula. It is a difficult problem in general, but there is much on the subject; Diagonalizable_matrix –  adam W Jan 22 '13 at 13:37
BTW, I just noticed you did not specify that $A$ is symmetric. This must be the case as a diagonal matrix is symmetric. Since you have $A = QDQ^T$ with $QQ^T=I$ ($Q$ orthogonal), then $A$ must necessarily be symmetric. –  adam W Jan 22 '13 at 13:40
What iterative method? The method I was taught was to construct an orthormal basis of $\mathbb{R}^n$ consisting of eigenvectors of A. –  fretty Jan 22 '13 at 13:41

You want to find $Q$ and $B$ with $\det Q \neq 0$ such that $$\tag{1}A= Q^t B Q.$$

First you should separate the matrix $A$ in the symmetric and antisymmetric part $$A_s = \tfrac12 (A+ A^t) \text{ and } A_a= \tfrac12 (A- A^t)$$ with $A= A_s + A_a$.

Sylvester's law of inertia states that $$A_s = Q^t D Q$$ with $$\tag{2}D= \begin{pmatrix} 1 \\& \ddots \\ && 1 \\&&&0\\&&&&\ddots\\&&&&&0\\&&&&&&-1\\&&&&&&&\ddots\\&&&&&&&&-1\end{pmatrix}.$$

The problem is what you will do with the antisymmetric part $A_a$. But it is easy to see that the antisymmetric part cannot be diagonalized via congruence relation (1). In fact given the antisymmetry of $A_a$, $A_a = - A_a^t$, $B_a = -B_a^t$ for and $B= Q^t A Q$, i.e., antisymmetry is preserved. The only antisymmetric matrix which is diagonal is the 0-matrix and as the 0-matrix is only congruent to each self we need to have $A_a = 0$ in order that $A$ can be diagonalized.

Concluding:

• Given $A=A^t$, we can write it in the form (1) with the matrix $B=D$ of the form (2). A method to obtain this is quadratic completion. Define $Q(\mathbf{x})= \sum_{ij} x_i A_{ij} x_j$ and complete the square that is write $Q$ in the form $$Q(\mathbf{y}) = \sum_i D_{ii} y_i^2$$ with $D_{ii}=\{0,\pm1\}$ and $y_i =\sum_j Q_{ij} x_j$.

• If $A\neq A^t$, we cannot write $A$ in the form (1).

-
@fretty: I just saw that you want to have an orthogonal matrix $Q$. The method I outlined in my answer does not yield and orthogonal matrix. For $Q$ to be orthogonal, you have to solve an eigenvalue problem (which is much harder). Could you please un-accept my answer such that I can delete it? –  Fabian Jan 22 '13 at 14:33
Still the statement holds, that only symmetric matrices can be made diagonal. –  Fabian Jan 22 '13 at 14:33
Perhaps this is enough for the OP. If not, perhaps you can edit your answer to make $Q$ orthogonal. Otherwise, if the OP does not respond, flag a mod again in a couple of days. –  robjohn Jan 22 '13 at 16:26