How to find integers $p$ and $q$ such that $(p\sqrt{2}+q)^2=34-24\sqrt{2}$ Find integers $p$ and $q$ such that $(p\sqrt{2}+q)^2=34-24\sqrt{2}$.
I approached this question first by expanding the the left-hand side to get:
$$2p^2 +2\sqrt{2}pq+q^2 = 34-24\sqrt{2}$$
The problem becomes intractable for me at this point
 A: We want to find integers $p$ and $q$ such that 
$$(p\sqrt{2} + q)^2 = 34 - 24\sqrt{2}$$
Expanding the expression on the left-hand side yields
$$2p^2 + 2pq\sqrt{2} + q^2 = 34 - 24\sqrt{2}$$
Matching rational and irrational parts yields
\begin{align*}
2p^2 + q^2 & = 34 \tag{1}\\
2pq\sqrt{2} & = -24\sqrt{2} \tag{2}
\end{align*}
Solving equation 2 for $q$ yields 
$$q =  -\frac{12}{p} \tag{3}$$
Substituting $-12/p$ for $q$ in equation 1 yields
\begin{align*}
2p^2 + \left(-\frac{12}{p}\right)^2 & = 34\\
2p^2 + \frac{144}{p^2} & = 34\\
2p^4 + 144 & = 34p^2\\
2p^4 - 34p^2 + 144 & = 0\\
p^4 - 17p^2 + 72 & = 0\\
(p^2 - 9)(p^2 - 8) & = 0\\
(p + 3)(p - 3)(p + 2\sqrt{2})(p - 2\sqrt{2}) & = 0
\end{align*}
which yields the solutions $p = -3, 3, -2\sqrt{2}, 2\sqrt{2}$.  The corresponding values for $q$ can be obtained by substituting these values for $p$ into equation 3.  Check that the results meet the stated requirements.
A: This doesn't necessarily answer the question, but I think that it well help as the OP is basically asking for a simplification for the nested radical$$Z=\sqrt{34-24\sqrt2}$$If $X,Y\in\mathbb{R}$, then a simplification exists if and only if $X^2-Y^2$ is a perfect square. In fact, a simplification is$$\sqrt{X\pm Y}=\sqrt{\frac {X+\sqrt{X^2-Y^2}}2}\pm\sqrt{\frac {X-\sqrt{X^2-Y^2}}2}$$This can be easily proven if we assume a denesting is possible and let$$\sqrt{X\pm Y}=\sqrt A\pm\sqrt B$$Now square both sides and you should get a quadratic where its solutions are simply $A$ and $B$. Now set $X=34$ and $Y=24\sqrt2$.
A: Note
$$\sqrt{34-24\sqrt2}
=\sqrt{2(17-2\sqrt{72})}
= \sqrt{2(\sqrt9-\sqrt{8})^2}= 3\sqrt2-4
$$
Thus, $(p,q)=(3,-4),(-3,4)$.
