What is the center of a semidirect product?

Let $G_1$ and $G_2$ be groups. Let $\varphi:G_2\rightarrow \operatorname{Aut}(G_1)$ be a group homomorphism defining the semidirect product $G_1 \rtimes G_2$. Determine the center $\operatorname{Z}(G_1 \rtimes G_2)$.

-

Denote by $\varphi_g$ the automorphism of $G_1$ associated with a $g\in G_2$. Take $z\in \operatorname{Z}(G_1\rtimes G_2)$ and write $z=xy$ for $x\in G_1$ and $y\in G_2$. Then, for every $g\in G_2$, we have $$gxy=\varphi_g(x)gy=xyg.$$ By equating the $G_1$ and $G_2$ parts in $gxy=\varphi_g(x)gy$, we see that $x=\varphi_g(x)$. Similarly, we equate the $G_1$ and $G_2$ parts in $gxy=xyg$ to obtain $gy=yg$. Since this is true for all $g\in G_2$, we may conclude that $x\in \operatorname{Fix}(\varphi)$ and $y\in \operatorname{Z}(G_2)$. With this in mind, we revisit our earlier computation: $$gxy=yxg=\varphi_y(x)yg=xyg$$ Thus we see that $x=\varphi_y(x)$, so $\varphi_y$ is the identity automorphism, and we have that $y\in \operatorname{Ker}(\varphi)$. Finally, taking $g\in G_1$, we have that $gxy=xyg$, from which we see that $x\in Z(G_1)$.

Putting it all together, we have $\operatorname{Z}(G_1\rtimes G_2) \subseteq \left(\operatorname{Z}(G_1)\cap\operatorname{Fix}(\varphi)\right)\rtimes \left(\operatorname{Ker}(\varphi)\cap \operatorname{Z}(G_2)\right),$ which is simply $\left(\operatorname{Z}(G_1)\cap\operatorname{Fix}(\varphi)\right)\times \left(\operatorname{Ker}(\varphi)\cap \operatorname{Z}(G_2)\right)$. The reverse inclusion is easy to see, so we conclude that $$\operatorname{Z}(G_1\rtimes G_2) = \left(\operatorname{Z}(G_1)\cap\operatorname{Fix}(\varphi)\right)\times \left(\operatorname{Ker}(\varphi)\cap \operatorname{Z}(G_2)\right).$$

EDIT As pointed out below, the reverse inclusion in the above answer is false in the general case. This is now under construction as I work to repair the description.

-
While thinking about this question math.stackexchange.com/q/569360/61691, I found your answer here. I can follow you to the point that $x\in\operatorname{Fix}(\varphi)$ (with a suitable definition of $\operatorname{Fix}$) and $y\in\operatorname{Z}(G_2)$. But the next point is not clear to me. How does $x = \varphi_y(x)$ imply $y\in\ker(\varphi)$? For this, wouldn't we need $\varphi_y(x') = x'$ for all $x'\in G_1$, and not only for the fixed $x$? –  azimut Nov 17 '13 at 17:10
@Alexander Gruber, Kindly tell me if I am wrong. Let $|G_2|=p$(a prime). If $\varphi$ is not trivial (that is the semidirect product is not a direct product), then $Ker(\varphi)$ is trivial. This implies that $Z(G) \subseteq G_1$. I am extremely sorry for asking this question again, I am asking this as I did not get any response to my previous post. I wish to know whether I am right or not. I have done some calculation assuming this fact. If it is wrong my whole calculation will be collapsed. –  Vipul Kakkar Dec 7 '13 at 8:08
@azimut Yes, that's a good point. I remember thinking when writing this post that I had accounted for this in some way. I will try to recall what I did, and update the answer with an explanation, or corrections if necessary. –  Alexander Gruber Dec 8 '13 at 9:16
@AlexanderGruber: Wow, I didn't expect a reaction any more! I'm looking forward to your update. –  azimut Dec 8 '13 at 12:46

I'm afraid the answer by Alexander is wrong. The given subgroup is indeed contained in the center of the semidirect product, but the reverse inclusion can fail.

Simple example: let $G_1$ be a center-free group, with an element $x$ of prime order $p$ (for instance, pick $G_1$ non-abelian of order 6 and $p=2$ or 3). Let the cyclic group $G_2$ of order $p$ act on $G_1$ so that the generator $c$ of order $p$ acts by conjugation by $x$: $\varphi(c^n)(g)=x^ngx^{-n}$. Then $\varphi:G_2\to\mathrm{Aut}(G_1)$ is injective, and hence the subgroup $(Z(G_1)\cap \mathrm{Fix}(\varphi))\times(Z(G_2)\cap\mathrm{Ker}(\varphi))$ is trivial. But the center of the semidirect product $G=G_2\rtimes G_1$ is not trivial: if the law of the latter is given by $(g_2,g_1)(h_2,h_1)=(g_2\varphi(g_1)(h_2),g_1h_1)$, then the element $(x,c^{-1})$ is central (thus the center $Z$ is cyclic of order $p$ and $G$ is direct product of $G_1$ and $Z$).

A correct description of the center of an arbitrary semidirect product should involve the kernel of the map $\varphi':G_2\to\mathrm{Out}(G_1)$, but it looks a bit complicated.

Edit: the center can be described as follows: let $f$ be the canonical map $G_2\to \mathrm{Inn}(G_2)=G_2/Z(G_2)$ and $s$ the canonical map $\mathrm{Ker}(\varphi')\to\mathrm{Inn}(G_2)$. Then the center of $G$ is the set of pairs $(g_2,g_1)\in G_2\rtimes G_1$ such that $g_1\in s^{-1}(f(\mathrm{Fix}(\varphi)))\cap Z(G_1)$, and $f(g_2)=s(g_1)^{-1}$.

-
Thank you @Yves! I suspected there was a counterexample. We should work together to provide the description of the general case. –  Alexander Gruber Dec 9 '13 at 22:38