Let $\mathcal M_m$ be the set of $2$-by-$2$ **primitive** (relatively prime entries) matrices with determinant $m$. Let $\alpha \in \mathcal M_m$ and let $\Gamma\subset \operatorname{SL}_2(\mathbb Z)$. Define
$$R_{\alpha,\Gamma}=\lbrace M\in \Gamma\backslash\mathcal M_m : M \equiv \alpha \text{ in } \Gamma\backslash\mathcal M_m/\Gamma\rbrace.$$ Thus $R_{\alpha,\Gamma}$ is a set of representatives $M$ for the left action of $\Gamma$ on $\mathcal M_m$ such that there exist matrices $A,B\in \Gamma$ with the property $M=A\alpha B$.

Let $F_{N,\mathbb C}$ be the field of modular functions of level $N.$ Suppose that $f\in F_{N,\mathbb C}$, $\mathbb C(j)\subset \mathbb C(f)$, and $\alpha \in \mathcal M_m$. The Galois group of $F_{N,\mathbb C}$ over $\mathbb C(j)$ is isomorphic to $\operatorname{SL}_2(\mathbb Z/N\mathbb Z)/\{\pm 1\}$. The subgroup corresponding to the subfield $\mathbb C(f)$ is $$\Gamma(f)=\lbrace A\in\operatorname{SL}_2(\mathbb Z/N\mathbb Z): f\circ A = f\rbrace.$$

It is easy to see that $f\circ \alpha \in F_{mN,\mathbb C}$, and that the minimal polynomial of the function $f\circ \alpha$ over $\mathbb C(f)$ is $$\prod_{M\in R_{\alpha, \Gamma(f)}}X-f\circ M.\label{m}\tag{1}$$

Suppose that in addition $f$ has **rational** Fourier coefficients. Is the polynomial above the also the minimal polynomial of $f\circ\alpha$ over the field $\mathbb Q(f)$?

**Update**

The result is true when $\alpha = \begin{pmatrix}m & 0 \\0& 1\end{pmatrix}$. In this case the function $f\circ \alpha$ has rational Fourier coefficients. It is therefore invariant under the action of $(\mathbb Z/mN\mathbb Z)^\times$ on $F_{N}$.

To show that the polynomial $\eqref{m}$ in question is also the minimal polynomial of $f\circ\alpha$ over $\mathbb Q(f)$, we must show that the set of roots of $\eqref{m}$ is stable under all automorphisms fixing $\mathbb Q(f)$. Each such automorphism can be represented as

$$\begin{pmatrix}d & 0 \\0& 1\end{pmatrix}\gamma,$$

where $\gamma \in \Gamma(f)$ and $d\in (\mathbb Z/mN\mathbb Z)^\times$. This is because $\operatorname{Gal}(F_{mN}/\mathbb Q(j)) \cong \operatorname{PGL}_2(\mathbb Z/ mN\mathbb Z)$. Since $f\circ\alpha(z)=f(mz)=\sum_ka_kq^{mk/N}$ has rational coefficients, the matrix $ \begin{pmatrix}d & 0 \\0& 1\end{pmatrix}$ acts trivially on $f\circ\alpha$. The set $R_{\alpha,\Gamma(f)}$ is stable under the action of $\gamma$ by definition.

**Update II**

We prove that the result is true when both $f$ and $f\circ\alpha$ have rational Fourier coefficients. Let $k=mN$. First note that if $d\in(\mathbb Z/k\mathbb Z)^\times$ and $\gamma \in \Gamma(f)$ then any lift to $\operatorname{SL}_2(\mathbb Z)$ of the matrix $$\begin{pmatrix}1 & 0\\0& d\end{pmatrix}\gamma\begin{pmatrix}1 & 0 \\0& d\end{pmatrix}^{-1}$$ also lies in $\Gamma(f)$ because it has determinant equal to $1$ and the automorphism induced by it fixes $f$ (here we use that $f$ has rational coefficients).

We know that $F_k=\mathbb Q(j,h^{(r,s)}:(r,s)\in \mathbb Z^2, \not \in k\mathbb Z^2)$, where $$h^{(r,s)}(\tau)=\frac{g_2(\tau)}{g_3(\tau)}\wp_\tau\left(\frac{r\tau+s}{k}\right)$$ are the Fricke functions. They satisfy $h^{(r,s)\gamma}=h^{(r,s)}\circ\gamma$ for $\gamma\in \operatorname{SL}_2(\mathbb Z)$, and $(h^{(r,s)})^{\sigma_d}=h^{(r,sd)}$ where $\sigma_d$ is the automorphism induced by $d\in(\mathbb Z/k\mathbb Z)^\times$.

Let $M\in R_{\alpha,\Gamma(f)}$. We must show that for each $d\in(\mathbb Z/k\mathbb Z)^\times$ we have $(f\circ M)^{\sigma_d}=f\circ M'$ for some $M'\in R_{\alpha,\Gamma(f)}$.

Write $f\circ \alpha = Q(h^{(r,s)})$ where $Q$ is a rational function with rational coefficients. Here $(r,s)$ ranges over some finite set of representatives.

We have $A\alpha B=M$ for some $A,B\in \Gamma(f)$; thus $$f\circ M=f\circ \alpha \circ B = Q(h^{(r,s)B}).$$

Let $D = \begin{pmatrix}1 & 0\\0& d\end{pmatrix}$. Then $$(f\circ M)^{\sigma_d}= Q(h^{(r,s)BD})=Q(h^{(r,s)DB'}),$$ where $B'=D^{-1}BD$ lies in $\Gamma(f)$ by above discussion. Therefore $$(f\circ M)^{\sigma_d}=Q(h^{(r,s)D}\circ B').$$ On the other hand, $(f\circ \alpha)^{\sigma_d}= Q(h^{(r,s)D})$, so $(f\circ M)^{\sigma_d}=(f\circ \alpha)^{\sigma_d}\circ B'$. Now we use the fact that $f\circ\alpha$ has rational Fourier coefficients to deduce that $(f\circ M)^{\sigma_d}=f\circ \alpha\circ B'$. Thus we can take $M' = \alpha B'$.

For the Fricke functions see Shimura: An introduction to the theory of automorphic functions, Section 6.2.

1more comment