Let $G$ be a group and $H = \{ g \in G \mid gx = xg \ \forall x \in G \}$. Show that $H \leqslant G$ and that $H$ is commutative. 
Let $G$ be a group and $H = \{ g \in G \mid gx = xg \ \forall x \in G \}$. Show that $H \leqslant G$ and that $H$ is commutative.

How can I show that $H \leqslant G$? This seems to me that I would want to show that $H$ is a subgroup of $G$? That would seem to imply the statement $H \leqslant G$. So I would need to show that $H$ is non empty and closed under products and inverses?
Let $h\in H$, then $hh^{-1} = e_G$ right? So the inverse is there. How can I show the closure under products here?
 A: Recall that for $H$ to be a subgroup of $G$, it suffices to prove that for all $a, b \in H$, we have $ab^{-1} \in H$.
Suppose $a, b \in H$. We have $x^{-1} b = b x^{-1}$ for all $x \in G$, which is equivalent to $b^{-1}x = xb^{-1}$. We now multiply with $a$ from the left and get
$ab^{-1}x=axb^{-1}$. Now use that $a$ commutes and associativity, and arrive at
$$(ab^{-1})x = x(ab^{-1}),$$
which finishes the proof.
EDIT: In order to use this subgroup test, it is also necessary to show that $H$ is non-empty. This is trivial since the identity element of $G$ will always be in $H$.
A: To check closure under inverses you have to show that $h^{-1}\in H$. You only know that $h$ is invertible as element of $G$, that is there is $h^{-1}\in G$ such that $hh^{-1}=e_G$ but it might be the case that $h^{-1}\in G\setminus H$, i.e. that the inverse is not in the subset $H\subseteq G$. Similarily, you have to show that $e_G\in H$ and that if $h_1,h_2\in H$ implies that $h_1h_2\in H$.

Let's take a closer look at the inverses. We are given $h\in H$ and want to show that $h^{-1}\in H$ which is to say that $h^{-1}x=xh^{-1}$ for all $x\in G$. We are given that $xh=hx$ since by assumption $h\in H$. Now, first multiply from the left by $h^{-1}$ and then from the right by $h^{-1}$ to get:
$$xh=hx\quad\implies\quad h^{-1}xh=x\quad\implies\quad h^{-1}x=xh^{-1}$$
Now, show that $xe_G=e_Gx$ for all $x\in G$ and that if $h_1,h_2\in H$ then $x(h_1h_2)=(h_1h_2)x$ for all $x\in G$ to complete the proof.

Aside: the subgroup you are dealing with is called the center of $G$, denoted by $Z(G)$ and measures "how abelian" the group is. We have, for instances $G=Z(G)$ if and only if $G$ is abelian.
A: If $gx=xg$ for all $x\in G$ i.e. $g\in H$ and $hx=xh$ for all $x\in G$ i.e. $h\in H$ then
$$(gh)x=g(hx)=g(xh)=(xh)g=x(hg)=x(gh)$$for all $x\in G$ and thus $gh\in H$ i.e. $H$ is closed under multiplication.
A: $H$ is the $\it{center}$ of $G$ and is denoted $\mathcal Z(G)$. Let $g$ be variable over $G$ and note $$xgx^{-1}=g\iff x^{-1}gx=g$$
$$\begin{align}&\therefore\;x,y\in H\implies g=xgx^{-1}=y^{-1}gy\implies (xy^{-1})g(yx^{-1})=x(y^{-1}gy)x^{-1}=g\\&\therefore\;x,y\in H\implies xy^{-1}\in H\\ &\therefore H\leq G\end{align}$$
