Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|cite|improve this question
up vote 4 down vote accepted

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$.

share|cite|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.