[The following exposition covers some familiar territory, but with perhaps a more perspicuous narrative.] Factoring/normalizing quaternions Henry Baker Posted 10/13/2020 to math-fun Let Q=A+Bj be an arbitrary quaternion, for arbitrary complex numbers A,B. I.e., quaternions can be represented as pairs of ordinary complex numbers; j is a symbol which does NOT commute with the ordinary complex 'i'. Complex numbers are commutative and always have square roots. Note that i^2=j^2=-1, and ij=k, and ijk=-1, as is usual for quaternions. (We won't be needing or using 'k' in this exposition.) Let A' be the complex conjugate of A, B' be the complex conjugate of B. Let N(A)=N(A')=AA'=|A|^2. N() is a multiplicative homomorphism. Now jB = B'j, so we can commute complex numbers with the j quaternion, so long as we conjugate them when they hop over j in either direction. We can 'normalize' the A component of Q into a non-negative real number by pre and post multiplication: (1/sqrt(A))Q(sqrt(A))' = (1/sqrt(A)) (A+Bj) (sqrt(A))' = (1/sqrt(A)) (A+Bj) sqrt(A') = (1/sqrt(A)) A(sqrt(A')) + (1/sqrt(A)) Bj (sqrt(A')) = sqrt(A) sqrt(A') + (1/sqrt(A)) B (sqrt(A))j = sqrt(AA') + Bj = sqrt(|A|^2) + Bj = |A| + Bj So Q = A+Bj = sqrt(A) (|A|+Bj) (1/sqrt(A))' Note that this works even when A is already a negative real number, e.g., A=-1, because sqrt(A)=sqrt(-1)=i, and (1/sqrt(A))'=(1/i)'=(-i)'=i, and A+Bj = -1+Bj = i (1+Bj) i = i^2 + iBji = -1 + i(-i)Bj = -1+Bj. Similarly, we an 'normalize' the B component of Q into a non-negative real number by pre and post multiplication: (1/sqrt(B))Q(sqrt(B)) = (1/sqrt(B)) (A+Bj) sqrt(B) = (1/sqrt(B)) A (sqrt(B)) + (1/sqrt(B)) Bj (sqrt(B)) = A + sqrt(B) j (sqrt(B)) = A + sqrt(B) sqrt(B') j = A + sqrt(BB') j = A + sqrt(|B|^2) j = A + |B|j So Q = A+Bj = sqrt(B) (A+|B|j) (1/sqrt(B)) Combining these two operations into one: (1/sqrt(AB))Q(sqrt(A'B) = (1/sqrt(AB)) (A+Bj) (sqrt(A'B)) = (1/sqrt(AB)) A (sqrt(A'B)) + (1/sqrt(AB)) Bj (sqrt(A'B)) = (1/sqrt(B)) sqrt(A) (sqrt(A'B)) + (1/sqrt(A)) sqrt(B) j (sqrt(A'B)) = sqrt(A) sqrt(A') + (1/sqrt(A)) sqrt(B) sqrt(B'A) j = sqrt(|A|^2) + sqrt(B) sqrt(B') j = |A| + sqrt(BB') j = |A| + |B|j So, Q = A+Bj = sqrt(AB) (|A|+|B|j) (1/sqrt(A'B)) We have thus factored our quaternion into two complex numbers sqrt(AB) and 1/sqrt(A'B), and a quaternion having only real (rather than complex) components. If Q is a 'unit' quaternion -- i.e., QQ'=1 -- then QQ' = N(sqrt(AB)) N(|A|+|B|j) N(1/sqrt(A'B) = sqrt(N(A)) sqrt(N(B)) N(|A|+|B|j) 1/(sqrt(N(A')) sqrt(N(B))) = sqrt(N(A)) N(|A|+|B|j) 1/sqrt(N(A')) = sqrt(N(A)) N(|A|+|B|j) 1/sqrt(N(A))) = N(|A|+|B|j) = N(A)+N(B) = |A|^2+|B|^2 = 1 So in this unit quaternion case, we can set |A|=cos(theta), |B|=sin(theta), for a suitable real angle theta in the first quadrant, and Q = A+Bj = sqrt(AB) (|A|+|B|j) (1/sqrt(A'B)) = sqrt(AB) (cos(theta)+sin(theta)j) (1/sqrt(A'B)) Note for the record that sqrt(AB)/sqrt(A'B) = sqrt(A)/sqrt(A') = sqrt(A/A') = sqrt(AA/AA') = sqrt(AA)/sqrt(AA') = A/sqrt(|A|^2) = A/|A| = phase(A) However, our factorization is NOT the same as the more usual factorization in terms of phases, since |sqrt(AB)| /= 1, and |1/sqrt(A'B)| /= 1. We can always recover the more traditional factorization by taking phases: Q = A+Bj = phase(sqrt(AB)) (|A|+|B|j) phase(1/sqrt(A'B)) since |sqrt(AB)|/|sqrt(A'B)| = |phase(A)| = 1. and if QQ'=1, we get the classical factorization Q = A+Bj = phase(sqrt(AB)) (cos(theta)+sin(theta)j) phase(1/sqrt(A'B)) = exp(i*gamma) (cos(theta)+sin(theta)j) exp(i*delta) for suitable real angles gamma, delta, theta. We have one last factorization to make. If m,n are *real* numbers then m+nj is a quaternion both of whose complex components are missing their imaginary parts. We can convert such a quaternion m+nj to the complex number m+ni by means of following product: m+ni = -(i+j)(m+nj)(i+j)/2 or -2m-2ni = (i+j)(m+nj)(i+j) = m(i+j)^2 + n(i+j)j(i+j) = m(i^2+j^2) + n(i+j)(ji+jj) = -2m + n(i+j)(-ij-1) = -2m - n(i+j)(1+ij) = -2m - n(i+i^2j+j+jij) = -2m - n(i-j+j-ij^2) = -2m - n(i+i) = -2m - 2ni But the same transformation also works in reverse! -2m-2nj = (i+j)(m+ni)(i+j) = m(i+j)^2 + n(i+j)i(i+j) = -2m + n(i+j)(i^2+ij) = -2m + n(i+j)(-1+ij) = -2m + n(-i -j +i^2j + jij) = -2m + n(-i -j -j - ij^2) = -2m + n(-2j -i + i) = -2m -2nj This transformation thus allows us to convert cos(theta)+sin(theta)j into cos(theta)+sin(theta)i, and then into exp(i*theta). -2*exp(i*theta) = -2*(cos(theta)+sin(theta)i) = (i+j) (cos(theta)+sin(theta)j) (i+j) So our original arbitrary quaternion Q can be factored as Q = A+Bj = sqrt(AB) (|A|+|B|j) (1/sqrt(A'B)) = -(sqrt(AB) (i+j) (|A|+|B|i) (1/sqrt(A'B)))/2 where |A|+|B|i is now an ordinary complex number in the first quadrant. We note that |A|,|B| supply only 2 degrees of freedom, so the other two degrees of freedom are supplied by phase(sqrt(AB)) and phase(1/sqrt(A'B)). Once again, if Q is a unit quaternion, QQ'=1, then Q = A+Bj = phase(sqrt(AB)) (cos(theta)+sin(theta)j) phase(1/sqrt(A'B)) = exp(i*gamma) (cos(theta)+sin(theta)j) exp(i*delta) = -exp(i*gamma) (i+j) (cos(theta)+sin(theta)i) (i+j) exp(i*delta)/2 = -exp(i*gamma) (i+j) exp(i*theta) (i+j) exp(i*delta)/2 for suitably chosen angles gamma, theta, delta. A unit quaternion has 3 real degrees of freedom, and this 3-parameter factorization provides one convenient representation.