### Basic Examples

Basic Examples

In[]:=

Get the quaternion :

1+2i+3j+4k

[1,2,3,4]

In[]:=

Out[]=

Add two quaternions:

[1,2,3,4]+

[2,3,4,5]

In[]:=

Out[]=

Use () to multiply quaternions:

**

[2,0,-6,3]**

[1,3,-2,2]

In[]:=

Out[]=

This multiplication is noncommutative:

[1,3,-2,2]**

[2,0,-6,3]

In[]:=

Out[]=

### Properties and Relations

Properties and Relations

In[]:=

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

q=Conjugate

[4,-3,1,-2]

In[]:=

Out[]=

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:

Sign[q]

In[]:=

Out[]=

Get the standard Euclidean length:

Abs[q]

In[]:=

30

Out[]=

The exponential of a quaternion can be quite complicated:

[2,3,1,6]

In[]:=

Out[]=

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

SinCos

[.3,.1,.5,.5]

In[]:=

Out[]=

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

[1,2,0,1]

2.5

In[]:=

Out[]=

Round for quaternions returns a in which either all components are integers, or all components are odd multiples of 1/2:

Quaternion

Round,3,4,

1

2

5

2

In[]:=

Out[]=

A quaternion is even if its norm is even:

EvenQ

[2,3,4,5]

In[]:=

True

Out[]=

EvenQNorm

[2,3,4,5]

In[]:=

True

Out[]=

Just as with complex numbers, the quaternion works:

Mod

[-3,4,1,2],3

In[]:=

Out[]=

You can specify a quaternion as the modulus:

Mod

[1,3,4,1],

[3,4,1,2]

In[]:=

Out[]=