What is degrees of freedom of a real orthogonal marix? How can I find the degrees of freedom of a $n \times n$ real orthogonal matrix?
I have tried to proceed by principle of induction but I fail.Please tell me the right way to proceed.
Thank you in advance.
 A: For an $n \times n$ matrix with column vectors $v_1 \dots v_n$, we say that it is orthogonal if,
$$
\langle v_i, v_j \rangle = 0,\ \ \ \forall (i,j)\ \Big{|}\ i\neq j
$$
Recalling that the inner product is commutative, the above gives us this many unique constraint equations:
$$\sum_{k=1}^{n-1} k = \frac{n(n-1)}{2}$$
The matrix has $n^2$ elements, so in the orthogonal case,
$$ \text{dof}_\text{orthogonal} = n^2 - \frac{n(n-1)}{2}$$
If we also require that the matrix is orthonormal, then there are $n$ more constraints of the form,
$$
\langle v_i, v_i \rangle = 1,\ \ \ \forall i
$$
and so in the orthonormal case,
\begin{align}
\text{dof}_\text{orthonormal} &= n^2 - \frac{n(n-1)}{2} - n\\
&= \frac{n(n-1)}{2}
\end{align}
This proves that $2 \times 2$ orthonormal matrices have 1 degree of freedom and that $3 \times 3$ orthonormal matrices have 3 degrees of freedom, which agrees with our intuition about rotations.
A: Answer to @Distracted Kerl and to the question asked by the OP.
There are essentially $2$ proofs of the required result; both uses the famous formula $1+2+\cdots+n=n(n+1)/2$. You chose the most difficult one. 
$O(n)$ is an algebraic set. If $A\in O(n)$, then there is an orthogonal $P$ s.t. $P^TAP$ is in your above form.
Step 1. If you leave the $\pm 1$, then you only have $k$ degrees of freedom while you can have $\approx n/2$ degrees of freedom. The key is to consider the open dense subset constituted by $Z=\{A\in O(n); A$ has distinct pairwise conjugate eigenvalues and at most $1$ real eigenvalue$\}$. Such a matrix $A$ is orthogonally similar to 
i) $diag(R_{a_1},\cdots,R_{a_p})$ when $n=2p$ ($p$ degrees of freedom) OR
ii) $diag(R_{a_1},\cdots,R_{a_p},\pm 1)$ when $n=2p+1$ ($p$ degrees of freedom).
We assume that the $(a_i)$ are distinct $mod\;2\pi$.
Step 2. We use a stratification using the Grassmannian varieties $G_{m,k}=\{V;V$ is a  vector subspace of $\mathbb{R}^m$ of dimension $k\}$; note that 
$(*)$ $G_{m,k}$ is an algebraic set of dimension $k(m-k)$.
Case i). To obtain all the matrices $A$ under the action of $P$ is equivalent to choose orthogonal planes $\Pi_1,\cdots,\Pi_{p}$. The numbers of degrees of freedom are 
for $\Pi_1$: $2.(2p-2)$ (according to $(*)$ with $m=2p$)
for $\Pi_2$:$2(2p-4)$ (according to $(*)$ with $m=2p-2$ since $\Pi_2$ is included in the orthogonal of $\Pi_1$), $\cdots$
The sum of degrees of freedom (for the action of $P$) is $4.(1+2+\cdots+(p-1))=2p^2-2p$ (the famous formula).
Finally when we consider the $p$ angles of the rotations $R_{a_i}$ we obtain $p(2p-1)=n(n-1)/2$ degrees of freedom.
Case ii). In the same way as above.
