Pell Equation Solver

x² − Dy² = 1

CalculatorsFreeNo Signup
4.6(287 reviews)
All Tools

Loading tool...

About Pell Equation Solver

A Pell equation solver finding integer solutions to x² − Dy² = 1 using continued fraction expansion of √D. Computes the fundamental solution and generates subsequent solutions via recurrence. All calculations are client-side.

Pell Equation Solver Features

  • Fundamental solution
  • Solution sequence
  • CF expansion
  • Verification
  • Table
Pell's equation x²−Dy²=1: for non-square D>0, infinitely many solutions exist. Fundamental solution (x₁,y₁) from continued fraction of √D. All solutions: xₙ₊₁=x₁xₙ+Dy₁yₙ, yₙ₊₁=x₁yₙ+y₁xₙ. Equivalently (xₙ+yₙ√D) = (x₁+y₁√D)ⁿ.

How to Use

Enter D:

  • D: Non-square positive integer
  • (x₁,y₁): Fundamental solution
  • More: Generated solutions

Method

Expand √D as continued fraction [a₀; a₁,a₂,...,aₖ] (periodic). Convergent pₖ/qₖ at end of period gives fundamental solution (x₁,y₁) = (pₖ,qₖ). If period length is odd, use (p₂ₖ,q₂ₖ).

History

Misnamed after John Pell. Actually studied by Brahmagupta (628 CE), Bhaskara II (1150), Fermat, and Euler. Lagrange proved all non-square D have solutions.

Step-by-Step Instructions

  1. 1Enter D.
  2. 2Get fundamental solution.
  3. 3Generate more.
  4. 4Verify x²−Dy²=1.
  5. 5View CF expansion.

Pell Equation Solver — Frequently Asked Questions

Why does the continued fraction method work?+

The convergents pₙ/qₙ of √D are best rational approximations. The fundamental solution occurs when pₙ²−Dqₙ²=±1, which happens at the end of the periodic part. Lagrange proved this always works for non-square D.

How large can the fundamental solution be?+

For D=61: (x₁,y₁) = (1766319049, 226153980). For D=109: x₁ has 15 digits! The size depends on the period length of the CF of √D, which can be O(√D). Small D can have huge solutions.

What about x²−Dy²=−1?+

The negative Pell equation x²−Dy²=−1 has solutions iff the CF period of √D has odd length. Not all D admit solutions: D=3 has none, D=2 has (1,1). When solvable, solutions generate both +1 and −1 cases.

Share this tool: