# 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
    ${\begin{aligned}\left(a^{2}+b^{2}\right)\left(c^{2}+d^{2}\right)&=\left(ac-bd\right)^{2}+\left(ad+bc\right)^{2}&&(1)\\&=\left(ac+bd\right)^{2}+\left(ad-bc\right)^{2}.&&(2)\end{aligned}}$
For example,
    $(1^{2}+4^{2})(2^{2}+7^{2})=26^{2}+15^{2}=30^{2}+1^{2}.$
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
    ${\begin{aligned}\left(a^{2}+nb^{2}\right)\left(c^{2}+nd^{2}\right)&=\left(ac-nbd\right)^{2}+n\left(ad+bc\right)^{2}&&(3)\\&=\left(ac+nbd\right)^{2}+n\left(ad-bc\right)^{2}.&&(4)\end{aligned}}$
This shows that, for any fixed A, the set of all numbers of the form x$^2$ + Ay$^2$ 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. Also, (2) can be obtained from (1), or (1) from (2), by changing b to −b, and likewise with (3) and (4).

## History

The identity first appeared in Diophantus' Arithmetica (III, 19), of the third century A.D. It was rediscovered by Brahmagupta (598–668), an Indian mathematician and astronomer, who generalized it to Brahmagupta's identity, and used it in his study of what is now called Pell's equation. His Brahmasphutasiddhanta was translated from Sanskrit into Arabic by Mohammad al-Fazari, and was subsequently translated into Latin in 1126. The identity was introduced in western Europe in 1225 by Fibonacci, in The Book of Squares, and, therefore, the identity has been often attributed to him.

## Related identities

Analogous identities are Euler's four-square related to quaternions, and Degen's eight-square derived from the octonions which has connections to Bott periodicity. There is also Pfister's sixteen-square identity, though it is no longer bilinear.
These identities are strongly related with Hurwitz's classification of composition algebras.
The Brahmagupta–Fibonacci identity is a special form of Lagrange's identity, which is itself a special form of Binet–Cauchy identity, in turn a special form of the Cauchy–Binet formula for matrix determinants.

## Multiplication of complex numbers

If a, b, c, and d are real numbers, the Brahmagupta–Fibonacci identity is equivalent to the multiplicative property for absolute values of complex numbers:
    $|a+bi|\cdot |c+di|=|(a+bi)(c+di)|.$
This can be seen as follows: expanding the right side and squaring both sides, the multiplication property is equivalent to
    $|a+bi|^{2}\cdot |c+di|^{2}=|(ac-bd)+i(ad+bc)|^{2},$
and by the definition of absolute value this is in turn equivalent to
    $(a^{2}+b^{2})\cdot (c^{2}+d^{2})=(ac-bd)^{2}+(ad+bc)^{2}.$
An equivalent calculation in the case that the variables a, b, c, and d are rational numbers shows the identity may be interpreted as the statement that the norm in the field Q(i) is multiplicative: the norm is given by
    $N(a+bi)=a^{2}+b^{2},$
and the multiplicativity calculation is the same as the preceding one.

## Application to Pell's equation

In its original context, Brahmagupta applied his discovery of this identity to the solution of Pell's equation x$^2$ − Ay$^2$ = 1. Using the identity in the more general form
    $(x_{1}^{2}-Ay_{1}^{2})(x_{2}^{2}-Ay_{2}^{2})=(x_{1}x_{2}+Ay_{1}y_{2})^{2}-A(x_{1}y_{2}+x_{2}y_{1})^{2},$
he was able to "compose" triples (x$_1$, y$_1$, k$_1$) and (x$_2$, y$_2$, k$_2$) that were solutions of x$^2$ − Ay$^2$ = k, to generate the new triple
    $(x_{1}x_{2}+Ay_{1}y_{2}\,,\,x_{1}y_{2}+x_{2}y_{1}\,,\,k_{1}k_{2}).$
Not only did this give a way to generate infinitely many solutions to x$^2$ − Ay$^2$ = 1 starting with one solution, but also, by dividing such a composition by k$_1$k$_2$, integer or "nearly integer" solutions could often be obtained. The general method for solving the Pell equation given by Bhaskara II in 1150, namely the chakravala (cyclic) method, was also based on this identity.

## Writing integers as a sum of two squares

When used in conjunction with one of Fermat's theorems, the Brahmagupta–Fibonacci identity proves that the product of a square and any number of primes of the form 4n + 1 is a sum of two squares.