Centralizer as a subgroup. Let $G$ be a group and $a\in G$. Define the centralizer of $a$ to be 
$\hspace{150pt} C(a)=\{g\in G : ga=ag\}$.
That is, $C(a)$ consists of all the elements that commute with $a$. Show that $C(a)$ is a subgroup of $G$. 

Clearly $C(a)$ is nonempty. Since $G$ is a group, $\exists e\in G$ such that $ea=ae=a$, so $e\in C(a)$. It is also clear that $a,g\in C(a)$ since $aa=aa=a^2$ and $ga=ag$ by definition. 
Now suppose $(ag^{-1})a\ne a(ag^{-1})$.
$\hspace{160pt}g(ag^{-1})a\ne ga(ag^{-1}) $
$\hspace{160pt}(ga)g^{-1}a\ne (ga)ag^{-1} $
$\hspace{160pt}(ag)g^{-1}a\ne (ag)ag^{-1} $
$\hspace{160pt}a(gg^{-1})a\ne a(ga)g^{-1} $
$\hspace{187pt}aa\ne a(ag)g^{-1} $
$\hspace{187pt}aa\ne aa(gg^{-1}) $
$\hspace{187pt}aa\ne aa $
Therefore, $ag^{-1}\in C(a)$. 
$C(a)$ is a subset of $G$ by the subgroup theorem. 

I just wanted to see if I was going about this the right way. Is there maybe a better way to prove that $C(a)$ is a subgroup of $G$?
 A: I had a hard time following the OP's extended calculation; I think he/she was trying to show that for $a, g \in C(a)$, $ag^{-1} \in C(a)$.  It is certainy true that for $S \subset G$, $S$ is a subgroup if and only if $s_1, s_2 \in S$ implies $s_1s_2^{-1} \in S$, but I think in the present case it is easier to proceed directly from first principles.  We verify the group axioms for $C(a)$:
1.)  for $g_1, g_2 \in C(a)$, we have
$(g_1g_2)a = g_1(g_2a) = g_1(ag_2) = (g_1a)g_2 = (ag_1)g_2 = a(g_1g_2), \tag{1}$
showing $C(a)$ is closed under the group operation;
2.)  since $ea = ae$ for $e \in G$ the identity element, $e \in C(a)$;
3.)  if $g \in C(a)$, then $ag = ga$, whence $g^{-1}a = ag^{-1}$, showing $g^{-1} \in C(a)$ as well.  
It is clear that $C(a)$ is nonempty, since evedently both $e, a \in C(a)$.  Having seen in items (1)-(3) above that $C(a)$ is closed under the group operation, contains the identity and inverses, we find that $C(a)$ is indeed a subgroup of $G$.  QED!!!
Remark:  It is also clear that $C(a)$ contains $\langle a \rangle$, the cyclic subgroup generated by $a$.
Hope this helps.  Cheerio,
and as always,
Fiat Lux!!!
A: Note that in your proof you have taken one of your elements to be $a$, the element we've taken the centralizer of. To show $C(a)$ is a subgroup, you would have to show that $gh^{-1}\in C(a)$ for any choice of $g$ and $h$ in $C(a)$, neither of which need be $a$ itself.
(Also you have not stated in your proof your assumption that $g$ is in $C(a)$. The $g$ in the statement of the question is a 'dummy' variable used to define $C(a)$, so you can't use it directly in your proof in the way you would use $a$.)
