Solving Pell's equation $x^2-5y^2=\pm4$ using elementary methods. 
Solve Pell's equation $x^2-5y^2=\pm4$.

This equation arises when I tried to prove that the units of $\mathbb{Z}[\varphi]$, where $\varphi=\frac{1+\sqrt{5}}{2}$ is the golden ratio, are of the form $\pm\varphi^n$. I found that $x+\varphi y$ is a unit iff $x^2+xy-y^2=\pm1$, i.e. $(2x+y)^2-5y^2=\pm4$. Yet I am unable to solve this equation. I saw here a solution using algebraic number theory, but I am interested in how to solve this equation using elementary methods, without using results from algebraic number theory. Thanks in advance!
 A: Let's take a solution $(x,y)$ of $x^2-5y^2=\pm4$. Assume $x>0$ and $y>0$.
Clearly also $x$ and $y$ have the same parity.
Define
$$x'=\frac{5y-x}2,\qquad y'=\frac{x-y}2.$$
Then $x'$ and $y'$ are integers, and
$$x'^2-5y'^2=\frac{(5y-x)^2-5(x-y)^2}4=\frac{20y^2-4x^2}4=\pm4.$$
Therefore $(x',y')$ is also a solution. I claim that $y'\ge0$ and $x'>0$.
If $y'<0$ then $x<y$ and $x^2-5y^2<-4x^2<-4$, which is false. So $y'\ge0$.
If $x'\le0$ then $x\ge5y$ and $x^2-5y^2\ge20y^2>4$ which is false. So
$y'\ge0$.
I claim that as long as $y\ge2$, then $y'<y$. Otherwise, $x\ge3y$
and $\pm 4=x^2-5y^2\ge4y^2$. This is only possible if $y=1$.
So, iterating the operation $(x,y)\mapsto(x',y')$ eventually reduces
$(x,y)$ to a solution $(X,Y)$ with $X>0$ and $Y\in\{0,1\}$. Therefore
to $(X,Y)=(2,0)$, $(1,1)$ or $(3,1)$. All of these reduce down to
$(2,0)$.
Therefore we can start with $(x_0,y_0)=(2,0)$ and reversing the operation
generate all positive solutions. The iterative process is
$$(x_{n+1},y_{n+1})=\left(\frac{x+5y}2,\frac{x+y}2\right).$$
A: There is a good story of solutions in Wikipedia. For the solution of Pell's 
like equation x^2−Dy^2=±C^2. You can always use following simple algorithm:
A:
x^2−5y^2 = 4
suppose x = y + a then we have:
y^2+2ay+a^2 -5y^2= 4  or 4y^2-2ay-a^2+4=0
y= [a±(5a^2-16)^0.5]/4
with a= 10 we get y = 8 and x = 10 + 8 = 18
I guess there is more  solutions in N for this equation.
with a=0 we get complex solutions x = y = ±i and with any a other than these 
two we may get real solutions but it must be checked in the equation.
B:
For equation  x^2−5y^2 = -4 assuming again x = y+a we get:
4y^2 - 2ay -a^2-4=0
y = [a±(5a^2+16)^0.5]/4
with a=2 we get y =2 and y=-1 ; if y=-1 then x=±1 these are solutions in R.
There may be infinitely many solutions in R .
With a=6 we get y=5 and x = 6+5=11. More solutions in N is probable.
with a=0 we get y = x = ±1 
Generally there is an algorithm that says there can be infinitely many Pell's like equations in which triples x, D and y are functions of a parameter like m.Now I solve equation x^2−5y^2 = 4 with this algorithm:
Suppose x=m^2 +2 we have:
m^2(m^2+4) = 5y^2
if y^2=m^2 then y = ±m and also:
m^2 +4 = 5 ;  m=±1 which results x = 3
and triples (x, D, y)=(m^2+2, 5m, ±m) for m=-1  and
(x, D, y) = (m^2+2, -5m, ±m) for m=1.
Now we can make more Pell's like equations; for example with m =2 we have:
D = 5 . 2 =10 that gives x^2 -10y^2 = 16 which it's solutions are x=2^2 +2 =6 
and y=±2.
A: For $x^2-5y^2=-4$ we have a base solution at $(x,y) = (1,1)$ and the unit solution for $x^2-5y^2=\pm1$ is $(x,y) = (2,1)$. So you can generate infinitely many solutions with:
\begin{equation*} x^2-5y^2 = (1-\sqrt{5})(1+\sqrt{5})(2-\sqrt{5})^n(2+\sqrt{5})^n = (-4)(-1)^n \end{equation*}
With $n=1$ that gives $(1+\sqrt{5})(2-\sqrt{5}) = -3 +\sqrt{5}, (1-\sqrt{5})(2+\sqrt{5}) = -3 -\sqrt{5}$ and we thus have $3^2-5(1^2) = 4$. We also have another base solution for $x^2-5y^2=4$ with $(x,y) = (\pm2, 0)$ which generates another family of solutions:
\begin{equation*} x^2-5y^2 = 4(2-\sqrt{5})^n(2+\sqrt{5})^n = (4)(-1)^n \end{equation*}
