Function Repository Resource:

# Quaternion

Represent a quaternion object

Contributed by: Wolfram Staff
 ResourceFunction["Quaternion"][a,b,c,d] returns the quaternion number a+bⅈ+cⅉ+d𝕜.

## Details and Options

Quaternions have the form a+b+c+d𝕜 where a, b, c and d are real numbers.
The symbols , and 𝕜 are multiplied according to the rules 2=2=𝕜2=ⅈ ⅉ 𝕜=-1.
Quaternions are an extension of the complex numbers and work much the same except that their multiplication is not commutative. For instance, ⅈⅉ=-ⅉⅈ.
Because of the similarities between quaternions and complex numbers, this function imitates the Wolfram Languages treatment of complex numbers in many ways.
To provide a clear distinction between quaternions and complex numbers all quaternions should be entered using the form ResourceFunction["Quaternion"][a,b,c,d] where a, b, c and d are real numbers.
Only limited support is offered to the symbolic form a+Ib+J c+Kd.

## Examples

### Basic Examples

Get the quaternion 1+2ⅈ+3ⅉ+4𝕜:

 In[1]:=
 Out[1]=

 In[2]:=
 Out[2]=

Use NonCommutativeMultiply (**) to multiply quaternions:

 In[3]:=
 Out[3]=

This multiplication is noncommutative:

 In[4]:=
 Out[4]=

### Properties and Relations

In the conjugate of a quaternion, all the signs of the nonreal components are reversed:

 In[5]:=
 Out[5]=

The sign of a quaternion is defined in the same way as the sign of a complex number. It is the “direction” of the quaternion:

 In[6]:=
 Out[6]=

Get the standard Euclidean length:

 In[7]:=
 Out[7]=

The exponential of a quaternion can be quite complicated:

 In[8]:=
 Out[8]=

Just as with complex numbers, it is important to beware of branch cuts:

 In[9]:=
 Out[9]=

A four‐dimensional analog of de Moivre’s theorem is used for calculating powers of quaternions:

 In[10]:=
 Out[10]=

Round for quaternions returns a Quaternion in which either all components are integers or all components are odd multiples of :

 In[11]:=
 Out[11]=

A quaternion is even if its norm is even:

 In[12]:=
 Out[12]=
 In[13]:=
 Out[13]=

Just as with complex numbers, the quaternion Mod works:

 In[14]:=
 Out[14]=

You can specify a quaternion as the modulus:

 In[15]:=
 Out[15]=