As a part of the research with which I am involved, I would like to understand how to compute the effect of the Atkin-Lehner operator/Fricke involution $W_2 = \begin{pmatrix} 0 & 1 \\ -2 & 0 \end{pmatrix}$ on the $q$-expansion modular forms with $\Gamma_0(2)$ level structure. I know of the Magma function $\operatorname{AtkinLehnerOperator}(f,q)$, but I would like to understand how this works at a theoretical level, both to get at theoretical results and to extend this function to work on modular forms over rings that are not the rationals, (specifically the integers and the 3-adic integers). If anyone has any sources on or explanations as to how to compute how q-expansions are transformed under the Atkin-Lehner/Fricke involution, it would be greatly appreciated!