On this page
Take 5 = 1² + 2² and 13 = 2² + 3². Their product, 65, is also a sum of two squares: 65 = 8² + 1² = 4² + 7². That is no accident. Around 628 CE, the astronomer Brahmagupta stated a rule that turns any two such sums into a third, and then pushed the same rule into a much harder kind of equation.
What is the Brahmagupta identity?
The identity reads (a² + b²)(c² + d²) = (ac ± bd)² + (ad ∓ bc)², where you take the top signs together or the bottom signs together (Wikipedia, Brahmagupta–Fibonacci identity). The same article notes it first appeared in Diophantus' Arithmetica in the third century, that Brahmagupta rediscovered and generalised it, and that Fibonacci introduced it to western Europe in 1225 in The Book of Squares, which is why his name is attached.
You can check it by expanding both sides. The cross terms 2abcd cancel, and what is left on the right is a²c² + b²d² + a²d² + b²c², exactly the left side multiplied out.
With a = 1, b = 2, c = 2, d = 3:
Top signs: (1·2 + 2·3)² + (1·3 − 2·2)² = 8² + (−1)² = 65
Bottom signs: (1·2 − 2·3)² + (1·3 + 2·2)² = (−4)² + 7² = 65
The two sign choices give 65 two different pairs.
That link to complex numbers is stated in the same Wikipedia article. Its vector cousin, |a × b|² + (a · b)² = |a|²|b|², is worked through in our post on Lagrange's identity for cross and dot products.
Who was Brahmagupta?
The MacTutor archive at the University of St Andrews gives his birth year as 598, possibly in Ujjain (MacTutor biography). He became head of the astronomical observatory at Ujjain, and in 628 he wrote the Brahmasphutasiddhanta, which he says he wrote at Bhillamala, today's Bhinmal. His later book, the Khandakhadyaka of 665, holds his sine interpolation rule, covered in our post on Brahmagupta's second-order interpolation formula.
How did Brahmagupta use it on Pell's equation?
The equation Nx² + 1 = y² asks for whole numbers x and y. Brahmagupta's key move, composition, combines two solutions into a new one. MacTutor's history states it: if (a, b) and (c, d) solve it, with x first, so do (bc + ad, bd + Nac) (MacTutor, Pell's equation).
In modern notation, (y₁² − Nx₁²)(y₂² − Nx₂²) = (y₁y₂ + Nx₁x₂)² − N(x₁y₂ + x₂y₁)². Put N = −1 and you get the sums-of-squares identity back. So the same algebra covers both.
MacTutor also records the clever part: if Brahmagupta could find a pair that nearly worked, meaning Nx² + k = y² with k equal to 1, −1, 2, −2, 4 or −4, he could find one, and therefore many, whole-number solutions (MacTutor, Pell's equation).
Worked example: 92x² + 1 = y²
Brahmagupta's famous case was N = 92, which Wikipedia's Pell's equation article says he solved by composing the triple (10, 1, 8) with itself and dividing by 64. Here is every step, with y first.
Near-miss: 10² − 92·1² = 100 − 92 = 8. Off by 8, not 1.
Compose (10, 1) with itself: y = 10·10 + 92·1·1 = 192 and x = 10·1 + 1·10 = 20. The errors multiply, so 192² − 92·20² = 36864 − 36800 = 64.
Divide y and x by 8, which divides the error by 64: y = 24, x = 5/2, and 24² − 92·(5/2)² = 576 − 575 = 1. Correct, but x is a fraction.
Compose (24, 5/2) with itself: y = 24² + 92·(5/2)² = 576 + 575 = 1151 and x = 2·24·(5/2) = 120.
Check: 1151² = 1324801 and 92·120² = 1324800. So 92·120² + 1 = 1151².
What came after Brahmagupta?
Composition alone needs a good near-miss to start. Bhaskara II supplied a general route in 1150 with the cyclic chakravala method (MacTutor, Pell's equation). Pierre de Fermat posed the equation as a challenge to English mathematicians in a 1657 letter (Wikipedia, Pell's equation). For the other big Indian method of whole-number equations, see Aryabhata's kuttaka for ax − by = c.
How to practise this in one sitting
Write 13 × 17 = 221 as a sum of two squares in both ways, using 13 = 2² + 3² and 17 = 1² + 4².
Redo the 92 example with N = 23, starting from 5² − 23·1² = 2.
Prove the identity by expanding, without looking.
If step 2 stalls, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer, and the Fermi Concept Library has its own lesson for each concept in mathematics, complex numbers included.



