In 1657 a lawyer in Toulouse, in the south of France, sent a challenge to the mathematicians of England and the rest of Europe. His name was Pierre de Fermat, and he did mathematics in his spare time, better than almost anyone alive. One of his questions looked like homework:
Find a whole number y so that **61 × y² + 1 is a perfect square.**
Take y = 1: 61 + 1 = 62, not a square (7² = 49, 8² = 64). Take y = 2: 61 × 4 + 1 = 245, not a square either (15² = 225, 16² = 256). Fermat, it seems, knew the answer, and wanted to see whether anyone else could find it. Try it.
Guess first. What is the smallest y that makes 61 × y² + 1 a perfect square?
Pick an answer to see why.
Smaller numbers first
Warm up with numbers that give in. For each N, find the smallest y (not 0) that makes N × y² + 1 a square, and that square’s root, x. Use a calculator.
- a.N = 3, 8, 15, 24. (Look at what each is one less than.)
- b.N = 2, 5, 10, 17. (Look at what each is one more than.)
- c.N = 6, 7, 11, 12.
- d.Predict, then check: N = 99 and N = 101.
Both patterns hold for every m (expand (2m² + 1)² and to prove the second). But most numbers are neither one more nor one less than a square, and for them the answers jump about with no pattern you can see:
| N | 13 | 29 | 46 | 60 | 61 | 62 |
|---|---|---|---|---|---|---|
| smallest y | 180 | 1,820 | 3,588 | 4 | 226,153,980 | 8 |
| its x | 649 | 9,801 | 24,335 | 31 | 1,766,319,049 | 63 |
Look at 60, 61 and 62. On either side of 61, the answer comes at y = 4 and y = 8. At 61 itself, nothing for 22 crore. Searching was never going to work.
What the answers are good for
Write the puzzle as an equation: whole numbers x and y with
Here N is a fixed whole number that is not a perfect square. This is called Pell’s equation, a name that is a mistake (the story is below). Mathematicians in India called it varga-prakriti, “the square with a multiplier”: the square y² multiplied by N.
Why should anyone care whether 61y² + 1 is a square? Divide the equation by y²:
So the fraction x/y, squared, overshoots N by only 1/y², which is tiny when y is big. In other words, x/y is an excellent fraction for √N. For 61:
- √61 = 7.810 249 675 906 654 394…
- 1,766,319,049 ÷ 226,153,980 = 7.810 249 675 906 654 395…
The first 17 decimal places agree. The same idea gives the old fractions for √2 and √3 that you may have met: 577/408 for √2 (577² − 2 × 408² = 1) and 1,351/780 for √3 (1,351² − 3 × 780² = 1).
For N = 7, the smallest answer is x = 8, y = 3. What does that tell you?
Pick an answer to see why.
Brahmagupta’s trick: new answers from old
In 628, in Bhillamala in western India (today’s Bhinmal, in Rajasthan), the astronomer Brahmagupta finished his great book, the Brahmasphutasiddhanta. In it is a discovery that turns one answer into infinitely many.
Take N = 8. You found x = 3, y = 1: 9 − 8 = 1. Here is the trick, which works with any two near-answers: whole numbers x, y with x² − N y² equal to some small number k, not necessarily 1. Write a near-answer as a triple (x, y, k). From two triples (a, b, k) and (c, d, l), Brahmagupta’s composition (in Sanskrit, bhavana) makes a third:
The small numbers multiply: if both were 1, the new one is 1 too. Compose (3, 1, 1) with itself for N = 8: (3 × 3 + 8 × 1 × 1, 3 × 1 + 1 × 3, 1) = (17, 6, 1). Check: 17² − 8 × 6² = 289 − 288 = 1. Compose again with (3, 1, 1): (99, 35, 1), and 99² − 8 × 35² = 9,801 − 9,800 = 1. These are the very numbers in Bhaskara’s own worked example for 8, which goes on “and so on, indefinitely, by means of composition.”
Why it works
Surds (Grade 9 Optional Maths) show why. Notice that
Now multiply two numbers of the form a + b√N:
because √N × √N = N: the composition’s two numbers. Do the same with minus signs, and multiply the two results: the left side is , and the right side is . So the new triple’s small number is kl. (Brahmagupta stated the rule in verse, without √N.)
Dividing a near-miss down to 1
The second half of Brahmagupta’s discovery is cleverer. If you can only find a near-answer with k = 2 or 4 (or −1, −2, −4), composition gets you to k = 1 anyway, by squaring and then dividing.
His own example, dressed as an astronomer’s puzzle, asks for y with 92y² + 1 a square, and with 83y² + 1 a square, and ends (in Colebrooke’s 1817 translation): “[a person solving this problem] within a year [is] a mathematician.” Here is the solution for 92, as his commentator Prithudaka worked it in Colebrooke’s translation.
- Try y = 1: 92 + 8 = 100 = 10². So (10, 1, 8) is a near-answer, with k = 8.
- Compose it with itself: (10 × 10 + 92 × 1 × 1, 10 × 1 + 1 × 10, 8 × 8) = (192, 20, 64).
- Now 192² − 92 × 20² = 64 = 8². Divide x and y by 8: (24, 5/2, 1). Check: 24² − 92 × (5/2)² = 576 − 575 = 1. Not whole numbers yet, but k = 1.
- Compose (24, 5/2, 1) with itself: (24 × 24 + 92 × 25/4, 24 × 5/2 × 2, 1) = (1,151, 120, 1).
So 92 × 120² + 1 = 1,324,801 = 1,151². The fractions vanished. Brahmagupta gave rules that always reach whole numbers from k = ±1, ±2 or ±4.
The catch: you need a near-answer with k = ±1, ±2 or ±4 to start from. For 92 and 83, y = 1 gave one. For 61, y = 1 gives 64 − 61 = 3, and nothing small gives ±1, ±2 or ±4 for a long way. Five hundred years after Brahmagupta, Bhaskara found how to get there from any start.
Bhaskara’s wheel: the chakravala
Bhaskara (1114–1185), head of the observatory at Ujjain, finished his Siddhanta Shiromani in 1150; its algebra part, the Bijaganita, holds the method. The Indian mathematicians called it the chakravala, the wheel or circle. It goes round and round one step, until k = 1.
One turn of the wheel
Start from any near-answer (a, b, k). For 61, take b = 1 and a = 8, whose square is nearest 61: 64 − 61 = 3, so (8, 1, 3). Now compose it with the easy triple (m, 1, m² − N), which is a near-answer for every whole number m (since m² − N × 1² = m² − N), and divide everything by k:
Bhaskara’s two rules for choosing m:
- choose m so that k divides a + bm, which keeps b′ whole (and then, it turns out, a′ and k′ are whole too);
- **among those, take the m whose m² − N is smallest**, so that the next k stays small.
For (8, 1, 3) and N = 61: 3 must divide 8 + m, so m = 1, 4, 7, 10, 13, …; their m² − 61 are −60, −45, −12, 39, 108, so m = 7. Then a′ = (56 + 61)/3 = 39, b′ = (8 + 7)/3 = 5, k′ = (49 − 61)/3 = −4. Check: 39² − 61 × 5² = 1,521 − 1,525 = −4. One turn, and every number is whole again.
In the widget, start 61 again and tap the worst of the four ms at every step. What happens?
Pick an answer to see why.
Why the numbers stay whole
This is the surprising part, and Bhaskara stated it without proof.
All the way round for 61
Bhaskara’s rule at every step takes 61 from (8, 1, 3) to the answer in 13 turns. Here are the ks, row by row:
3, −4, −5, 5, 4, −3, −1, −3, 4, 5, −5, −4, 3, 1.
Up to −1 halfway, then back through the same values in reverse. (The name means something simpler: the commentator Suryadasa says the method is “so denominated because it proceeds as in a circle”, round the same steps again and again.) The row with k = −1 is (29,718, 3,805, −1): 29,718² − 61 × 3,805² = −1. And row 14 is
Bhaskara himself took a shortcut. At row 2, (39, 5, −4), he had Brahmagupta’s ±4, so he divided by 2 to get (39/2, 5/2, −1), composed this with itself and again to reach the whole-number row (29,718, 3,805, −1), and squared that (composed it with itself: −1 × −1 = 1) for the answer. Every number agrees with the wheel’s.
Where the rule breaks
The minus-one equation
The equation x² − Ny² = −1 is a different matter. For 61 it has an answer (row 7 above), and for 2, 5, 10, 13 (y = 1, 1, 1, 5). But for N = 3 it has none at all, ever. The proof is short: a square leaves remainder 0 or 1 on division by 3 (0² = 0, 1² = 1, 2² = 4 = 3 + 1). If x² − 3y² = −1, then x² = 3y² − 1 leaves remainder 2 on division by 3. No square does.
Bhaskara gave a test: if N is not the sum of two squares, x² − Ny² = −1 has no answer (his words: “the instance proposed is imperfect”). He was right. But the test only works one way. 34 = 3² + 5² passes it, and still x² − 34y² = −1 has no answer: the wheel for 34 never reaches −1. The exact test known today needs a much longer calculation (the repeating pattern in the continued fraction of √N, beyond this topic).
Does the wheel always stop?
Bhaskara used the wheel for every example he tried, and it always stopped at k = 1. He, like the European mathematicians after him, seems to have taken it for granted that it always would. That is true, but not obvious. The proof that x² − Ny² = 1 has an answer for every non-square N came from the French mathematician Joseph-Louis Lagrange in 1768, more than 600 years later.
Where this is used
- Fractions for square roots. Every answer to x² − Ny² = 1 gives a fraction x/y very close to √N, as for 61. Baudhayana’s 577/408 for √2, in the ancient Shulba Sutras of India, is one, as Can You Prove √2 Is Not a Fraction? shows; Archimedes’ 1,351/780 for √3 is another.
- Whole-number puzzles. Right triangles whose two short sides differ by 1 (20, 21, 29; 119, 120, 169; 696, 697, 985) come from , the subject of How Do You Find Every Right Triangle with Whole Sides?. Numbers that are both square and triangular (1, 36, 1,225, …) come from x² − 8y² = 1 (Question d.).
- Computers and quantum computers. How fast an answer can be found is a research question today, because the smallest answer can have roughly √N digits, too long even to write down when N is big; mathematicians write such answers as short products instead. In 2002 Sean Hallgren showed that a quantum computer could find one in “polynomial time”, much faster as N grows than any method known for ordinary computers, which, as Lenstra wrote that year, will stay the practical way “until quantum computers become available”.
Questions
★ Which pair solves x² − 15y² = 1?
Pick an answer to see why.
For N = 3 the smallest answer is (2, 1). a. Compose (2, 1, 1) with itself, and again, and again, to find the next three answers. b. Which composition gives Archimedes’ 1,351/780?
Answer
Run the chakravala by hand for N = 13, starting from (4, 1, 3), as far as k = −1. Then use that row to finish.
Hint
Answer
Show that x² − 3y² = −1 has no whole-number answer, and that x² − 4y² = 1 has none with y ≠ 0.
Answer
36 is a square (6²) and a triangular number (1 + 2 + … + 8 = 8 × 9/2). a. Show that n(n + 1)/2 = s² is the same as x² − 8s² = 1, with x = 2n + 1. b. Use composition with (3, 1, 1) to find the next two numbers that are both square and triangular after 36.
Hint
Answer
Where to go next
- Can You Buy 100 Birds with 100 Coins? Whole-number equations of the first degree, and the kuttaka, the “pulverizer” Bhaskara used to find each m.
- How Many Eggs Were in the Basket? Remainder puzzles, one of them Bhaskara’s own from the Bijaganita.
- How Did Madhava Find π Without a Calculator? India’s next great discovery: an endless sum for π, centuries before Europe.
- Can You Solve the Puzzles of the Lilavati? (Grades 6–8) Bhaskara’s arithmetic book, and his puzzles in verse.
- How Does a Calculator Find a Square Root? (Computing, Going Further) Getting ever-better fractions for √N by machine.
- Grade 10 Math: Quadratic Equation Equations with squares in them, solved for one unknown.
Where these facts come from
- Bhaskara’s Bijaganita, chapter 3 (“Affected square”), §§ 75–87: the rules of composition, the cyclic method, the examples 8 and 11 (roots 1, 3; 6, 17; 35, 99 for 8), the example of 67 and 61 with the “creeper” verse, the worked solutions (67: 5,967 and 48,842; 61: through 5, 39 with additive −4, then 3,805, 29,718 with −1, to 226,153,980 and 1,766,319,049), Suryadasa’s note on the name; § 88–89, the sum-of-two-squares test (“the instance proposed is imperfect”); Brahmagupta’s chapter 18, §§ 65–67 (question 87), the 92 and 83 problem, “within a year [is] a mathematician”, and the commentary’s working (by Prithudaka, Colebrooke’s source for Brahmagupta), roots 120, 1,151 and 9, 82: H. T. Colebrooke, Algebra, with Arithmetic and Mensuration, from the Sanscrit of Brahmegupta and Bháscara (1817, public domain), pp. 170–179 and 363–364, Internet Archive, read October 2026.
- Brahmagupta’s composition and the ±1, ±2, ±4 rule, his example 83, Bhaskara’s method and the 61 example, Narayana’s examples 97 and 103, Fermat’s 1657 challenge including 61 and his remark about Narbonese Gaul, Frénicle’s table up to 150 and his 313, Brouncker’s “an hour or two”, Wallis’s Commercium epistolicum (1658), Euler’s naming, Lagrange: J. J. O’Connor and E. F. Robertson, “Pell’s equation”, MacTutor, read October 2026.
- Bhaskara’s dates, birthplace and the Ujjain observatory, the Bijaganita’s chapters: MacTutor, “Bhaskara II”; Brahmagupta’s dates, Bhillamala and Ujjain: MacTutor, “Brahmagupta”, read October 2026.
- Fermat posing 109 in 1657 (and its answer), Pell’s dates and that he “has nothing to do with the equation”, attempts to change the name “futile”, Euler and his predecessors taking it “for granted” that the method always works, Lagrange’s proof of 1768, the cattle problem (Lessing, Amthor 1880, 206,545 digits, 47 pages of printout), the size of answers, Hallgren’s quantum algorithm: H. W. Lenstra Jr., “Solving the Pell Equation”, Notices of the AMS 49(2), 182–192 (2002), read October 2026 (through the Wayback Machine).
- Bhaskara’s method as the first general one (1150), the triple form of composition, Brahmagupta’s (10, 1, 8) → (192, 20, 64) → (24, 5/2, 1) → (1,151, 120, 1), Baudhayana’s 577/408, Archimedes’ 1,351/780, Rahn’s 1659 algebra and Euler’s mistake, Lagrange 1766–1769, the cattle problem’s Pell equation with N = 410,286,423,278,424, Hallgren’s result: Wikipedia, “Pell’s equation”, read October 2026.
- Hankel’s judgment, in his words “sicherlich das Feinste, was in der Zahlenlehre vor Lagrange geleistet worden ist” (our translation): H. Hankel, Zur Geschichte der Mathematik in Alterthum und Mittelalter (1874, public domain), pp. 202–203, Internet Archive, read October 2026.
- Jayadeva and the credit some give him, Selenius (1975, Historia Mathematica 2, 167–184, not opened: his words as Wikipedia quotes them) on the chakravala as a best-approximation method of minimal length: Wikipedia, “Chakravala method”; Jayadeva known from 20 verses quoted in a commentary of 1073: Wikipedia, “Jayadeva (mathematician)”, read October 2026.
- The name vargaprakṛti, and Bhaskara solving 61 more than five centuries before Fermat: Wikipedia, “Bhāskara II”, read October 2026.
- The cattle problem’s discovery in 1773 at Wolfenbüttel, the 44-line poem, Amthor’s 1880 work, and the 1965 computer solution (Williams, German and Zarnke, Mathematics of Computation 19): Wikipedia, “Archimedes’s cattle problem”, read October 2026.
- Every number on this page (the smallest answers for every N in the tables and questions, checked by trying every y where they are small and by continued fractions where they are not; the record-breakers up to 200; the 17 decimal places for √61; every composition; every row of the chakravala for 13, 61, 67, 97 and 103; the lemma checked over small cases; no answer to x² − 34y² = −1 below y = 1,000,000 and none in the continued fraction; the square triangular numbers) was computed by a script,
checks/textbooks/math-further-9-12/36/tmp/pell.py.
