Quaternion identity

The Quaternion identity expresses the product of any two numbers, each expressed as the sum of four squares, as the sum of four squares. [ Edit]
 * Main article: Quaternion identity



Derivation from quaternions
The quaternion units 1,i,j,k are defined so that
 * 1 = 1*1 = -i2 = -j2 = -k2
 * i = 1i = i1 = jk = -kj
 * j = 1j = -ik = j1 = ki
 * k = 1k = ij = -ji = k1

If u=a-bi-cj-dk, U=A+Bi+Cj+Dk, then from
 * u||U|=|uU|,

we get
 * (a2+b2+c2+d2)(A2+B2+C2+D2) = (aA+bB+cC+dD)2+(aB-bA-cD+dC)2+(aC+bD-cA-dB)2+(aD-bC+cB-dA)2

In defining u, the signs of b, c, and d are arbitrary; We could have just as easily defined them differently (or permuted the meanings of A, B, C and D). The important observations to make regarding the sign of the variables a,b,c,d,A,B,C,D on the right hand side of the equation are:
 * One of the eight variables, which we will arbitrarily call a has a positive sign whereever it appears. This fixes a as one of the lower-case variables.
 * One of the four variables upper-case variables, which we arbitrarily call A has a negative sign wherever it appears, except with a. This fixes the relationship between a and A.
 * Then the pairing of b, c, and d with B, C, and D is such that bC, cD, and dB have a negative sign; and cB, dC, and bD have a positive sign.

Generalization
By defining $$u=a-bi-\sqrt{n}cj-\sqrt{n}dk\,$$ and $$U=A+Bi+\sqrt{n}Cj+\sqrt{n}Dk\,$$, then from
 * u||U|=|uU|,

we get
 * (a2+b2+nc2+nd2)(A2+B2+nC2+nD2) =   (aA+bB+ncC+ndD)2+(aB-bA-ncD+ndC)2+n(aC+bD-cA-dB)2+n(aD-bC+cB-dA)2

Application
A simple application of this identity is
 * 3(A^2+B^2+C^2+D^2) = (A+B+C)^2+(D+A-B)^2+(C+D-A)^2+(B-C+D)^2