In the Quaternion package tutorial, it says:
A four-dimensional analog of de Moivre’s theorem is used for calculating powers of quaternions
In[15]:=
Quaternion[1, 2, 0, 1]^2.5
Out[15]= Quaternion[-9.0604, 2.20741, 0., 1.1037]
That’s fine, but if I take the 2.5 root again, I get
In[16]:= Quaternion[-9.0604, 2.20741, 0., 1.1037]^2.5
Out[16]:=Quaternion[
6.51112*10^-14 + 212.669 I, -4.56519*10^-14 -
149.11 I, -1.39769*10^-30 - 4.56519*10^-15 I, -2.2826*10^-14 -
74.5552 I]
The quaternion components are now complex (e.g. the first component above is 6.51112*10^-14 + 212.669 I). This seems to occur when the real part of the quaternion is negative.
This seems like a bug. The output ought to be another well formed quaternion.
I thought I could simplify this by going:
Quaternion[ 6.51112*10^-14 + 212.669 I, -4.56519*10^-14 - 149.11 I, -1.39769*10^-30 - 4.56519*10^-15 I, -2.2826*10^-14 - 74.5552 I]
= (6.51112*10^-14 + 212.669 I) + (-4.56519*10^-14 - 149.11 I)*I + (-1.39769*10^-30 - 4.56519*10^-15 I)*J + (-2.2826*10^-14 - 74.5552 I)*K
= 6.51112*10^-14 + 212.669 I -4.56519*10^-14 I - 149.11 I^2 - 1.39769*10^-30 J - 4.56519*10^-15 IJ - 2.2826*10^-14 K - 74.5552 IK
= 6.51112*10^-14 + 212.669 I -4.56519*10^-14 I + 149.11 - 1.39769*10^-30 J - 4.56519*10^-15 K - 2.2826*10^-14 K + 74.5552 J
= (6.51112*10^-14 + 149.11) + (212.669 - 4.56519*10^-14) I + (74.5552 - 1.39769*10^-30) J - (4.56519*10^-15 + 2.2826*10^-14) K
= Quaternion[149.11, 212.669, 74.5552, -2.73911*10^-14]
But this is incorrect as Quaternion[149.11, 212.669, 74.5552, -2.73911*10^-14]^0.4 <> Quaternion[-9.0604, 2.20741, 0., 1.1037]
What is going on here? How can I either avoid getting complex components when I take quaternion roots or eliminate the complex components when they appear?