here it's a question that I've posted [in MSE](https://math.stackexchange.com/questions/3501788/) but unfortunately got no answers:


Let $A$ and $B$ be matrices of finite order with integer coefficients.


Let $n\in\mathbb{N}$ and let $G\_A=\mathbb{Z}\ltimes\_A \mathbb{Z}^n$ be the semidirect product, where the action is $\varphi(n)\cdot (m\_1,\ldots,m\_n)=A^n (m\_1,\ldots,m\_n)$, and similarly with $B$.


It is easy to construct an isomorphism between $G\_A$ and $G\_B$ if $A$ is conjugate in $\mathrm{GL}(n,\mathbb{Z})$ to $B$ or $B^{-1}$. 


But, this is also a necessary condition? I mean, does $G\_A\cong G\_B$ implies $A\cong B$ or $A\cong B^{-1}$ in $\mathrm{GL}(n,\mathbb{Z})$ or is there a counterexample?


I've seen [at this MSE question](https://math.stackexchange.com/questions/2376842/a-necessary-condition-for-two-semi-direct-products-to-be-isomorphic?rq=1) that it is true if $A$ and $B$ are hyperbolic, i.e none of their eigenvalues have module 1, but it isn't the case.


Thank you very much!



Isomorphism of $\mathbb{Z}\ltimes_A \mathbb{Z}^m$ and $\mathbb{Z}\ltimes_B \mathbb{Z}^m$
I believe now that David Speyer's example can be adapted to provide a counterexample to the original question. (So I retract my earlier comment on the question and will delete it soon.)


In David's example, $A$ is a degree $\phi(m)$ matrix of order $m$ defining the action by multiplication of $\zeta\_m$ on the ideal $I$ of the number field ${\mathbb Q}[\zeta\_m]$, and $B$ is the action on the ideal $\sigma(I)$, and $A$ and $B$ are not conjugate to each other or to their inverses in ${\rm GL}\_{\phi(m)}({\mathbb Z})$. A specific example is $m=37$, $\phi(m)=36$.


We define degree $n:=\phi(m)+1$ matrices $A'$ and $B'$
as the diagonal joins of $A$ and $B$ with the identity matrix $I\_1$. So the corresponding ${\mathbb Z}$-modules can be thought of as $I \oplus \langle y \rangle$ and $\sigma(I) \oplus \langle z \rangle$, with trivial action on the second factors. These modules cannot be isomorphic, because an isomorphism would have to map the fixed points submodule $\langle y \rangle$ onto $\langle z \rangle$ and then their quotients $I$ and $\sigma(I)$ would be isomorphic, which they are not. So $A'$ and $B'$ are not conjugate in ${\rm GL}\_{n}({\mathbb Z})$.


I claim (at least in some cases) that we can choose $A$ and $B$ such that the corresponding semidirect products $\langle \alpha \rangle \ltimes\_{A'} {\mathbb Z}^n$ and $\langle \beta \rangle \ltimes\_{B'} {\mathbb Z}^n$ are isomorphic, where $\alpha$ and $\beta$ generate infinite cyclic groups. We can (in some cases?) choose $A = B^a$ with $a$ coprime to $m$ and $2 \le a < \phi(m)-1$ such that $B$ is not conjugate in ${\rm GL}\_{\phi(m)}({\mathbb Z})$ to $A$ or to $A^{-1}$, and choose integers $r,s$ with $ra-sm=1$.


Then we can define a isomorphism from $\langle \alpha \rangle \ltimes\_{A'} {\mathbb Z}^n$ to $\langle \beta \rangle \ltimes\_{B'} {\mathbb Z}^n$ by mapping $I$ to $\sigma(I)$ as in David's example, $y$ to $\beta^m z^r$ and $\alpha$ to $\beta^a z^s$. Note that this induces an isomorphism from the free abelian group $\langle \alpha, y \rangle$ to $\langle \beta, z \rangle$, such that the image of $y$ centralizes $\sigma(I)$.


I did some calculations in Magma in the case $m=37$, and found a degree 36 integer matrix $A$ that is not conjugate to $A^a$ for any $a$ with $2 \le a \le 36$.


For completeness, here is the matrix $A$ in machine readable format. I used the Magma function $\mathsf{AreGLConjugate}$ to test $A$ for conjugacy with $A^i$. This uses a fairly new algorithm published in Bettina Eick, Tommy Hofmann, and E.A. O'Brien.
The conjugacy problem in ${\rm GL}(n,{\mathbb Z})$.
J. London Math. Soc., 2019.



```
[
 [-4,149,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [-1,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [-4,133,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [-2,64,0,0,1,0,0,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