Why does the class equation have rational coefficients?

Let $j$ be the Klein modular invariant and let $\Gamma=SL_2(\mathbb Z)$ be the modular group. Consider the set of primitive quadratic forms $ax^2+bxy+cy^2$ of discriminant $d<0$.

The root of a quadratic form $f(x,y)$ is the unique complex number $\omega$ from the upper half-plane such that $f(\omega, 1)=0$. It follows, that two quadratic forms are equivalent, if and only if their respective roots are in the same orbit of the action of $\Gamma$ on the upper half plane.

Therefore we may associate to each equivalence class of quadratic forms of the discriminant $d$ a unique value of the $j$-invariant. Now choose a root from every equivalence class, say $\omega_1,...,\omega_h$, where $h=h(d)$ is the class number and consider the class equation

$$H(x)=(x-j(\omega_1))\cdots(x-j(\omega_h)).$$

Why should this polynomial have integral coefficients?

I am seeking some simple reason why $j(\omega)$, where $\omega$ is a root of a quadratic form of discriminant $d$, should be an algebraic integer of degree at most $h(d)$. The modular equation shows, that $j(\omega)$ is an algebraic integer, see my question Singular values of the j-invariant.

I am aware that more advanced theory shows that the degree of $j(\omega)$ is actually $h(d)$. Also there is an elementary proof of the weaker statement in the Cox's book Primes of the form $x^2+ny^2$, but this requires a lot of work.

On the other hand Weber in his Lehrbuch der Algebra proves that $H(x)$ has rational coefficients by some sort of induction. However, this is scarcely readable.

My ultimate goal is to understand the proof of Heegner-Stark theorem as described in Stark's article. I asked a question about it before: Modular functions of the type $\mathfrak f(\cdot)^{k}\mathfrak f(\cdot)^{23nk}$, but got no response. Fortunately I had resolved that problem and now this is the next question to be answered.

At any rate, Shimura in his book "Introduction to the arithmetic theory of automorphic functions" answers your questions nicely. Theorem 4.14 states that $j(\omega)$ is always an algebraic integer, and the proof is rather short and elementary. Then, Theorem 5.7 shows that $H(x)$ has rational coefficients (and it is irreducible over $\mathbb{Q}$), whence the coefficients are in fact integers (because they are algebraic integers).
• Stark in his paper claims that it is easy to show that the degree of $j(\omega)$ is at most $h(d)$. Moreover, he asserts that if $d\equiv-3 (\text{mod } 8)$ and $h(d)=1$, then it is trivial that the number $j(\frac{-1+\sqrt d}{2})$ is of degree $1$. – Shimrod Apr 25 '18 at 13:10