Linear subspaces of $\mathrm{GL}_n(\mathbb{R})$ whose inverses are also linear subspaces $\DeclareMathOperator\GL{GL}$We will call a subset $S \subset \GL_n(\mathbb{R})$ a linear subspace if it is of the form $S = S'\cap \GL_n(\mathbb{R})$ for some $S'\subset M_n(\mathbb{R})$ which is a linear subspace (in the usual sense) of $M_n(\mathbb{R})$.
My question is, is there some sort of classification of the subsets $S\subset \GL_n(\mathbb{R})$ such that both $S$ and $S^{-1}$ are linear subspaces? (Here elements of $S^{-1}$ are precisely the inverses of elements of $S$.)
Note that:

*

*Any centralizer subgroup in $\GL_n(\mathbb{R})$ is an example.

*If $S_1,S_2\subset \GL_n(\mathbb{R})$ are examples, then so are $S_1\cap S_2$, $S_1^{-1}$, $S_1 A$, $AS_1$ for any $A\in \GL_n(\mathbb{R})$.

 A: $\DeclareMathOperator\GL{GL}$I think that there is probably too much variety in the examples to expect any clean classification.  Consider the following examples:
First, as I mentioned in my comment, for any $\mathbb{R}$-subalgebra $S'\subset M_n(\mathbb{R})$, the invertible elements $S = S'\cap \GL(n,\mathbb{R})$ will satisfy $S=S^{-1}$.  (If $S'$ has no invertible elements, this is trivial.  If $s\in S'$ is invertible in $M_n(\mathbb{R})$, i.e., $\det(s)\ne0$, then by Cayley–Hamilton, $I_n$ is a polynomial in $s$ and hence $s^{-1}$ is a polynomial in $s$ and so lies in $S'$.  Thus, $S^{-1}=S$.  There is no simple classification of the subalgebras of $M_n(\mathbb{R})$ that contain $I_n$ (i.e., that have invertible elements).
Second, the subspace $\Sigma_n\subset M_n(\mathbb{R})$ consisting of the symmetric $n$-by-$n$ matrices has the property that its set of invertible elements is linear in the OP's sense.  It's not a subalgebra of $M_n(\mathbb{R})$, though.  More generally, if $S'\subset M_n(\mathbb{R})$ is a subspace that contains $I_n$ and is closed under positive powers, i.e., $s\in S'$ implies that $s^k\in S'$ for all $k\ge 1$, then $S = S'\cap M_n(\mathbb{R})$ is linear in the OP's sense.   (The example of $\Sigma_n$ shows that such an $S'$ does not have to be a subalgebra.)
There are other examples that are not subalgebras.  For example, when $n=4$, take $S'\subset M_n(\mathbb{R})$ to be the $3$-dimensional subspace of matrices of the form
$$
s = \begin{pmatrix} a & b & c & 0\\-b&a&0&-c\\-c&0&a&b\\0&c&-b&a\end{pmatrix} = a\,I_4 + b\,\mathbf{i} + c\,\mathbf{j},
$$
and note that $s^{-1} = \bigl(a\,I_4 - b\,\mathbf{i} - c\,\mathbf{j}\bigr)/(a^2+b^2+c^2)\in S'$ when $s\ne0$, but $S'$ is not a subalgebra of $M_4(\mathbb{R})$. (It generates the quaternion subalgebra spanned by $I_4,\mathbf{i},\mathbf{j},\mathbf{k} = \mathbf{i}\mathbf{j}$.)
For a more exotic example, let $\mathbb{O}\simeq\mathbb{R}^8$ denote the (non-associative) algebra of octonions.  For $\mathbf{x}\in \mathbb{O}$, let $L_{\mathbf{x}}:\mathbb{O}\to\mathbb{O}$ be left multiplication by $\mathbf{x}$. Now let $S'\subset M_8(\mathbb{R})$ be the subspace of dimension $8$ spanned by $\{L_{\mathbf{x}}\ \vert\  \mathbf{x}\in \mathbb{O}\}$.  Because the octonions are not associative, $S'$ is not a subalgebra of $M_8(\mathbb{R})$, in fact, it generates $M_8(\mathbb{R})$.  Meanwhile, every nonzero element of $S'$ is invertible, and its inverse belongs to $S'$, so, setting $S = S'\cap \GL(8,\mathbb{R})$, one has $S^{-1} = S$.
