Dom::Quaternion -- the skew
field of quaternions
IntroductionThe domain Dom::Quaternion represents the skew field of
quaternions.
Creating
ElementsDom::Quaternion(listi)
Dom::Quaternion(ex)
Dom::Quaternion(M)
Parameterslisti |
- | a list containing four elements of type Type::Real |
ex |
- | arithmetical expression |
M |
- | A matrix of type
Dom::Matrix(Dom::Complex). It has to be of a special form
described in the Details section. |
Cat::SkewField
Related
Domains
Details+- -+ | a+b*I, -c-d*I | | c-d*I, a-b*I | +- -+
where a,b,c,d are real numbers. Another usual notation is a+bi+cj+dk; the subfield of those quaternions for which c=d=0 is isomorphic to the field of complex numbers.
Dom::Quaternion regards these fields as
being identical, and it allows both notations that have been mentioned,
as well as simply [a,b,c,d].ex, the identifiers i, j, and
k are understood in the way mentioned above; I, J, and K
may be used alternatively, and you may also mix small and capital
letters. Every subexpression of ex not containing one of
these must be real and constant.
Be sure that you have not assigned a value to one of the identifiers mentioned.
Dom::Quaternion has the domain Dom::BaseDomain as its super domain,
i.e., it inherits each method which is defined by
Dom::BaseDomain and not re-implemented by
Dom::Quaternion. Methods described below are
re-implemented by Dom::Quaternion.the characteristic of this domain is 0
the unit element; it equals
Dom::Quaternion([1,0,0,0]).
the number of quaternions is infinity.
The zero element; it equals
Dom::Quaternion([0,0,0,0]).
_mult(dom x , dom
y...)_mult._plus(dom x , dom
y...)_plus._power(dom x, rational n)_power.n.Im(dom x)Im.Re(dom x)Re.Type::Real.abs(dom x)abs.Type::Real.conjugate(dom x)conjugate.intpower(dom x, DOM_INT)n.Dom::Quaternion is used by "_power".nthroot(dom x, DOM_INT n)n-th root of
x.Dom::Quaternion is used by "_power".norm(dom x)norm.Type::Real.random()a, b, c and d
being nonnegative numbers with at most 12 digits generated by random.scalarmult(Type::Real s, dom x)scalarprod(dom x, dom
y)sign(dom x)sign.Type::Real.convert(any x)x into an element of
Dom::Quaternion. If x is a list, it must
consist of four real numbers (type Type::Real). Constant real expressions
and the identifiersi, J, j,
K, and k can also be converted to domain
elements, as well as sums and products of them. A matrix of the type
Dom::Matrix(Dom::Complex) can be converted if and only if
it is of the special form:
+- -+ | a+b*I, -c-d*I | | c-d*I, a-b*I | +- -+
If the conversion fails, FAIL is returned.
convert_to(dom x, any
T)x to an
element of type T, or, if T is not a domain,
to the domain type of T. If the conversion fails,
FAIL is returned.T:
DOM_EXPR, DOM_LIST, Dom::Matrix(Dom::Complex).matrixform(dom x)+- -+ | a+b*I, -c-d*I | | c-d*I, a-b*I | +- -+
Dom::Matrix(Dom::Complex).TeX(dom x)generate::TeX.Dom::Quaternion(x) returns a
TeX-formatted string representing x.map(dom x, function
f, any arg...)map.Dom::Quaternion(x, f) returns a copy of
x where each component co of x
has been replaced by f(co). So for the quaternion
x:=a+bi+cj+dk, Dom::Quaternion(x,
f) returns the quaternion
f(a)+f(b)i+f(c)j+f(d)k.co of x is replaced by f(co, arg...). So for
the quaternion x:=a+bi+cj+dk,
Dom::Quaternion(x, f, arg, ...) returns the
quaternion f(a, arg,...)+f(b, arg,...)i+f(c, arg,...)j+f(d,
arg,...)k.simplify(dom x)simplify.a, b, c, d of
x.
Example
1Creating some quaternions.
>> Dom::Quaternion([1,2,3,4]), Dom::Quaternion(11+12*i+13*j+14*k); M := Dom::Matrix(Dom::Complex)([[3+4*I,-6-2*I],[6-2*I,3-4*I]]): M, Dom::Quaternion(M)
3 J + 4 K + (1 + 2 I), 13 J + 14 K + (11 + 12 I)
+- -+
| 3 + 4 I, - 6 - 2 I |
| |, 6 J + 2 K + (3 + 4 I)
| 6 - 2 I, 3 - 4 I |
+- -+
Example
2Doing some standard arithmetic.
>> a:=Dom::Quaternion([1,2,3,4]): b:=Dom::Quaternion([11,2,33.3,2/3]): a*b, a+b, a^2/3, b^3;
72.96666667 J + 105.2666667 K - (95.56666667 + 107.2 I),
14 K 8 K
36.3 J + ---- + (12 + 4 I), 2 J + --- - (28/3 - 4/3 I),
3 3
- 24986.137 J - 500.222963 K - (35409.03666 + 1500.668889 I)
Example
3More mathematical operations:
>> a:=Dom::Quaternion([1,2,3,4]): b:=Dom::Quaternion([11,2,33.3,2/3]): Dom::Quaternion::nthroot(b,3); abs(a), sign(b)
1.325212827 J + 0.02653078732 K +
(2.993953193 + 0.07959236197 I)
1/2
30 , 0.9478242358 J + 0.01897546018 K +
(0.3130950929 + 0.05692638053 I)
Example
4Some miscellaneous operations.
>> a:=Dom::Quaternion([1,2,3,4]): Dom::Quaternion::matrixform(a); map(a, sqrt), map(a, _plus, 1);
+- -+
| 1 + 2 I, - 3 - 4 I |
| |
| 3 - 4 I, 1 - 2 I |
+- -+
1/2 1/2
2 K + I 2 + J 3 + 1, 4 J + 5 K + (2 + 3 I)
Super-DomainAx::canonicalRep