Accelerating the pace of engineering and science

# Dom::Quaternion

Skew field of quaternions

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```Dom::Quaternion(listi)
Dom::Quaternion(ex)
Dom::Quaternion(M)
```

## Description

Domain Dom::Quaternion represents the skew field of quaternions.

Quaternions are usually defined to be complex 2 ×2 matrices of the special form

,

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.

The domain 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].

If you enter a quaternion as an arithmetical expression 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.

 Note:   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.

Dom::BaseDomain

Ax::canonicalRep

Cat::SkewField

## Examples

### Example 1

Creating 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)```

### Example 2

Doing 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;```

### Example 3

More 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)```

### Example 4

Some miscellaneous operations.

```a:=Dom::Quaternion([1,2,3,4]):
Dom::Quaternion::matrixform(a);
map(a, sqrt), map(a, _plus, 1);```

## Parameters

 listi 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.

## Entries

 "characteristic" the characteristic of this domain is 0 "one" the unit element; it equals Dom::Quaternion([1,0,0,0]). "size" the number of quaternions is infinity. "zero" The zero element; it equals Dom::Quaternion([0,0,0,0]).

expand all

## Mathematical Methods

_mult(x, y, …)

_plus(x, y, …)

_power(x, n)

### Im — Return the imaginary (vectorial) part of a quaternion.

Im(x)

The result is still a quaternion.

### Re — Return the real part of a quaternion.

Re(x)

The result is of type Type::Real.

### abs — Absolute value of a quaternion

abs(x)

The result is of type Type::Real.

conjugate(x)

### intpower — Multiplie quaternions

intpower(x, {DOM_INT})

The implementation uses "repeated squaring".

Dom::Quaternion is used by "_power".

### nthroot — N-th root of a quaternion

nthroot(x, n)

The implementation uses "repeated squaring".

Dom::Quaternion is used by "_power".

### norm — Norm of a quaternion

norm(x)

The result is of type Type::Real.

random()

scalarmult(s, x)

scalarprod(x, y)

### sign — Sign of a quaternion

sign(x)

The result is of type Type::Real.

## Conversion Methods

convert(x)

### convert_to — Conversion to other domains

convert_to(x, T)

It currently handles the following domains for T: DOM_EXPR, DOM_LIST, Dom::Matrix(Dom::Complex).

### expr — Convert a quaternion to an object of a kernel domain

expr(x)

The result is an object of the kernel domain DOM_EXPR.

This method overloads the function expr for quaternions, i.e., you may use it in the form expr(x).

### matrixform — Convert a quaternion to a 2 x 2 matrix with complex entries.

matrixform(x)

The result is an object of the domain Dom::Matrix(Dom::Complex).

## Technical Methods

TeX(x)

### map — Apply a function to all components of a quaternion

map(x, f, arg, …)

If optional arguments are present, then each component 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(x)