Abelian-by-abelian group Given a group $G$ such that $G/Z(G)\cong C_{2} \times C_{2}$. Prove that for $g,h \notin Z(G)$: $gh=hg$ iff $gh \in Z(G)$. One direction is obvious, since $gh \in Z(G)$ implies sthat $ghg^{-1}h^{-1}=g^{-1}ghh^{-1}=1$, so $gh=hg$. Can anyone help with the other direction? 
 A: Suppose $gh = hg$.  As $h$ and $g$ are not in $Z(G)$, the cosets $hZ(G)$ and $gZ(G)$ are not equal to $Z(G)$.  We want to show that $ghZ(G) = Z(G)$ (why?).  It will suffice to show that $gZ(G) = hZ(G)$ (why??).  Can you show that $h^{-1}g \in Z(G)$?
A: Assume $gh = hg$, and $g,h \notin Z(G)$; we want to show that $gh \in Z(G)$, or equivalently, that $g,h$ lie in the same class in $G/Z(G)$.
First note: as you showed, if $g,g'$ lie in the same class in $G/Z(G)$, then $g, g'$ commute.
Secondly, note that since $g$ commutes with $h$, it also commutes with any $h'$ in the same class as $h$: $gh' = g(h'h^{-1})h = (h'h^{-1})gh = (h'h^{-1})hg = h'g$.
Thirdly, since $g$ commutes with both $g$ and $h$, it commutes with $gh$, and hence with anything else in the same class.
But now if $g$ and $h$ were in distinct classes, then $gh$ would by in the third non-identity class; so by the above observations, $g$ would commute with elements of all three classes, so $g$ would be in the centre, contradicting the assumption.
A: Suppose $G / Z(G) = \langle a Z(G) \rangle \times \langle b Z(G) \rangle$. If $G$ is abelian, this is obvious. So assume $[a, b] = a^{-1} b^{-1} a b = (b a)^{-1} a b \ne 1$.
Then $[a, b]$ is an element of order $2$, as $1 = [a^2, b] = [a, b]^{2}$, since $[a,b] \in Z(G)$.
Write
$$
g = a^i b^j z, \qquad h = a^k b^l w,
$$
for $z, w \in Z(G)$. Note that you may take $i, j, k, l \in \Bbb{Z}_{2}$, and that the vectors $[i, j]$ and $[l, k]$ in $\Bbb{Z}_{2}^{2}$ are nonzero, as $g, h \notin Z(G)$.
Then
$$
1 = [g, h] = (hg)^{-1} gh = [a, b]^{i l - j k}.
$$
It follows that $i l - j k = 0$ in $\Bbb{Z}_{2}$. Since the vectors $[i, j]$ and $[l, k]$ are nonzero, they must be equal, so modulo $Z(G)$
$$
g h \equiv a^{i + j} b^{k + l} \equiv a^{2i} b^{2j} \equiv 1.
$$
PS I believe that basically the same argument shows that when $G/Z(G)\cong C_{p} \times C_{p}$, where $p$ is a prime, and $g, h \in G \setminus Z(G)$, then $g h = h g$ if and only if $\langle g Z(G) \rangle = \langle h Z(G) \rangle$.
