I'm trying to get a better feeling about differential geometry and I was trying to prove that $G = \{ x \in M_2(\mathbb{R}) : xx^t = I\}$ has a manifold structure. My approach was to set $X = M_2(\mathbb{R})$ and consider the smooth map $f: X \rightarrow X, f(x) = xx^t - I$. The regular value theorem says that if the tangent space map $T_x(f): T_x(X) \rightarrow T_0(X)$ is surjective for all $x \in f^{-1}\{0\} = G$, then $G$ is a submanifold of $X$. This is what I wanted to show in order to prove that $G$ has a manifold structure.
Identifying $X$ with $\mathbb{R}^4$ via $\begin{pmatrix} a & b \\ c & d \end{pmatrix} = (a,b,c,d)$, and taking the basis of the tangent space at a point $p$ to be $\frac{d}{dx_1}|_p, ... , \frac{d}{dx_4}|_p$, the matrix of the tangent map at any $p \in f^{-1}\{0\}$ is just the Jacobian evaluated at $p$. Checking that
$$f(x_1,x_2,x_3,x_4) = (x_1^2+x_2^2 -1, x_1x_3 + x_2x_4, x_1x_3 + x_2x_4, x_3^2 + x_4^2 - 1)$$ we see that the Jacobian of $f$ is
$$\begin{pmatrix} 2x_1 & 2x_2 & 0 & 0 \\ x_3 & x_4 & x_1 & x_2 \\ x_3 & x_4 & x_1 &x_2 \\ 0 & 0 & 2x_1 & 2x_4 \end{pmatrix}$$
which is never invertible. Hence the tangent space map is never surjective. So this approach fails.
On the other hand, this blog uses a similar approach with the regular value theorem, except it actually works. It notably uses the space of symmetric matrices as the codomain, rather than the space of all matrices.
My question: If I were more experienced in differential geometry, how can I know that my approach above is destined to fail? How would I recognize that I need to shrink my codomain to a manifold of smaller dimension? Does this have something to do with the fact that the orthogonal group itself has smaller dimension?
This is, in fact, a particular case of the following general story:
Let $M$ and $N$ be smooth manifolds, and let $f:M\to N$ be smooth. Now assume that $N$ is an embedded submanifold of another manifold, $L$, such that $\dim L>\dim N$. Then one can think of $f$ as a smooth map $M\to L$, but then $f$ has no regular points at all!
Now let us return to the question. You have the map $A\mapsto A^tA-I$, whose values all lie in the space of symmetric matrices. This space has a strictly smaller dimension than the space of all matrices. Hence, as in the previous paragraph, no value in the image of the map can be regular, once you take your codomain to be the space of all matrices.
Long story short, whenever you wish to use the regular value theorem, you should choose your codomain to have the least possible dimension. Otherwise, your attempt will certainly fail.