# 9.64 QuaternionΒΆ

The domain constructor Quaternion implements quaternions over commutative rings. For information on related topics see ComplexXmpPage and OctonionXmpPage . You can also issue the system command )show Quaternion to display the full list of operations defined by Quaternion.

The basic operation for creating quaternions is quaternquaternQuaternion. This is a quaternion over the rational numbers.

q := quatern(2/11,-8,3/4,1)


 211-8i+34j+k

Type: Quaternion Fraction Integer

The four arguments are the real part, the i imaginary part, the j imaginary part, and the k imaginary part, respectively.

[real q, imagI q, imagJ q, imagK q]


 [211,-8,34,1]

Type: List Fraction Integer

Because q is over the rationals (and nonzero), you can invert it.

inv q


 352126993+15488126993i-48442331j-1936126993k

Type: Quaternion Fraction Integer

The usual arithmetic (ring) operations are available

q^6


 -20294907093193457256313856-482516908511288408i+14475507255341229056j+4825169085110307264k

Type: Quaternion Fraction Integer

r := quatern(-2,3,23/9,-89); q + r


 -2011-5i+11936j-88k

Type: Quaternion Fraction Integer

In general, multiplication is not commutative.

q * r - r * q


 -249518i-1418j-81718k

Type: Quaternion Fraction Integer

There are no predefined constants for the imaginary i, j, and k parts, but you can easily define them.

i:=quatern(0,1,0,0); j:=quatern(0,0,1,0); k:=quatern(0,0,0,1)


 k

Type: Quaternion Integer

These satisfy the normal identities.

[i*i, j*j, k*k, i*j, j*k, k*i, q*i]


 [-1,-1,-1,k,i,j,8+211i+j-34k]

Type: List Quaternion Fraction Integer

The norm is the quaternion times its conjugate.

norm q


 1269931936

Type: Fraction Integer

conjugate q


 211+8i-34j-k

Type: Quaternion Fraction Integer

q * %


 1269931936

Type: Quaternion Fraction Integer