## FANDOM

1,025 Pages

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 $\mathbb{H}$ 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:

$a + b\boldsymbol{\hat{\imath}} + c\boldsymbol{\hat{\jmath}} + d\boldsymbol{\hat{k}}$

Where, for rectangular coordinates:

• $\boldsymbol{\hat{\imath}}$ may represent the direction of the x-axis
• $\boldsymbol{\hat{\jmath}}$ may represent the direction of the y-axis
• $\boldsymbol{\hat{k}}$ 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.

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

$A, B : \mathbb{H}$

$A := a_0 + a_1 \boldsymbol{\hat{\imath}} + a_2 \boldsymbol{\hat{\jmath}} + a_3 \boldsymbol{\hat{k}}$

$B := b_0 + b_1 \boldsymbol{\hat{\imath}} + b_2 \boldsymbol{\hat{\jmath}} + b_3 \boldsymbol{\hat{k}}$

$A + B := (a_0 + b_0) + (a_1 + b_1)\boldsymbol{\hat{\imath}} + (a_2 + b_2)\boldsymbol{\hat{\jmath}} + (a_3 + b_3)\boldsymbol{\hat{k}}$

## Example

$A := 5 - 3 \boldsymbol{\hat{\imath}} + \boldsymbol{\hat{\jmath}} -2 \boldsymbol{\hat{k}}$

$B := -3 + 6 \boldsymbol{\hat{\imath}} + 2 \boldsymbol{\hat{\jmath}} + \boldsymbol{\hat{k}}$

$A + B = 2 + 3 \boldsymbol{\hat{\imath}} + 3 \boldsymbol{\hat{\jmath}} - \boldsymbol{\hat{k}}$

### Commutativity

$A + B = B + A$

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

### Associativity

$A + (B + C) = (A + B) + C = A + B + C$

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.

$0 + A = A + 0$

The zero quaternion, represented as $0 + 0 \boldsymbol{\hat{\imath}} + 0 \boldsymbol{\hat{\jmath}} + 0 \boldsymbol{\hat{k}}$

Forall $A \in \mathbb{H}$ there is a $-C$ such that: $A + -A = 0$

$-A := -a_0 - a_1 \boldsymbol{\hat{\imath}} - a_2 \boldsymbol{\hat{\jmath}} - a_3 \boldsymbol{\hat{k}}$

# Subtraction

We define subtraction using the additive inverse:

$A - B := A + -B$

# 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:

$a+b\vec{x}+c\vec{y}+d\vec{z}$

# 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:

# Extensions

There are several extensions that have quaternions embedded into them: