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

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.
