School of Mathematics, Tel: +44 (0) 1509 22 2861

Introduction to quaternions

 
(This page is an extract from the document quat.ps)

Abstract

We introduce quaternions, which may be viewed in a sense as `hyper-complex' numbers. We discuss their discovery and elementary properties. We then implement quaternion arithmetic in the C++ programming language.

Contents


Introduction

Quaternions were discovered by Hamilton in the nineteenth century. It had long been appreciated that the real numbers have a geometrical interpretation as points lying on a line, and that the complex numbers have a similar geometrical interpretation as points lying in a plane.

As Hamilton pointed out in a paper in 1833, the addition symbol used in the Cartesian representation of a complex number

a+ib

is somewhat misleading, since a real and purely imaginary number cannot be directly added together arithmetically.

A more suitable representation might be as an ordered pair of real numbers

(a,b)

together with a set of manipulation rules that define how to perform operations like addition and multiplication of these pairs.

Extending the Complex Numbers

It seems natural, then, to speculate whether there might be some form of extended number system whose numbers may be interpreted as points in three-dimensional space, with a corresponding representation as number triples.

The simplest such extension would seem to be numbers of the form

a+ib+jc = (a,b,c),

where i and j are distinct, independent square roots of -1. Hamilton attempted to define operations on these triples that were analogous to those on complex numbers. Addition and subtraction are naturally implemented as component-wise operations on the three real numbers. Multiplication, however, presented a problem.

For complex numbers, the effect of multiplication is most easily appreciated when they are represented in polar form, by a length r (the 'modulus') and an angle &theta (the 'argument') which define a point in the plane. If z=a+ib, then we have

r = SQRT(a2+b2), &theta = TAN-1(b/a),

and so

z = (r COS(&theta), r SIN(&theta)).

Multiplication of two complex numbers z1, z2 then acts geometrically as a scaling and a rotation about the origin, giving the resulting point

z1z2 = (r1r2 COS(θ12), r1r2 SIN(θ12)),

which has modulus r1r2 and argument θ12.

In three dimensions we need two parameters to specify the direction of the axis for a rotation, a third to specify the angle of rotation, and yet another to determine a scaling for the length. Thus, we would need to specify four parameters in all, whereas the ordered triples have only three.

Breaking Commutativity

The solution to this problem can be found by attempting to extend another operation from the complex numbers, namely that of conjugation. The conjugate of a complex number z=a+ib is given by z*=a-ib. When a complex number is multiplied by its conjugate the result is always a real number,

zz* = a2+b2 = (SQRT(a2+b2))2

which is the square of the modulus of the number.

A natural extension of this operation to number triples is to write

z = a+ib+jc, z* = a-ib-jc.

This gives

zz* = a2+b2+c2 - 2ijbc,

which seems to have an extra product term, -2ijbc. In order to get rid of this term, we might attempt to put ij=0, but this would result in the contradiction that

ij.ij = i2.j2 = (-1)(-1) = 1.

Hamilton finally resolved this problem by recognising that the product term is more properly regarded as two terms, -ijbc and -jibc. Now, if one breaks the commutative law of multiplication and assumes that ij=-ji, then the product term vanishes, but it turns out that we are still left with a consistent number system in which quadruples of numbers (rather than triples) are the natural objects.

The fourth number forming each quadruple arises from the realisation that we can use the associative law of multiplication to find out what the value of ij is:

ij.ij = i(ji)j = -i(ij)j = -(i2)(j2) = -(-1)(-1) = -1.

In other words, ij is yet another root of -1, independent to both i and j. If we call this root k, then the extension to quadruples of numbers is straightforward:

a+ib+jc+kd = (a,b,c,d).

It is then easy to see that the following relationships hold:

ij=k, jk=i, ki=j, ji=-k, kj=-i, ik=-j, i2 = j2 = k2 = ijk = -1.

Hamilton called these extended numbers quaternions. We now go on to define the fundamental operations on quaternions in more detail.

Fundamental properties

We now discuss the elementary properties of quaternions, and the operations of quaternion arithmetic.

Addition and subtraction

Addition and subtraction of quaternions proceed component-wise:

q = ( a, b, c, d ) = a +ib +jc +kd,

p = ( x, y, z, w ) = x +iy +jz +kw,

q+p = (a+x,b+y,c+z,d+w) = (a+x) +i(b+y) +j(c+z) +k(d+w),

q-p = (a-x,b-y,c-z,d-w) = (a-x) +i(b-y) +j(c-z) +k(d-w).

Multiplication by a real number

Similarly, multiplication by a real number x has the effect of scaling each component:

q = ( a, b, c, d) = a +ib +jc +kd,

xq = qx = (xa,xb,xc,xd) = xa +i(xb) +j(xc) +k(xd).

Alternative representation

In addition to the Cartesian and quadruple representations

q = (a,b,c,d) = a+ib+jc+kd,

there is an alternative way to represent a quaternion. We separate the real part a from the purely imaginary (or pure) part ib+jc+kd.

It turns out that it is natural to represent the pure part by the vector (b,c,d), since (as we shall see) i,j, and k act like orthogonal unit vectors.

We put

q = (a,v), where v=(b,c,d),

then

q+p = (a,v) + (x,u) = (a+x,v+u),

where '+' represents the usual operations of real, respectively vector, addition.

Conjugation and Absolute Value

The conjugate of q = ( a, b, c, d ) = a+ib+jc+kd is given by

q* = ( a,-b,-c,-d ) = a-ib-jc-kd.

Or, in the alternative representation, if q = (a,v) then

q* = (a,-v).

The absolute value is given by extending Pythagoras's theorem to four dimensions, and is equal to the square root of the product of a number and its conjugate:

|q| = SQRT(a2+b2+c2+d2) = SQRT(qq*).

Multiplication

For q = (a,b,c,d), p = (x,y,z,w) then

qp = (a+ib+jc+kd)(x+iy+jz+kw)                                                                        

= a(x+iy+jz+kw) + ib(x+iy+jz+kw) + jc(x+iy+jz+kw) + kd(x+iy+jz+kw)       

= ax+iay+jaz+kaw + ibx -by+kbz-jbw + jcx-kcy -cz+icw + kdx+jdy-idz -dw

= ( ax-by-cz-dw, ay+bx+cw-dz, az-bw+cx+dy, aw+bz-cy+dx ) .                

This can be re-written much more conveniently using the alternative representation of real number and 3-vector as follows. For q = (a,v), p = (x,u),

qp = ( ax-v.u, au+xv + vXu)

(where X is the vector cross-product). With this representation, it becomes obvious that quaternion multiplication is not commutative, since the cross-product of the vectors is not commutative.

Squaring

Note that the above rule for multiplication means that we have

q2 = (a2 - v.v, 2av)

because the cross-product of any vector with itself is zero.

Inverse and division

Recall that

qq* = q*q = |q|2

and thus

(qq*)/(|q|2) = (q*q)/(|q|2) = 1

giving the (both left and right) inverse of q to be q-1=q*/(|q|2).

We can use the inverse to define division. However, one has to be careful what is meant by division. We could define either

q/p = qp-1  or  q/p = p-1q.

Real and complex subspaces

Quaternions of the form

(a,0,0,0) = a

are just real numbers. Similarly, quaternions of any of the three following forms

(a,b,0,0) = a+ib,

(a,0,c,0) = a+jc,

(a,0,0,d) = a+kd,

are just equivalent complex numbers, and are closed under the operations of addition and multiplication.

Pure quaternions (q=ib+jc+kd), however, are not closed since the dot product of the vector parts contributes to the real part of a product.

C++ Implementation

[The C++ implementation can be found in the source files.]

Back to:     Quaternionic fractals     Gallery home     Home page
     
  webmaster