## Solutions of Diophantine Equations x^2-ny^2=pm 1

Theorem
Suppose the Diophantine equation
$x^2-ny^2=-1$
has a solution
$x=x_1, \; y=y_1$
, Then
$x=2x_1^2+1, \; y=2x_1y_1$
satisfies the Diophantine equation
$x^2-ny_2=1$
.
Proof
$(2x_1^2+1)^2-n(2x_1y_1)^2=4x_1^4+4x_1^2+1-4nx_1^2y_1^2=4x_1^2(x_1^2-ny_1^2+1)+1=1$
since
$x_1^2-ny_1^1+1=0$
in the statement of the theorem.
Suppose for example that
$\sqrt{n}=\sqrt{74}$
has continued fraction
$[ 8 \lt 1,1,1,1,16 \gt ]$
.
The first solution will be found from the convergent
$[ 8,1,1,1,1]$
. This is equal to
$\frac{43}{5}$
and the solution is
$x=43, \; y=5$
. Another solution according to the theorem is
$x=2 \times 43^2+1=3699, \; y=2 \times 43 \times 5=430$
and
$3699^2- 74 \times 430^2=1$
.