The **quaternions** are a four-dimensional extension of the two-dimensional complex numbers. They form a non-associative normed division algebra over the real numbers.

# Motivation

Sir William Rowan Hamilton was attempting to extend the complex numbers into 3 dimensions, recognizing that complex numbers could represent a 2D plane.

# Type

The type of Quaternions is usually represented as after Hamilton. It forms an Lie Algebra over the real numbers.

# Representation

It is typically represented as a linear combination of unit vectors and a scalar, similar to the complex numbers:

Where, for rectangular coordinates:

- may represent the direction of the x-axis
- may represent the direction of the y-axis
- may represent the direction of the z-axis

However, if using rectangular coordinates, the axes may be chose at random, such that they follow the right-hand rule

# Injection from real numbers

There is a monomorphism from the real numbers to the quaternions, which maintains value, and the operations of the real numbers by setting the scalar quantity to the value of the real number, and leaving the vector quantities 0. Likewise, only for quaternions where the vector quantities is 0 can a quaternion be converted to a real number.

Other conversions exist, but do not maintain value.

# Addition

The addition of Quaternions is similar to that of a 4-vector. First, define two quaternions where:

## Example

## Identities associated with addition

### Commutativity

Knowing that each individual element of A and B are real numbers: (e.g. ) due to the properties of addition on the real numbers.

### Associativity

Again, knowing that each individual element of A and B are real numbers, the properties of addition on the real numbers imply that addition of quaternions is also associative.

### Additive Identity

The zero quaternion, represented as

### Additive Inverse

Forall there is a such that:

# Subtraction

We define subtraction using the additive inverse:

# Multiplication

The realization was that commutativity would need to be dropped before a multiplication was possible to be defined. As complex numbers are represented with a scalar-part and a vector-part, one can be represented as a linear combination:

# Examples of Code Implementation

Real numbers are represented as either 32-bit floating-point, 64-bit floating point, or other decimal representations. Below are some examples of quaternions implemented over float-point numbers:

- C# - MathNet Spatial, GitHub
- Haskell - Linear, Hackage

# Extensions

There are several extensions that have quaternions embedded into them:

- Octonions add another basis, lose associativity, but remain a division algebra. Complex numbers, quaternions, and octonions are part of the Cayley-Dickson construction
- Clifford Algebras maintain associativity, but are no longer a division algebra
- Matrix Matrices represent quaternions, and can also be used to represent even more structures