How to compute dimension of $O(n,\mathbb{R})$ Let $f:GL(n,\mathbb{R})\to GL(n,\mathbb{R})$ be the smooth map $A\mapsto A^TA$. Observe that $f$ has constant rank on $GL(n,\mathbb{R})$ by chain rule and that $O(n,\mathbb{R})$ is the preimage of $I$, therefore is a regular submanifold. 
To compute the dimension of $O(n,\mathbb{R})$, it thus suffices to compute the rank of $f$ at any point, e.g at $I$. In an appropriate choice of bases, the matrix of $Df|_{I}$ is given by
$$\left[\frac{\partial f^{ij}}{\partial x^{kl}}|_I\right]$$
where $(i,j)$ with $1\le i,j\le n$ gives the row index and $(k,l)$ $1\le k,l\le n$ gives the column index.
So how do I proceed from here really?    

Note that the above $f$ can be thought of as $f:M_{n\times n}\mathbb{R}\to Sym_{n\times n}\mathbb{R}$. It is not very hard to show that this makes $I$ a regular value of $f$ (see explanation below), thus $$\dim O_n(\mathbb{R})=\dim f^{-1}(I)=\dim M_{n\times n}\mathbb{R}-\dim Sym_{n\times n}\mathbb{R}=n^2-\frac{n(n+1)}{2}=\frac{n(n-1)}{2}.$$To show that $I\in Sym_{n\times n}(\mathbb{R})$ is indeed a regular value of $f$, one shows first that $$df_I:T_IM_{n\times n}\mathbb{R}\to T_ISym_{n\times n}\mathbb{R}$$is surjective, by dierct calculation. Then, given $O\in O_n(\mathbb{R})$, let $L_O:M_{n\times n}\mathbb{R}\to M_{n\times n}\mathbb{R}$ be left multiplication by $O$, and note that $f=f\circ L_O$. Since $L_O$ is clearly a diffeomorphism, it follows that $df_{O^{-1}}=df_I\circ {dL_O}_{O^{-1}}$ is surjective.
