The domain constructor Quaternion implements quaternions over commutative rings.
The basic operation for creating quaternions is quatern. This is a quaternion over the rational numbers.
q := quatern(2/11,-8,3/4,1)
2 3
-- - 8i + - j + k
11 4
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]
2 3
[--,- 8,-,1]
11 4
Type: List Fraction Integer
Because q is over the rationals (and nonzero), you can invert it.
inv q
352 15488 484 1936
------ + ------ i - ----- j - ------ k
126993 126993 42331 126993
Type: Quaternion Fraction Integer
The usual arithmetic (ring) operations are available
q^6
2029490709319345 48251690851 144755072553 48251690851
- ---------------- - ----------- i + ------------ j + ----------- k
7256313856 1288408 41229056 10307264
Type: Quaternion Fraction Integer
r := quatern(-2,3,23/9,-89); q + r
20 119
- -- - 5i + --- j - 88k
11 36
Type: Quaternion Fraction Integer
In general, multiplication is not commutative.
q * r - r * q
2495 817
- ---- i - 1418j - --- k
18 18
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)
i
Type: Quaternion Integer
j:=quatern(0,0,1,0)
j
Type: Quaternion Integer
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]
2 3
[- 1,- 1,- 1,k,i,j,8 + -- i + j - - k]
11 4
Type: List Quaternion Fraction Integer
The norm is the quaternion times its conjugate.
norm q
126993
------
1936
Type: Fraction Integer
conjugate q
2 3
-- + 8i - - j - k
11 4
Type: Quaternion Fraction Integer
q * %
126993
------
1936
Type: Quaternion Fraction Integer
See Also: