Modified weight 2 Eisenstein series is a modular form for $\Gamma_0(N)$ I'm doing exercise 1.2.8(e) in Diamond & Shurman's A First Course in Modular Forms. The problem is to show that $G_{2,N}(\tau) := G_2(\tau)-NG_2(N\tau)$ is in $M_2(\Gamma_0(N))$. To show this, I need to argue that $G_{2,N}$ satisfies $G_{2,N}[\gamma]_2=G_{2,N}$ where $f[\gamma]_2(\tau):=j(\gamma,\tau)^{-2}f(\gamma(\tau))$ is the weight-2 operator for every $\gamma\in\Gamma_0(N)$, and that $G_{2,N}$ is holomorphic on $\mathcal{H}$ and holomorphic at the cusps.
So far, I proven that $G_2(\tau)$ satisfies the transformation formula $$G_2[\gamma]_2(\tau) = G_2(\tau)-\frac{2\pi ic}{c\tau+d},\;\;\;\;\gamma = \begin{bmatrix}a&b\\c&d\end{bmatrix}$$
and that
$$\frac{\pi}{j(\gamma,\tau)^2\Im(\gamma(\tau))}=\frac{\pi}{\Im(\tau)}-\frac{2\pi ic}{c\tau+d},$$
and I've concluded that $G_2(\tau) - \frac{\pi}{\Im(\tau)}$ is weight-2 invariant under $SL_2(\mathbb Z)$.
I have no idea how to conclude that $G_{2,N}(\tau)$ is a modular form for $\Gamma_0(N)$. Specifically, how does the weight-2 operator act on $G_{2,N}$? Is it
$$G_{2,N}[\gamma]_2(\tau) = (c\tau+d)^{-2}(G_2(\gamma(\tau))-NG_2(\gamma(N\tau)))$$
or
$$G_{2,N}[\gamma]_2(\tau) = (c\tau+d)^{-2}(G_2(\gamma(\tau)) - NG_2(N\gamma(\tau))?$$
In either case, $N\gamma(\tau)$ and $\gamma(N\tau)$ are not of the form $\alpha(\tau)$ for some $\alpha\in SL_2(\mathbb Z)$, so how should $G_2(\tau)$ transform?
Moreover, I don't know how to verify that $G_{2,N}$ is holomorphic on $\mathcal{H}$ or at the cusps. I would greatly appreciate detailed answers to both of these.
P.S. This is not homework, I'm simply trying to better understand computational aspects of modular forms.
 A: Note that $\tau \longmapsto NG_2(N\tau)$ is the function $G_2[\gamma]_2$ with $\gamma=\begin{bmatrix}N & 0\\0&1 \end{bmatrix}$. Moreover, if $\gamma’=\begin{bmatrix}a &b\\c&d\end{bmatrix} \in \Gamma_0(N)$, then $$\gamma\gamma’=\begin{bmatrix} Na & Nb \\ c & d\end{bmatrix}=\begin{bmatrix} a & Nb \\ c/N & d\end{bmatrix}\gamma:=\gamma’’\gamma,$$ and $\gamma’’ \in SL_2(\mathbb{Z})$, so that $G_{2,N}[\gamma’]_2(\tau)=G_2(\tau)-\frac{2i\pi c}{c\tau+d}-(G_2[\gamma’’]_2)[\gamma]_2(\tau)=G_2(\tau)-\frac{2i\pi c}{c\tau+d}-NG_2[\gamma’’]_2(N\tau)=G_2(\tau)-\frac{2i\pi c}{c\tau+d}-NG_2(N\tau)+N\frac{2i\pi (c/N)}{(c/N)(N\tau)+d}=G_{2,N}(\tau)$.
Edit: Now let’s address the holomorphicity issues. First, we show that $G_2[\gamma]_2$ is holomorphic everywhere (including at infinity) for any $\gamma \in SL_2(\mathbb{Z})$. Given the transformation formula, it’s enough to show that $G_2$ is holomorphic everywhere and at infinity.
It’s enough to show that $G_2(\tau)$ is holomorphic  on the half plane and bounded at infinity. But $G_2(\tau)=2\zeta(2)+2\sum_{c \geq 1}{f(c\tau)}$ where $f(z)=\sum_{d \in \mathbb{Z}}{\frac{1}{(z+d)^2}}$. As $f$ is the sum of a (locally) normally convergent series of holomorphic functions, $f$ is holomorphic.
Now, if $z$ has imaginary part at least $A > 0$ and real part between $-1$ and $1$, then $$f(z)=\sum_{d \in \mathbb{Z}}{\int_{-1/2}^{1/2}{\int_0^t{\frac{-2du}{(z+d+u)^3}}\,dt}},$$ which shows that $|f(z)| \leq 2\sum_{d \in \mathbb{Z}}{\sup_{t \in (d-1/2,d+1/2)}\, |\frac{1}{(z+t)^3}|}$.
The term for $d=0$ is at most $\frac{1}{A^3}$, and the term for $d \geq 1$ is at most $\frac{1}{(A^2+(|d|-1/2)^2)^{3/2} } \leq \frac{8}{(A^2+d^2)^{3/2}} \leq \frac{16}{A^3+|d|^3}$ by convexity.
It follows that $|f(z)| \leq 2A^{-3}+32\sum_{d \geq 1}{(A^3+d^3)^{-1}}$. By separating the cases $d \geq A$ and $d \leq A$, we get finally that $|f(z)| \leq C(A^{-3}+A^{-2})$ where $C$ is a numerical constant.
Since $f$ is $1$-periodic, it follows that $|f(z)| \leq \frac{C}{|Im(z)|^3}+\frac{C}{|Im(z)|^2}$ and therefore the series $\sum_{c \geq 1}{f(cz)}$ converges normally on all $\{Im z > A\}$, $A>0$.
It follows from this and the bound on $f$ that that series is a holomorphic function of $z$ and goes to zero as $Im(z)$ goes to infinity, so that $G_2(z)$ is holomorphic on the half-plane and at the cusps.
Thus, $G_{2,N}$ is also holomorphic on the half-plane, $\Gamma_0(N)$-invariant and bounded (hence holomorphic) at infinity. Moreover, it has a well know Fourier expansion with coefficients in $O(n^2)$, so by Proposition 1.2.4 it is modular.
A: This is more of an expansion of my comment to the question.
Let $q\in(0,1)$ be the nome corresponding to elliptic modulus $k\in(0,1)$ (in the symbolism of modular forms $q$ takes backstage and is replaced by $\tau$ where $q=\exp(2\pi i\tau)$ and $\tau$ has positive imaginary part).
Let us define elliptic integrals $K, E$ as $$K=K(k) =\int_0^{\pi/2}\frac{dx}{\sqrt{1-k^2\sin^2x}}\tag{1}$$ and $$E=E(k) =\int_0^{\pi /2}\sqrt{1-k^2\sin^2x}\,dx\tag{2}$$ The nome $q$ is related to $k$ via  $$q=\exp\left(-\pi\frac{K(k')} {K(k)} \right), k'=\sqrt{1-k^2}\tag{3}$$ Ramanujan used the function $P(q) $ instead of your $G_2$ defined by $$P(q) =1-24\sum_{n=1}^{\infty}\frac{nq^n}{1-q^n}\tag{4}$$ The following link of $P(q) $ and elliptic integrals defined above was well known before Ramanujan: $$P(q^2)=\left(\frac{2K}{\pi}\right)^2\left(\frac {3E}{K}+k^2-2\right) \tag{5}$$ For Ramanujan modular forms were roughly those functions $f(q) $ which could be expressed like $(2K/\pi)^w A(k) $ where $w$ is some positive integer or half of a positive integer and $A(k) $ is an algebraic function of $k$ ($w$ being weight of $f(q) $). The exact definition of modular forms which Ramanujan provided could not however be decoded by Berndt and his collaborators.
The term $3E/K$ on right of $(5)$ is what prevents $P(q^2)$ from being a modular form. Fortunately for us Ramanujan found out a way to fix this. He instead considered the function $NP(q^{2N})-P(q^2)$ ($N$ being a positive integer) and proved that it can be expressed in the form desired.
Let us start with another well known function called Dedekind eta function defined by $$\eta(q) =q^{1/24}\prod_{n=1}^{\infty} (1-q^n)\tag{6}$$ Eta function is related to $P(q) $ via $$P(q) =24q\frac{d}{dq}{\log \eta(q)} \tag{7}$$ The following identity $$ \eta(q^2)=2^{-1/3}\sqrt {\frac{2K}{\pi}}(kk')^{1/6}\tag{8}$$ is well known and shows that $\eta(q^2)$ is a modular form of weight $1/2$.
Using $(1),(2),(3)$ it can be proved that $$\frac{dq} {dk} =\frac{\pi^2q}{2kk'^2K^2}\tag{9}$$ and then $(5)$ can be established using $(7),(8),(9)$.
Let $l$ be the elliptic modulus corresponding to nome $q^N$ (which corresponds to $N\tau$). The elliptic integrals $K(l), K(l') =K(\sqrt {1-l^2})$  are usually denoted by $L, L'$ so that $q^N=\exp(-\pi L'/L) $. From $(8)$ we get $$\eta(q^{2N})=2^{-1/3}\sqrt{\frac{2L}{\pi}}(ll')^{1/6}\tag{10}$$ From $(7)$ we get $$P(q^2)=12q\frac{d}{dq}\{\log\eta(q^2)\},NP(q^{2N})=12q\frac{d}{dq}\{\log\eta(q^{2N})\}$$ and thus $$F(q) =NP(q^{2N})-P(q^2)=12q\frac{d}{dq}\left(\log\frac{\eta(q^{2N})}{\eta(q^2)}\right)$$ Using $(8),(9),(10)$ we thus get $$F(q) = \left(\frac{2K}{\pi}\right)^2kk'^2\frac{d}{dk}\left(3\log\frac{L}{K}+\log\frac{ll'}{kk'}\right)\tag{11}$$ From the standard theory of modular equations it is known that $l,l'$ as well as $K/L$ are algebraic functions of $k$ and hence from the equation $(11)$ it follows that $F(q) $ is of the form $(2K/\pi)^2A(k)$ where $A(k) $ is an algebraic function of $k$. Thus $F(q)$ is a modular form of weight $2$.
Ramanujan calculated the function $A(k) $ in explicit form for many values of $N$. For small values of $N$ the values given by Ramanujan can be verified with some effort. But no one knows how Ramanujan evaluated them for large $N$.
