# Quinternions

Attributed to Russell Walsmith
Written by Paul Bourke
August 2005

The images shown here are based upon quinternion arithmetic and are created in a similar way to the Mandelbrot set. That is, a function is iterated with some dependency on a position on the complex plane. The outcome of the series (infinity, zero, or otherwise) determines the state of that position and ultimately how it is represented graphically. Generally the distinction is made between the series tending to zero (inside the set) and other behaviour (outside the set).

The difference here is the function being iterated is not in the complex plane but rather in five dimensions. To determine whether the position in 5D is inside or outside the set, a test is made whether the magnitude of the series (a 5 dimensional vector) tends to zero. The result, as shown in the images on the right is a Mandelbrot like outline, extruded in 3D space over some limited range. In these image the first three dimensions are mapped to 3D Cartesian coordinates and the last two dimensions are fixed at one value, a point in the plane of the last two dimensions.

The series in five dimensions is given by
xn+1 = a + x0
yn+1 = b + y0
zn+1 = c + z0
un+1 = d + u0
vn+1 = e + v0
where
a = xn2 + 2 (ynvn + znun)
b = un2 + 2 (xnyn + znvn)
c = yn2 + 2 (xnzn + unvn)
d = vn2 + 2 (xnun + ynzn)
e = zn2 + 2 (xnvn + ynun)
where (x0,y0,z0,u0,v0) is the point in question.

C style code to evaluate the quinternion

```int Eval(double *q,int nmax)
{
int i,n=0;
double a[5],q1[5] = {0,0,0,0,0};
double zz = 0;

while (zz < 100 && n < nmax) {
a[0] = q1[0]*q1[0]+2*(q1[1]*q1[4]+q1[2]*q1[3]);
a[1] = q1[3]*q1[3]+2*(q1[0]*q1[1]+q1[2]*q1[4]);
a[2] = q1[1]*q1[1]+2*(q1[0]*q1[2]+q1[3]*q1[4]);
a[3] = q1[4]*q1[4]+2*(q1[0]*q1[3]+q1[1]*q1[2]);
a[4] = q1[2]*q1[2]+2*(q1[0]*q1[4]+q1[1]*q1[3]);
zz = 0;
for (i=0;i<<5;i++) {
q1[i] = a[i] + q[i];
zz += q1[i] * q1[i];
}
n++;
}

return(n);
}
```