Show that $O(n,\mathbb{R})$ the set of all orthogonal matrices is closed in $M(n,\mathbb{R})$
Let $$f:M(n,\mathbb{R}) \mapsto \mathbb{R}$$
$$ f:A \mapsto det(A.A^t)$$
We know that $$ \text{det}(x_{i,j})= \sum_\sigma \text{sgn}(\sigma) \prod_{i=1}^{n} x_{\sigma(i),i} $$ The determinant function is continuous as it is a polynomial function in $x_1,\cdots x_n$. Then $det(A.A^t)$ is also a polynomial in $x_1,\cdots x_n$ . Any function from $M(n,\mathbb{R})$ to a polynomial in $x_1,\cdots , x_n$ is continuous. So the following map $f$ is continuous.
$O(n,\mathbb{R}) = f^{-1}(\{1\})$.
The singleton $\{1\}$ is a closed set in $\mathbb{R}$. Hence, $O(n,\mathbb{R})$ is a closed set in $M(n,\mathbb{R})$.
I have not seen any answer in stackexchange similar to this method. Is my procedure incorrect? Also can we extend the following method to prove that $SO(n,\mathbb{R})$ is continuous?
Here's my attempt for $SO(n,\mathbb{R})$ I was thinking of the following map $f:M(n,\mathbb{R}) \mapsto \mathbb{R}$ where $A \mapsto det(A).det(A^t)$ . I think that the following map will be continuous but I am not sure whether $f^{-1}(\{1\}) = SO(n,\mathbb{R})$?