Is $U:=\{A \in \mathbb{Q}^{n \times n} | AX = XA, \quad \forall X \in M \}$ sub vector space of $\mathbb{Q}^{n \times n}$? Let $n \in \mathbb{N}, n \geq 2$ and $M \subseteq \mathbb{Q}^{n \times n}$. Show that $U:=\{A \in \mathbb{Q}^{n \times n} | AX = XA, \quad \forall X \in M \}$ is a sub vector space of $\mathbb{Q}^{n \times n}$.
Question: Is my solution to that task correct? I am not sure if it is, because I had trouble with the set notation of $U$.
My solution:
Let $A$ be the Nullmatrix. 
Then $AX=0\cdot X = 0 = X \cdot 0, \quad \forall X \in M$. Thus $0 \in U \Rightarrow U \neq \emptyset$. 
Let $u_1=\{A_1 \in \mathbb{Q}^{n \times n} | A_1X = XA_1, \quad \forall X \in M \}$ and $a \in \mathbb{Q}$.
Because $A_1X=XA_1 \Leftrightarrow A_1X-XA_1=0$
\begin{align}
a \cdot u_1 &\Rightarrow a(A_1X - XA_1) = 0 \\
&\Leftrightarrow aA_1X-aXA_1=0 \\
&\Leftrightarrow (aA_1)X-X(aA_1) =0 \\
\end{align}
Scalar multiplication is defined so this equation is valid. Thus, $a \cdot u_1 \in U$.
Let $u_1=\{A_1 \in \mathbb{Q}^{n \times n} | A_1X = XA_1, \quad \forall X \in M \}$, $u_2=\{A_2 \in \mathbb{Q}^{n \times n} | A_2X = XA_2, \quad \forall X \in M \}$ and $a \in \mathbb{Q}$.
Then: 
$u_1=A_1X=XA_1 \Rightarrow A_1X-XA_1=0 \qquad u_2=A_2X=XA_2 \Rightarrow A_2X-XA_2=0$
\begin{align}
u_1+u_2 &= (A_1X-XA_1)+(A_2X-XA_2) \\
&= A_1X-XA_1+A_2X-XA_2 \\
&=A_1X+A_2X-(XA_1+XA_2) \\
&=(A_1+A_2)X-X(A_1+A_2) \\
&=0 \\
\end{align}
Thus $U$ is a sub vector space of $\mathbb{Q}^{n \times n}$.
 A: Your solution is not bad, but you misuse the notation.  I hope my comment clarifies things a little bit :
Given a subset $M$ of $\textsf{M}_{n \times n}(\mathbb Q)$ (the set of all matrices of size $n\times n$ and entries in $\mathbb Q$), we define
$$U:= \{A\in \textsf{M}_{n \times n}(\mathbb Q): \, AX=XA \textrm{ for all } X\in M\}$$
this set consists of all those matrices in which the product commutes with all matrices of $ M $.
If $O$ denotes the $n\times n$ zero matrix, it is clear that for any matrix $ X $ of $ M $, the product
$$OX= O =XO$$
conmute, that is, the matrix $O$ belongs in $U$.
Now, given $A$ and $B$ matrices in $U$ we have
$$AX=XA \quad \textrm{for all } X\in M$$
and 
$$BX=XB \quad \textrm{for all } X\in M$$
you have to check that their sum $ A + B $ also satisfies the property, but this is easy since
$$(A+B)X =AX +BX = XA +XB = X(A+B)$$
so, the matrix $A+B$ also belongs in $U$. Finally, it must be verified that if $ A $ is in $ U $, the matrix $ cA $ is also in $ U $ for any scalar $ c $. Look, given $A$ in $U$ and $c\in \mathbb Q$ we have
$$(cA)X=c(AX)=c(XA)=X(cA)$$
then $cA$ is in $U$. Therefore, we can conclude that $ U $ is a vector subspace of $\textsf{M}_{n \times n}(\mathbb Q)$.
