Quaternions

From Create52 Cookbook

Jump to: navigation, search

Contents

Motivation for this page

This page is a collection of notes that was inspired by the question "What is the layout of roots of polynomials like z^3 = 1 in the Quaternions?" and the using of the Newton-Raphson method to find such roots. (The case of roots in the complex plane is well known, see below for more details). Please see also http://create52.com/blog and this flickr set of mine. Also, many years ago I wrote a short page on the Newton-Raphson method.

See also my Simple quaternion library for Processing.

Notation

The standard way of representing a quaternion is the form:


q = a + bi + cj + dk \!

See Quaternions on wikipedia for more info and properties.

What are quaternions useful for?

  • Modelling rotations in 3D and 4D (Wikipedia) - because the representation is more compact than other ways; Gimbal lock can be avoided, etc.
  • Understanding low-dimension symmetry groups (see a fearsome book called On Quaternions and Octonions for more details)
  • scaring kids

Roots of the simple polynomial in complex numbers

In the complex plane, the polynomial z^n = 1\! has n\! roots, spaced equally on the unit circle. (Examining how Newton-Raphson method finds roots to polynomials like this reveals interesting fractal boundaries - see James Gleick's book Chaos, for example). Understanding Euler's famous equation:


e^{i \theta} = \cos \theta + i \sin \theta = \operatorname{cis}\, \theta \!

and in particular de Moivre's equation:

\left(\cos x+i\sin x\right)^n=\cos\left(nx\right)+i\sin\left(nx\right)\,

leads to a fairly straightforward understanding of why these roots are where are are.

Specifically, the solutions to

z^n = r\quad\quad (with z \in \mathbb{C}, r \in \mathbb{R})

are given by:


z = r^{1/n} \exp \left ( \frac{2k \pi}{n} \right )\quad\quad where 0 \eqslantless k < n \!  \quad\quad[1]

In words: the roots are equally spaced out on a circle of radius r^{1/n} \!, and one root is on the real line.

In the more general case of the equation:

z^n = r e^{i \theta} \! (with z \in \mathbb{C}, r \in \mathbb{R})

we have solutions at:


z = r^{1/n} \exp \left ( \frac{\theta + 2k \pi}{n} \right )\quad\quad where 0 \eqslantless k < n \!

Again, the roots are equally spaced out on a circle of radius r^{1/n} \!, but there isn't necessarily a root on the real line - they all are rotated around the origin by \frac{\theta}{n}.

(Note the use of polar coordinate form here - under multiplication and division, complex numbers in polar form retain independence in their radius and angle components. Conversely, under addition/subtraction, complex numbers in cartesian form retain independence of co-ordinate components.)

Roots of polynomials in the quaternions

Complex numbers are a subset of the quaternions (denoted \mathbb{H}), and so the roots as described above also exist in the quaternion case. However, what other roots exist in \mathbb{H}? What is their (geometrical) layout, and how many of them are there?

To give a quick initial answer: for the equation

q^n = r\! (where n > 2, q \in \mathbb{H}, r \in \mathbb{R})

there are infinitely many roots. These roots lie on a number of 2-spheres which span the i, j and k axes (i.e. have no extent in the real axis). To be exact, there are \lceil (n/2) - 1 \rceil such 2-spheres. (Plus there is the obvious root at q = 1\!.)

To understand the structure of these roots, we can look at a special subset of the quaternions, called the isomorphic complex numbers.

Isomorphic imaginary and complex numbers

This concept is well presented on the Wikipedia Quaternions page but it is presented below for completeness.

Isomorphic imaginary numbers

The fact that the quaternions anti-commute - i.e. ij = -ji, ik= -ki, jk = -kj \! - means that when you square a quaternion, some terms drop out, as follows:


\begin{align}
(a + b i + c j + d k)^2  & = & & a^2  + b^2 i^2 + c^2  j^2 + d^2 k^2 \\
 & & + & i(2ab) + j(2ac) + k(2ad) \\
 & & + & bc(ij + ji) + bd(ik + ki) + cd(jk + kj) \quad\quad  \mbox{(terms cancel out on this line)} \\
 \\
 & =  & & a^2  - b^2 - c^2 - d^2 \\
      & & + & i(2ab) + j(2ac) + k(2ad)
\end{align}

And if the quaternion has no real part, i.e. a=0 \!, things get very simple indeed:


\begin{align}
(b i + c j + d k)^2  & = - b^2 - c^2 - d^2 \\
   & = - (b^2 + c^2 + d^2)
\end{align}

Bearing in mind the equation for a sphere (and Pythagoras), we can see that the above is telling us that there are an infinite amount of quaternions, q \!, with no real part, such that q^2 = -1 \!, and they form the surface of a 2-sphere.

More formally, quaternions with this property belong to a subset of \mathbb{H}, denoted \mathbb{H}_i, and defined as:

\mathbb{H}_i = \left\{ q : a = 0 \ \mbox{and}\  \sqrt{ b^2 + c^2 + d^2 } = 1 )\right\} \,\!

Members of \mathbb{H}_i have a length of 1 and a square of -1: in this way, they are analogous to imaginary numbers, and we refer to them generally as i_r \!. Properly speaking, i_r \in \mathbb{H}_i \! is isomorphic to the imaginary unit i \!.

Simple example of isomorphic imaginary numbers:

In the realm of imaginary numbers, finding the value of \sqrt{-9} goes as follows:


\begin{align}
\sqrt{-9} & = \sqrt{9} \sqrt{-1} \\
          & = \pm 3 \sqrt{-1} \\
          & = \pm 3i
\end{align}

In the realm of the quaternions, we have exactly the same solution, but with i_r \! being defined as \sqrt{-1} (rather than plain old i\!), i.e.:



\begin{align}
\sqrt{-9} & = \sqrt{9} \sqrt{-1} \\
          & = \pm 3 \sqrt{-1} \\
          & = \pm 3i_r
\end{align}

Remember, however, that i_r \! represents any member of \mathbb{H}_i (and there are an infinite amount, in the form of all points on the unit 2-sphere spanning i, j, k). So the answer for the quaternion case is actually representing all points on a 2-sphere of radius 3 spanning i, j, k .

This 2-sphere includes on its surface\pm 3i (i.e. the answer for the complex case), as well as \pm 3j, \pm 3k.

Isomorphic complex numbers

Every member i_r \! of \mathbb{H}_i has a 'unused' real part. If we let that real part take any value, and allow scaling of the imaginary ('vector') part by any amount, we end up with an isomorphism to the complex numbers! More formally, for every i_r \in \mathbb{H}_i, there is a subset of quaternions, C_r \!, which is a plane (in quaternion space) which is isomorphic to the complex plane, defined like so:

C_r = \left\{ c_r : c_r = a_r + b_r i_r \ \mbox{and}\ a_r,b_r \in R \right\} \,\!

Each possible C_r \! forms a plane in \mathbb{H}, and every possible C_r \! contains the real axis. Any operations (e.g. negation, addition, multiplication) on, or between, members of C_r \! will have results also in C_r \! (because C_r \! is an algebraically closed field, as are the complex numbers).

The union of all possible C_r \! planes forms the entirety of the Quaternions \mathbb{H}. Conversely, any Quaternion q \! with a non-zero imaginary (vector) part belongs to one and one only C_r \!, which we can refer to as C_q \!. (Quaternions with zero imaginary part belong to every C_r \!, because every C_r \! contains the real line.)

Layout of roots of simple polynomials in quaternions

So, back to the original question.

The roots of

q^n = r\! (where n > 2, q \in \mathbb{H}, r \in \mathbb{R})

are the same as for the roots in the complex case, except that the roots are isomorphic complex numbers, not plain complex numbers.

An example: There are three roots of q^3 = 1\! in the complex plane, which are:

1, \quad (-\frac{1}{2} + \frac{\sqrt{3}}{2}i), \quad (-\frac{1}{2} - \frac{\sqrt{3}}{2}i)

In the quaternions there are roots at:

1, \quad (-\frac{1}{2} + \frac{\sqrt{3}}{2}i_r), \quad (-\frac{1}{2} - \frac{\sqrt{3}}{2}i_r)

Roots two and three above actually represent exactly the same thing (because ir concerns itself with length), so we can simplify and say that the roots are:

1, \quad (-\frac{1}{2} + \frac{\sqrt{3}}{2}i_r)

So there is a root at 1 \! and an infinite amount of roots lying on the surface of a 2-sphere in i, j, k of radius \frac{\sqrt{3}}{2} positioned at - 1/2 \! on the real axis.

The Newton-Raphson picture in quaternions (and other fractals)

The Newton-Raphson (N-R) picture in higher dimensions of the quaternions is not 'quaternionically interesting': the 2d complex plane structure (i.e. that colourful picture!) is in effect rotated, or 'swept out', in all imaginary directions i, j, k. There is no 'extra structure' in these higher dimensions. Another way of putting it is that the N-R picture is rotationally invariant in its imaginary parts. For example, if you plotted a N-R picture of an (i, j) plane slice (that passes through the origin) you will only see concentric circles - i.e. a rotationally invariant picture. The same goes for (j, k), or (i, k) slices, or any planar slices that pass through origin and have zero span (extension) in the real axis.

To understand why the above is so, consider the N-R iteration equation: each value iteration is based entirely on the previous iterations value, and the equation is a simple algebraic closed form (oof), hence the value varies only within one isomorphic complex plane (which is identified by the very first 'guess' value for the iteration). And if the value varies only within one isomorphic complex plane, then the structure cannot be any more complicated than that found in the complex plane case.

For similar reasons to those detailed above, the Mandelbrot set is also 'quaternionically uninteresting' - i.e. the iteration which defines the M-set is a closed form function concerning only the previous iteration value and the first iteration value - hence the iteration remains in only one isomorphic complex plane.

Julia sets, however, are 'interesting' - pictures and movies of their 3d, 4d structure litter the internet like rude jewels (e.g. 1, 2) - see also my ancient movies from 1997. Julia sets are interesting because their iteration features a single constant complex parameter that is unchanging over the whole 'picture' - hence the iteration will generally not stay in a single isomorphic complex plane.

An alternative representation of Quaternions

Another way of writing a quaternion is in the form of a pair: the scalar (real) part, and the 'vector' (imaginary) part:


q = (m, \mathbf{u})

where m = a\! and \mathbf{u} = (bi, cj, dk).

This representation is useful as it demonstrates the result of multiplication of quaternions quite succinctly: given the two quaternions


\begin{align}
q_1 & = (m, \mathbf{u}) \\
q_2 & = (n, \mathbf{v})
\end{align}

we then have the product as:


q_1 q_2 = (mn - \mathbf{u} . \mathbf{v}, m \mathbf{v} + n \mathbf{u} + \mathbf{u} \times \mathbf{v})

And for squaring a quaternion, we have:


\begin{align}
q_1^2 & = (m^2 - \mathbf{u} . \mathbf{u}, 2 m \mathbf{u}) \\
      & = (m^2 - \|\mathbf{u}\|^2 , 2 m \mathbf{u})  
\end{align}
Personal tools