How to make a perfect square from a number given in a surd form $a+b\sqrt{c}$? Is there a way of checking that a number can be written as a perfect square and hence finding it if the number is given in the surd form?
For example, if I expand and simplify $$(1+\sqrt{2})^{2}=3+2\sqrt{2}$$.
Is there a way of finding that perfect square (assuming it has one or after checking it has one) from $3+2\sqrt{2}$?
 A: $$(a + b \sqrt{c})^2 = a^2 + b^2 c + 2 a b \sqrt{c}$$
So if you are given $s + t \sqrt{c}$ (with $s, t, c$ rational, $t \ne 0$ and $c$ not a square)
and want to write it in this form, you want to find rationals $a$ and $b$ to solve the equations
$$ \eqalign{a^2 + b^2 c &= s\cr
             2 a b &= t\cr}$$
Since $a=0$ won't work, we can write $b = t/(2a)$ and the equation becomes
$$ a^2 + \frac{c t^2}{4a^2} = s $$
which we can solve for $a^2$ and then for $a$:
$$ a = \pm \frac{\sqrt{ 2\,s+2\,\sqrt {s^2-c{t}^{2}}}}{2} $$
That is, $s^2 - c t^2$ must be the square of a rational, and then $2s + 2 \sqrt{s^2 - ct^2}$ must be the square of a rational, and if so we get a solution with this $a$ and $b = t/(2a)$.
A: Correction: $$(1+\sqrt 2)^2=3+\color{red}2\sqrt2$$
Generally:
$$(\alpha+\beta\sqrt x)^2=(\alpha^2+x\beta^2)+2\alpha\beta\sqrt x$$
Hence we can recursively solve using simultaneous equations:
$$\begin{cases}\alpha^2+2\beta^2=3 & \\  2\alpha\beta=2  \end{cases} $$
Using the second to get $\alpha=\frac 1\beta$, we implant this into the first so:$$\frac{1}{\beta^2}+2\beta^2=3\implies2\beta^4-3\beta^2+1=0\implies(2\beta^2-1)(\beta^2-1)=0$$
This yields $$\beta=\pm1, \pm\frac{1}{\sqrt 2}$$
and thusly $$\alpha=\frac1\beta=\pm1,\pm\sqrt 2$$
The first pair gives us $\pm(1+\sqrt 2)$, and the seconnd pair gives $\pm(\sqrt 2+\frac{1}{\sqrt2}\sqrt2)=\pm(1+\sqrt2)$ which is the same result, achieved a different way.
