quadratic extension of $\mathbb{Q}(X)$ generated by the square root of a square-free polynomial

Let $f(X)\in\mathbb{Q}[X]$ be a square-free polynomial, that is, not divisible by any prime of $\mathbb{Q}[X]$. Let $K:=\mathbb{Q}(X)[Y]$, where $Y$ is a square root of $f(X)$, or equivalently $Y$ solves the monic polynomial equation given by $T^2-f(X)=0$. I want to compute $O_{K}$, the integral closure of $\mathbb{Q}[X]$ in $K$.

There is a trivial case: $Y\in\mathbb{Q}(X)$. In this case, $K=\mathbb{Q}(X)$ hence the integral closure of $\mathbb{Q}[X]$ in $K$ coincides with the integral closure of $\mathbb{Q}[X]$ in its field of fractions, which is $\mathbb{Q}[X]$ itself, since $\mathbb{Q}[X]$ is a UFD and UFD'S are integrally closed domains.

So we assume $Y\notin\mathbb{Q}(X)$. In this case, the set $\{1,Y\}$ provides a basis for $K$ (as a $\mathbb{Q}(X)$-vector space): every element $\xi\in K$ can be written in a unique way as

$$\xi=x+yY, \ \textrm{with} \ \ x,y\in\mathbb{Q}(X)$$

An easy computation provides the minimal polynomial of $\xi$ over $\mathbb{Q}(X)$, which is

$$m_{\xi}(X)=X^2-2xX+(x^2-y^2f)$$

If we assume $\xi$ integral over $\mathbb{Q}[X]$, then it is well known that $m_{\xi}$ has coefficients in $\mathbb{Q}[X]$

$$2x\in\mathbb{Q}[X], x^2-y^2f\in\mathbb{Q}[X]$$

Now, $2x\in\mathbb{Q}[X]$ clearly implies $x\in\mathbb{Q}[X]$ and $x\in\mathbb{Q}[X]$ implies $y^2f\in\mathbb{Q}[X]$.

Now suppose that some prime $p(X)$ of $\mathbb{Q}[X]$ divides the denominator of $y$. We get $p^2|f$, which contradicts the square-free hypothesis. Thus $y\in\mathbb{Q}[X]$ and $\xi\in\mathbb{Q}[X]+\mathbb{Q}[X]Y$, so that $O_k=\mathbb{Q}[X][Y]$ in this particular quadratic extension of $\mathbb{Q}(X)$.

My question is: can be stated something more than this? I mean, this setting reminds me a similar situation, where we have $\mathbb{Z}$ in place of $\mathbb{Q}[X]$, $\mathbb{Q}$ in place of $\mathbb{Q}(X)$ and $\mathbb{Q}[\sqrt{d}]$ in place if $K$, with $d$ an integer, $d\neq 0,1$, $d$ squarefree. In this case we have $O_K=\mathbb{Z}[\sqrt{d}]$ if $d\equiv 2,3 (mod \ 4)$, $O_K=\mathbb{Z}[\frac{1+\sqrt{d}}{2}]$ if $d\equiv 1 (mod \ 4)$.

So i'm asking if there is an analogy among the present case and the other one, or not.

-

The situations are fully analogous, except for the special role of the prime $2$ of $\mathbb Z$. If we kill that prime by instead taking the ground ring to be the localization $\mathbb Z[1/2]=R$, whose maximals are all the primes but $2$, then the integral closure of $R$ in $\mathbb Q(\sqrt d)$ is $R[\sqrt d]$, no matter what the congruence of $d$ is. The “special role” of $2$ arises precisely from the coefficient $2$ in the trace of $\xi$, namely $2x$ in your notation.