# How to find all solutions for Pell's equation $x^2 - Dy^2 = -1$ after the first $x_0$ and $y_0$?

How to find all solutions for Pell's equation $x^2 - Dy^2 = -1$ after the first $x_0$ and $y_0$?
for example if we have $x^2 - 2 y^2 = -1$ then the smallest integer solution for $(x,y) = (1,1)$
How to build on this to get the rest of the solutions ?

-

## 1 Answer

You mean $x^2-2y^2=-1$. The answer is, take odd powers of $x_0+y_0\sqrt D$. If such a power is $a+b\sqrt D$, then $a^2-Db^2=-1$.

-
Thanks that solved it ^^ ,and yep that's what I meant , I edited the question .. –  Loers Antario Sep 28 '12 at 13:52
Note, as in the now deleted answer by @MartinSleziak, that you can write a simple recurrence for all solutions by expanding $x_{2n+1}+y_{2n+1}\sqrt D = (x_{2n-1}+y_{2n-1}\sqrt D)(x_0+y_0\sqrt D)^2$. –  lhf Sep 28 '12 at 15:26