Introduction to Quaternions
Quaternions, invented by William Rowan Hamilton, have the
form:
Q = a + bi + cj + dk
Quaternions are four-dimensional complex numbers, used in
applications of relativity, three dimensional rotations, and crystallographic
texture analysis. This blog entry will
cover some of the basic calculations used with quaternions.
Let’s start with the i, j, and k coefficients first. Some of the basic properties are:
i^2 = j^2 = k^2 = -1
(just like ordinary complex numbers)
Then: (the order of which the i, j, and k are multiplied is
important)
i*j = k
j*k = i
k*I = j
Going in reverse:
i*k = -j
k*j = -i
j*i = -k
Furthermore, the multiplication of two quaternions are
not communicative, which means for any two quaternions P and Q, P*Q ≠ Q*P.
If your calculator can handle complex-numbered matrices,
such as the HP Prime and HP 50g (I am thinking the TI-89 also qualifies), we
can use that form to work with quaternions fairly easily. For the quaternion Q = a + bi + cj + dk, the
2 x 2 matrix form is:
[[ a + b*i, c + d*i]
[ -c + d*i, a –
b*i]]
If the matrices can only handle real numbers, don’t despair,
we can still use a 4 x 4 matrix representation, like this:
[[ a, b, c, d ], [-b, a, -d, c], [-c, d, a, -b], [-d, -c,
b, a ]]
For this blog entry, we will concentrate on the 2 x 2
matrix format of quaternions. The
program QTM converts a quaternion to its matrix form. I made the name short so it would be easier
to type should this be used as a subroutine in future programs.
HP Prime:
QTM(A,B,C,D)
BEGIN
RETURN [[A+B*i, C+D*i],
[-C+D*i, A-B*i]];
END;
HP 50g:
Input: A, B, C, D
on stacks 4 through 1, respectively
QTM:
<< -> A B C D
<< A B R->C
C D R->C
C NEG D R->C A B R->C CONJ
{2, 2} ->ARRY >> >>
Note that QTM only accepts numeric arguments.
Basic Calculations and Examples
For the following examples let P and Q represent the
quaternions:
P = 5 + 2i + 3j + 4k
Q = 3 +6i – 2j + 8k
Using QTM to transform P and Q into matrix form yields:
P = [[ 5 + 2i, 3 + 4i ],[ -3 + 4i, 5 – 2i ]]
Q = [[ 3 + 6i, -2 + 8i],[ 2 + 8i, 3 – 6i ]]
Hamilton Multiplication: Just multiply the two matrices. Remember order is important since in general,
P*Q ≠ Q*P
Q*P = [[ -23 + 4i, -9 + 74i ],[ 9 + 74i, -23 -4i ]] (This represents -23 + 4i – 9j + 74k)
P*Q = [[ -23 + 68i, 7 + 30i ],[ -7 + 30i, -23 – 68i
]] (This represents -23 + 68i + 7j +
30k)
Quaternion Norm: norm(Q) = √(a^2 + b^2 + c^2 + d^2) = √(det(Q
in matrix form))
Caution: don’t use ABS(Q)
norm(P) = √54 ≈ 7.3847
norm(Q) = √113 ≈ 10.63015
Unit Quaternion:
U_Q = Q / norm(Q)
U_P ≈ [[ 0.68041 + 0.27217i, 0.40825 + 0.54433i ], [
-0.40825 + 0.54433i, 0.68041 – 0.27217i ]]
U_Q ≈ [[ 0.28222 + 0.56443i, -0.18814 + 0.75258i ], [
0.18814 + 0.75258i, 0.28222 – 0.56443i ]]
Reciprocal of a Quaternion: U^-1 = conj(Q)/norm(Q)^2. Yes, we can use the inverse (1/x) function
here.
P^-1 ≈ [[ 0.09259 – 0.03704i, -0.0556 – 0.07407i ], [
0.0556 – 0.07407i, 0.09259 + 0.03704i ]]
Q^-1 ≈ [[ 0.02655 – 0.05310i, 0.01770 – 0.07080i ], [
-0.01770 – 0.07080i, 0.02655 + 0.05310i ]]
Conjugate using the Reciprocal and Norm: conj(Q) = Q^-1 * norm(Q)^2
conj(P) = P^-1 * norm(P)^2 = [[ 5 – 2i, -3 – 4i ], [ 3 –
4i, 5 + 2i ]]
conj(Q) = Q^-1 * norm(Q)^2 = [[ 3 – 6i, 2 – 8i ],[ -2 –
8i, 3 + 6i ]]
That is some of the basic calculations used with
quaternions.
Sources:
Calvert, Dr. James B.
“Quaternions” web.archive.org/web/20200214052743/http://mysite.du.edu/~jcalvert/math/quatern.htm Retrieved June 20, 2015 (updated January 23, 2024)
Weisstein, Eric W.
“Quaternion” From Mathworld – A Wolfram Web Resource http://mathworld.wolfram.com/Quaternion.html Retrieved June 22, 2015
“Quaternion”
Wikipedia https://en.wikipedia.org/wiki/Quaternion Retrieved June 20, 2015
Talk to you all next time!
Eddie
Update: (1/23/2024). A typo has been corrected. Also, the link to Quanternions has been moved to web.archive.org. Thank you and gratitude to Carl Holmberg.
This blog is property of Edward Shore. 2015.