I'm doing a master's thesis about quadratic fields and I know that for squarefree m, the ring of integers for the quadratic field $\mathbb{Q}(\sqrt{m})$ is $\mathbb{Z}[\sqrt{m}]$ if $m \equiv 2,3 \pmod{4}$ and $\mathbb{Z}[\frac{1 + \sqrt{m}}{2}]$ if $m \equiv 1 \pmod{4}$. My question is this: Why is the ring of integers in $\mathbb{Q}(\sqrt{m}) = \mathbb{Z}[\frac{1+\sqrt{m}}{2}]$ when $m \equiv 1 \pmod{4}$ instead of just $\mathbb{Z}[\sqrt{m}]$?
EDIT: I have seen some of your posts and I know that it has to do with integral closure. My confusion comes when I see that the minimal polynomial of $3 + 6\sqrt{5}$ is $x^2 -6x -171$ even though $3 + 6\sqrt{5}$ does not seem to be an element of $\mathbb{Z}[\frac{1+\sqrt{5}}{2}]$. What I'm looking for is an element of $\mathbb{Z}[\sqrt{m}]$ which is not a quadratic integer. i.e. one whose minimal polynomial has a non-integer coefficient.