Calculating tangent spaces of Lie groups such as $SO(n)$ or $O(n)$ I was asking myself what was, given either $O(n)$ or $SO(n)$ as manifolds immersed in $\mathbb{R}^k$ for some natural $k$, the tangent space at a generic point $p$ of such a manifold. 
I know that I can, given a smooth map between manifolds $f: X \rightarrow Y$ and $q$ a regular value for $f$, express the tangent space at a point $p$ of $f^{-1}(q)$ as $Ker(d_{p}f)$ where $d_{p}f$ is the differential of $f$ at $p$; however, even if this lemma has proven using in a bunch of cases (like calculating such spaces when $p=I$), it could not lead me to a satisfying answer in the general one. I was wondering then if there exists some general way of describing such tangent space as a subset of $M(n)$ for a generic point $p$.
 A: It's easier to describe the tangent space $V$ at the origin $I=e$, then the tangent space at a point $g$ will be $g \cdot V$, the multiplication of $V$ on the left by $g$.
In general, the tangent space at $e$ of a subgroup $G$ consists of all the matrices $X$ so that $\exp (t X) \in G$ for all $t \in \mathbb{R}$.
Take the case $G= O(n, \mathbb{R})$. We need $\exp(t X)^T \cdot \exp (t X)= I$ for all $t\in \mathbb{R}$. Taking the derivative $\frac{d}{dt}$ we get $X^T \exp (t X)^T \exp (t X) + \exp(tX)^T \exp(tX) X= 0$ for all $t\in \mathbb{R}$. For $t=0$ we get $X^T + X = 0$. But conversely, if $X^T = - X$ then $\exp(tX)^T = \exp(tX^T) = \exp(- t X)= \exp(tX)^{-1}$ so $\exp(tX)\in O(n,\mathbb{R})$. So the tangent space at $I$ for $O(n,\mathbb{R})$ is the space of skew-symmetric matrices.
Another example: $G= SL(n,\mathbb{R})$. Here the condition is
$\det(\exp(tX)) = 1$. But $\det(\exp M) = \exp(\operatorname{trace}M)$. Therefore,the tangent space at $I$ for $SL(n,\mathbb{R})$ is the space of matrices of trace $0$.
The tangent space at origins behave well w.r to intersections.
A: The method you mention is actually very useful, it is just that too often, the devil is in the details.
Let $f:\mathbb{R}^{n\times n} \to S_n$ be defined by $f(A)=AA^\intercal$, where $S_n$ is the space of symmetric matrices. Then $f$ is a smooth function for which the identity matrix $I$ is a regular value, and so
$$O(n)=f^{-1}(I)$$ is a manifold. To find the tangent space at a generic point $P$ (a matrix), you could compute the directional derivative at $P$ as follows:
\begin{align*}\ker(df_P)=&\left \{A\in \mathbb{R}^{n\times n}\;|\; \lim_{t \to 0}\frac{f(P+tA)-f(P)}{t}=0\right \}\\
=&\left \{A\in \mathbb{R}^{n\times n}\;|\; \lim_{t \to 0}\frac{(P+tA)(P+tA)^{\intercal}-PP^\intercal}{t}=0\right \}\\
=&\left \{A\in \mathbb{R}^{n\times n}\;|\; PA^\intercal+AP^\intercal=0\right \}\\
\end{align*}
Thus, the tangent space of $O(n)$ at $P$ is collection of matrices $A$ such that $PA^\intercal$ is skew-symmetric.
To find it for $SO(n)$, it may be easier to find it for $SL(n)$ first. Using a similar method, define
$g:\mathbb{R}^{n\times n} \to \mathbb{R}$ by $g(A)=\det(A)$. This is another $C^\infty-$ smooth function having $1$ as a regular value, and $$SL(n)=g^{-1}(1).$$
To find the tangent space, we do as before:
\begin{align*}
\ker(dg_P)=&\left \{A\in \mathbb{R}^{n\times n}\;|\; \lim_{t \to 0}\frac{\det(P+tA)-\det(P)}{t}=0\right \}\\
=&\left \{A\in \mathbb{R}^{n\times n}\;|\; \lim_{t \to 0}\frac{\det(P^{-1})\det(P+tA)-\det(P)}{t}=0\right \}\\
=&\left \{A\in \mathbb{R}^{n\times n}\;|\; \lim_{t \to 0}\frac{\det(I+tP^{-1}A)-1}{t}=0\right \}\\
=&\left \{A\in \mathbb{R}^{n\times n}\;|\; \lim_{t \to 0}\frac{1+\text{tr}(P^{-1}A)t+O(t^2)-1}{t}=0\right \}\\
=&\left \{A\in \mathbb{R}^{n\times n}\;|\; \text{tr}(P^{-1}A)=0\right \},
\end{align*}
where we used that $\det(P^{-1})=1$ and that $\det(I+tM)=1+\text{tr}(M)t+O(t^2)$ as $t\to \infty$ (see here: https://en.wikipedia.org/wiki/Determinant).
Finally, to find the tangent space of $SO(n)=O(n)\cap SL(n)$, note that
$$T_P\big(O(n)\cap SL(n)\big)=T_P(O(n))\cap T_P(SL(n)),$$ so
$$T_p(SO(n))=\{A\in \mathbb{R}^{n\times n}\;|\; PA^\intercal+AP^\intercal=0 \; \land \; \text{tr}(P^{-1}A)=0\},$$
and we are done.
