If we have two finitely generated residually finite groups $G$ and $H$, is there are relation between


the profinite completions $\hat{G},\hat{H}$ and the profinite completion of a semidirect 
product $\hat{G \rtimes H}$


(and analogous question for pro-p completions)



Profinite completion of a semidirect product
Take a finite non-abelian simple group $A$ and consider the wreath product $G=A\wr \mathbb Z$. Let $N$ be any subgroup of finite index of $G$. Then $N\cap A^{\mathbb Z}\ne 1$. Let $g$ be a non-trivial element in the intersection. Suppose that the $i$-th coordinate $g\_i$ of $g$ is not $1$. Since $A$ has trivial center, there exists $h\in A$ such that $[g\_i,h]\ne 1$. Let $h'$ be the element of $A^{\mathbb Z}$ with $h$ on the $i$-th coordinate and trivial other coordinates. Then $[g,h']$ is in $N$ and has exactly one non-trivial coordinate (number $i$). Using the fact that $A$ is simple and the action of ${\mathbb Z}$ on $A^{\mathbb Z}$, we get that $N$ contains $A^{\mathbb Z}$. Hence the profinite (pro-p) completion of $G$ is the same as the profinite completion of $\mathbb Z$. Of course $G$ is a semidirect product of $A^{\mathbb Z}$ and $\mathbb Z$, both residually finite. 


If $G, H$ are finitely generated, then $P=\hat G\rtimes \hat H=\hat{G\rtimes H}$. Indeed it is easy to see that the profinite completion of $G$ in $P$ is $\hat G$. That is because for every finite index subgroup $N$ of $G$ there exists a finite index subgroup $K$ in $G\rtimes H$ such that $K\cap G < N$. 


