Computing the roots of unity for complex numbers and quaternions.

William Overington

Copyright 2001 William Overington

It sometimes happens that one might like to compute the roots of unity of either a complex number or a quaternion, so as to obtain a number of values that contain non-real parts. The method of finding a root by taking the logarithm using zn or un as appropriate, dividing by the power of the root and then using ze or ue as appropriate will not work for unity as it will for other values that are not totally real and positive. This is because zn and ue return a zero angle for values of the input argument that are real and positive. In order to return a value of 2 * pi for an input argument that is real and positive, the commands zf and uf are provided. The f may be thought of as meaning "first" whereas the n may be thought of as "natural" as in natural logarithm, though I might mention that I did have it in mind that it might well refer to John Napier the inventor of logarithms.

The zf and uf commands only produce a different result from zn and un along the positive real axis.

In the underlying Java implementation that I have used for implementing the 1456 engine it is quite straightforward.

I need to compute the angle theta. The Java returns a value that is either positive or negative with zero in the middle of the range. I need a non-negative value. For zn and un I use the following.


if (theta < 0.0)
  {
    theta=theta + 8.0*Math.atan(1.0);
  }

For zf and uf I use the following.


if (theta <= 0.0)
  {
    theta=theta + 8.0*Math.atan(1.0);
  }

The 8.0*Math.atan(1.0) is how I compute 2 * pi in the software.

1456 object code

Copyright 2001 William Overington