Brahmagupta–Fibonacci identity

In algebra, the Brahmagupta–Fibonacci identity expresses the product of two sums of two squares as a sum of two squares in two different ways. Hence the set of all sums of two squares is closed under multiplication. Specifically, the identity says with the plus-minus sign indicating that either a plus or minus may be used, with the minus-plus sign being the reverse. The equivalence of the two forms can be seen in the following example:

The identity is also known as the Diophantus identity, as it was first proved by Diophantus of Alexandria. It is a special case of Euler's four-square identity, and also of Lagrange's identity.

Brahmagupta proved and used a more general Brahmagupta identity, stating This shows that, for any fixed A, the set of all numbers of the form x2 + Ay2 is closed under multiplication.

These identities hold for all integers, as well as all rational numbers; more generally, they are true in any commutative ring. All four forms of the identity can be verified by expanding each side of the equation.