Application of the decomposition of prime ideals as $Q_q^{e_1}Q_2^{e_2}\dots Q_R^{e_r}$ I'm reading Marcus number field book and at page 57 he asks the following

We give some applications of Theorem 27. Taking $\alpha=\sqrt{m}$, we can re-obtain the
  results of Theorem 25 except when p = 2 and m $\equiv $ 1 (mod 4); in this exceptional
  case the result can be obtained by taking $\alpha=\frac{1+\sqrt{m}}{2}$.

Where the theorems are the following

Theorem 25 With notation as above, we have:
If p | m, then
  $$ pR=(p,\sqrt
{m})^2.$$
If m is odd, then
  $$ 2R= \begin{cases} (2,1+\sqrt
{m})^2&\text{if $m\equiv 3\pmod4$}\\
\left(2,\frac{1+\sqrt{m}}{2}\right)\left(2,\frac{1-\sqrt{m}}{2}\right) & 
\text{if $m\equiv 1\pmod8$}\\
\text{prime if $m\equiv 5\pmod8$.}
\end{cases}$$
If p is odd, $p\not| m$ then
  $$ pR=\begin{cases} (p,n+\sqrt{m})(p,n-\sqrt{m})\; \text{if $m\equiv n^2 \pmod p$}\\
\text{prime if $m$ is not a square mod $p$}
\end{cases}$$
  where in all relevant cases the factors are distinct.

and

Theorem 27
  Now let g be the monic irreducible polynomial for $\alpha$ over K. The coefficients
  of g are algebraic integers (since they can be expressed in terms of the conjugates
  of the algebraic integer $\alpha$), hence they are in  $\mathbb{A}\cap K = R$. 
Thus g $\in$ R[x] and we
  can consider $\overline{g}\in$ (R/P)[x]. 
$\overline{g}$ factors uniquely into monic irreducible factors in
  (R/P)[x], and we can write this factorization in the form
  $$\overline{g} =\overline{g}_1^{e_1}\dots \overline{g}_n^{e_n}$$
  where the $\overline{g}_i$ are monic polynomials over R. It is assumed that the $\overline{g}_i$ are distinct.
Let everything be as above, and assume also that p does not divide
  |S/R[$\alpha$]|, where p is the prime of $\mathbb{Z}$ lying under P. Then the prime decomposition
  of PS is given by
  $$Q_1^{e^1}\dots Q_n^{e_n}$$
  where $Q_i$ is the ideal (P, $g_i(\alpha$)) in S generated by P and $g_i(\alpha)$; in other words,
  Qi = PS + ($g_i(\alpha$)).
  Also, f ($Q_i$ |P) is equal to the degree of $g_i$ .

I tried doing it but I think I'm doing something wrong. How do I use the relations between p and m? 
I always get that the minimal polynomial of $\sqrt{m}$ is $x^2-m=(x-m)(x+m)$ and so
$Q_1=(P,2\sqrt{m})\wedge Q_2=(P,0)$ whose product is not equal, for example,  to $(p,\sqrt{m})$.
Can you help me?
 A: First of all, the factorization of $x^2-m$ (when it exists) is $(x-\sqrt{m})(x+\sqrt{m})$ not $(x-m)(x+m)$ as you wrote. Thus the key question is whether $\sqrt{m}$ exists in $\frac{R}{P}$.
An example to illustrate this : take $m=7,p=29$. Then $m$ is a square modulo $p$ (since $6^2\equiv m\ \mod p$), so in $\frac{\mathbb Z}{p{\mathbb Z}}$, $x^2-m$ factorizes $x^2-m=x^2-7=(x-6)(x+6)$ ; you have $\bar{g_1}=x-6,\bar{g_2}=x+6$.
Accordingly, the ideal $(p)$ decomposes as $(p)=(p,\sqrt{m}-6)(p,\sqrt{m}+6)$.
If you want to "visualize" those ideals more, note that $(p)$ is the set of all $x+y\sqrt{m}$ such that $p$ divides both $x$ and $y$, $(p,\sqrt{m}-6)$ is the set of all $x+y\sqrt{m}$ such that $p$ divides $x-6y$, and   $(p,\sqrt{m}+6)$ is the set of all $x+y\sqrt{m}$ such that $p$ divides $x+6y$.
A: We start with the general case picking $g(x)=x^2-m,\; \alpha=\sqrt
{m},\; K=\mathbb{Q},\; L=\mathbb{Q}(\sqrt
{m})$ $p\not|\left|\frac
{S}{\mathbb{Z}[\sqrt{m}]}\right|$. 
A problem arises when $m\equiv1\; (mod\; 4)$ and p=2, in that special case we pick $\alpha=\frac{1+\sqrt{2}}{2}$ $g(x)=x^2-x+\frac{1-m}{4}$.  
In the general case,


*

*if $p|m|$,  $x^2-m\equiv x^2\; (mod\; p)\mathbb{Z}[x]$; so $g_1(x)=g_2(x)=x$ and $pS=Q^2$ where $Q=(p,\sqrt{m})$;

*if m is a non zero square (mod p), $m\equiv n^2\; (mod\; p)$ we get 
$$ x^2-m\equiv(x-n)(x+n)\; (mod\; p)\mathbb{Z}[x]$$ so $g_1(x)=x-n$, $g_2(x)=x+n$ and $pS=Q_1Q_2$ where $Q_1=(p,\sqrt{m}-n)$ and $Q_2=(p,\sqrt{m}+n);$

*if m is not a square (mod p) then g(x) is irreducible (mod p) and $Q=(p,g(\alpha)=0)=pS$ is a prime with residue degree 2.


In the special case, there are two possibilities:


*

*if  $m\equiv 1\; (mod\; 8)$ then g(x) has the zeroes $\alpha_1=0$ and $\alpha_2=1$ in $\mathbb{F}_2$ so $g_1(x)=x$ and $g_2(x)=x-1$ work; in this case $Q_1=(2,\alpha)=\left(2,\frac{1+\sqrt
{m}}{2}\right)$ and $Q_2=(2,\alpha-1)=\left(2,\frac{1-\sqrt{m}}{2}\right)$;

*if $m\equiv 5\; (mod\; 8)$ then g(x) is irreducible (mod 2) so $Q=(2,g(\alpha)=0)=2S$ is a prime of residue degree 2.

