On this page
In 1150 the Indian mathematician Bhaskara II wrote down a step-by-step way to find whole numbers x and y with Nx² + 1 = y². The MacTutor history of Pell's equation says Bhaskara II "discovered the cyclic method, called chakravala by the Indians."
What is Pell's equation?
Pell's equation asks for whole numbers x and y with Nx² + 1 = y², where N is a positive whole number that is not a perfect square. For N = 2, x = 2 and y = 3 work, because 2 × 4 + 1 = 9. For N = 61, the smallest answer has a ten-digit y.
The name is a mistake. According to MacTutor, Euler probably named it after John Pell because he mixed Pell up with William Brouncker, whose work John Wallis had reported. Fermat issued the equation as a challenge to English mathematicians in a 1657 letter, and MacTutor notes that one of his challenge problems was 61x² + 1 = y², "the same example of Pell's equation which had been studied by Bhaskara II 500 years earlier." Read more in our post on Pierre de Fermat and his last theorem.
Where did the chakravala method come from?
In his Brahmasphutasiddhanta of about 628, Brahmagupta found a rule for combining two near-solutions into a new one, as Wikipedia's Pell's equation article sets out. Brahmagupta is also the mathematician behind the earliest written rules for zero.
The chakravala article says the method is "commonly attributed to Bhāskara II", though some credit Jayadeva (c. 950 to 1000 CE), and that Bhaskara described it in his algebra text, the Bijaganita. The Bijaganita is one of the four parts of his Siddhanta Shiromani, written in 1150. The MacTutor biography gives his dates as 1114 to 1185. His arithmetic book is the subject of our post on the word problems of Bhaskara II's Lilavati.
How does the chakravala method solve Pell's equation?
Keep track of three numbers (a, b, k) with a² − Nb² = k. When k = 1, you are done: y = a and x = b. The engine is Bhaskara's lemma, stated in the chakravala article: if a² − Nb² = k, then for any m, ((am + Nb)/k)² − N((a + bm)/k)² = (m² − N)/k.
Start with a near miss: take a as the whole number closest to √N, b = 1, and k = a² − N.
Choose a positive m so that a + bm divides exactly by k. Among those, take the one that makes m² − N closest to zero.
Replace a with (am + Nb) ÷ |k|, b with (a + bm) ÷ |k|, and k with (m² − N) ÷ k.
Repeat until k = 1.
A worked example: 67x² + 1 = y²
Start with 8² − 67 × 1² = −3, so (a, b, k) = (8, 1, −3).
8 + m must divide by 3, so m could be 1, 4, 7 or 10. m = 7 brings m² nearest 67. New triple: (41, 5, 6). Check: 1681 − 1675 = 6.
m = 5 gives (90, 11, −7).
m = 9 gives (221, 27, −2).
m = 9 gives (1899, 232, −7).
m = 5 gives (3577, 437, 6).
m = 7 gives (9053, 1106, −3).
m = 8 gives (48842, 5967, 1).
So x = 5967 and y = 48842, the same answer the chakravala article gives. Look at the k values: −3, 6, −7, −2, −7, 6, −3, then 1. Before the final 1 they read the same forwards and backwards. The name itself comes from chakra, Sanskrit for "wheel", which the article says refers to the cyclic nature of the algorithm.
What happens with 61x² + 1 = y²?
The same rules starting from (8, 1, 3) give (39, 5, −4), then (164, 21, −5), (453, 58, 5), (1523, 195, 4), (5639, 722, −3) and (29718, 3805, −1). Halfway there, k = −1. Brahmagupta's rule for combining near-solutions, applied to this triple and itself, gives y = 29718² + 61 × 3805² = 1766319049 and x = 2 × 29718 × 3805 = 226153980. Wikipedia's account of Pell's equation confirms that this is the answer Bhaskara gave. The general theory came later, from Lagrange in 1766 to 1769.
How can you practise the method?
N = 7: start at (3, 1, 2). One step with m = 3 finishes it.
N = 13: start at (4, 1, 3). Two steps reach k = −1; then square it the way we did for 61.
If a step goes wrong, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer. If the divisibility test in step 2 feels shaky, the Fermi Concept Library has a lesson for every concept in mathematics, so you can review it first.



