Quaternion Definition and Basic Algebra
A quaternion is a four component number that extends the real and complex numbers while
preserving addition, multiplication, and division by any nonzero element. Quaternions are
especially important in physics and engineering because their multiplication law naturally encodes
the ordered geometry of three dimensional space. Unit quaternions will later be used to represent
frame orientation, rigid body attitude, and angular kinematics.
This entry develops only the algebra needed before those applications. The main goals are to define
a quaternion precisely, derive Hamilton’s multiplication table, derive the component formula
for a product, and identify which familiar algebraic rules remain valid and which do
not.
The convention issues that arise in engineering applications are treated in the preceding
PhysicsLibrary article Quaternions for Physics and Engineering: Orientation, Notation, and
Conventions. The present article uses Hamilton multiplication throughout. The later
PhysicsLibrary attitude articles use passive coordinate transformations, but that application
convention does not alter the algebra developed here.
1 Definition
The set of Hamilton quaternions is denoted by ℍ. A quaternion is an expression
where
The four basis elements are
The same quaternion may therefore be represented as the ordered four tuple
In the scalar first column notation used in this series,
Equation (2) is a representation of the four real coefficients. It does not mean that quaternion
multiplication is ordinary four dimensional vector multiplication. Quaternion multiplication is
defined by the special products of i, j, and k developed below.
Scalar and vector parts
It is useful to separate a quaternion into a real scalar part and a three component vector
part:
where
PhysicsLibrary uses
when a named scalar or vector part is useful.
A quaternion with zero vector part,
is simply a real number embedded in ℍ. A quaternion with zero scalar part,
is called a pure quaternion. Ordinary three dimensional vectors will later be embedded into
quaternion calculations in this form.
Equality
Two quaternions are equal if and only if all four corresponding real coefficients are
equal:
Thus one quaternion equation generally represents four scalar equations.
2 Addition, subtraction, and multiplication by a real scalar
Let
and
Addition is componentwise:
Subtraction is defined similarly. For a real scalar a,
Real scalars commute with every quaternion:
With addition and real scalar multiplication, ℍ is a four dimensional real vector space. Quaternion
multiplication gives this vector space additional algebraic structure.
3 Hamilton’s multiplication law
Hamilton’s fundamental relation is
Together with associativity, this determines the standard Hamilton multiplication table.
The squares are
To obtain ij, begin with
Multiply on the right by −k. Since
associativity gives
The cyclic positive products are therefore
Reversing the order changes the sign:
This failure of the commutative law is a defining feature of quaternion multiplication. Hamilton
multiplication remains associative.
Multiplication table
The complete basis table is
where the entry in a row is the row factor multiplied on the left by the column factor on the
right.
A useful mnemonic for the positive products is
Following the arrows gives a positive product. Going against the arrows gives the negative of the
remaining basis element.
The mnemonic is convenient, but the multiplication table is the actual rule to use when checking
an unfamiliar convention. Some engineering literature uses a flipped multiplication in which the
signs of these cross like products are reversed. PhysicsLibrary uses Hamilton multiplication unless
an article explicitly states otherwise.
4 Deriving the product of two general quaternions
Let
and
Quaternion multiplication is distributive, so expand as in ordinary algebra but do not reorder
quaternion factors:
Using Hamilton’s basis products and collecting the coefficients of 1,i,j,k gives
In scalar first component form,
This component formula is often implemented directly in software. It should never be copied
into a program without also documenting the component ordering and multiplication
convention.
The next PhysicsLibrary quaternion article develops the same result in compact scalar vector form.
That form exposes the ordinary dot and cross products hidden inside this component
expression.
5 Why quaternion multiplication is not commutative
Using the basis products,
Therefore
One counterexample is enough to show that multiplication in ℍ is not commutative.
This is not a defect. Ordered spatial transformations do not generally commute, so a
noncommutative algebra is naturally suited to later orientation applications.
For two general quaternions p and q, one should therefore expect
The difference
is called the commutator. When [p,q] = 0, those two particular quaternions commute even though
the algebra as a whole is noncommutative.
6 Associativity and distributivity still hold
Although commutativity fails, two other familiar multiplication laws remain valid.
Quaternion multiplication is associative:
It is distributive over addition:
and
Associativity means that an unparenthesized product such as pqr has a unique value. What cannot
be done is to exchange the order of the factors.
For example,
while
Thus associativity works. But interchanging i and j gives
which is different.
7 Identity, zero, and division
The real number 1 is the multiplicative identity:
The zero quaternion
is the additive identity:
It also satisfies
Every nonzero Hamilton quaternion has a multiplicative inverse. Therefore ℍ is a noncommutative
division algebra over the real numbers.
The conjugate, norm, and explicit inverse formula are developed in later PhysicsLibrary entries so
that the present article can concentrate on the fundamental product.
8 Important subalgebras
The real numbers occur inside the quaternions as
They commute with all quaternions.
If only one imaginary basis direction is used, for example
then multiplication behaves exactly like ordinary complex number multiplication because i2 = −1
and there are no j or k factors to introduce noncommutativity. Thus
is a copy of the complex numbers inside ℍ.
The same is true using j, k, or any unit pure quaternion. This observation becomes useful in later
orientation problems because a fixed spatial axis behaves algebraically like an imaginary
unit.
9 Worked examples
Example 1: multiplying basis expressions
Compute
Distribute without changing factor order:
Reverse the two factors:
The products differ only in the sign of the k term, but that is enough to demonstrate
noncommutativity.
Example 2: a numerical product
Let
Using the general component formula,
Reversing the order gives
Hence pq≠qp.
Example 3: associativity does not imply commutativity
For the basis elements,
The product is associative. But
so it is not commutative.
Example 4: a pure quaternion can square to a real number
Consider
Then
Expanding without reordering gives diagonal square terms and reversed mixed pairs. The mixed
pairs cancel:
with analogous cancellation for the other pairs. Therefore
Thus a unit pure quaternion in an arbitrary three dimensional direction can behave algebraically
like an imaginary unit.
10 Common pitfalls
- Reordering factors as if they were real variables. In general pq≠qp. Do not sort
terms alphabetically during an expansion.
- Confusing associativity with commutativity. Parentheses may be moved
according to (pq)r = p(qr), but factors may not be exchanged.
- Forgetting the negative squares. The Hamilton basis satisfies i2 = j2 = k2 = −1.
- Using the multiplication table backward. ij = k, but ji = −k.
- Treating a four component storage array as an ordinary vector. Quaternion
addition is componentwise, but quaternion multiplication is not.
- Inferring multiplication convention from storage order. Scalar first and scalar
last describe only component layout. They do not determine whether the multiplication
law is Hamilton or flipped.
- Calling every four component array a quaternion. A quaternion is not merely
four numbers. It is four real coefficients together with the multiplication law of ℍ.
- Changing the later active or passive attitude convention and then changing
Hamilton’s algebra as well. These are separate choices. PhysicsLibrary’s move to
passive coordinate transformations does not change the Q01 multiplication table.
11 Exercises
The exercises are stated first so that the article can be used for self study. Complete solutions
follow in the next section.
- Basis multiplication. Evaluate
- Addition and scalar multiplication. For
find p + q, p − q, and −2p.
- General quaternion product. Let
Compute pq.
- Order matters. For the quaternions in Exercise 3, compute qp and the commutator
[p,q] = pq − qp.
- A cancellation identity. Show directly from the multiplication table that
Explain why treating i and j as commuting symbols gives the wrong intermediate
expression.
- Complex numbers inside the quaternions. Let
where a,b,c,d are real. Show that
and verify that pq = qp for this restricted pair.
- Associativity versus commutativity. Verify explicitly that
but
State in words what the two calculations demonstrate.
- Arbitrary unit pure quaternion. Let
Expand u2 using only the multiplication table and prove that u2 = −1.
- Identify a convention error. An engineer writes quaternion components in scalar
first order and states ij = −k. A colleague claims that the minus sign must be caused
by scalar first storage. Is that explanation correct? Identify what the equation actually
reveals.
12 Solutions
1. Basis multiplication
From the Hamilton table,
and
Also,
whereas
2. Addition and scalar multiplication
Componentwise addition gives
Subtraction gives
Finally,
3. General quaternion product
With
the general product formula gives
4. Order matters
Reversing the factors gives
Therefore
The nonzero commutator confirms that these two quaternions do not commute.
5. A cancellation identity
Expand without reordering factors:
If the symbols were incorrectly assumed to commute, the two middle terms would instead be
combined as 2ij = 2k. Quaternion multiplication gives ij + ji = 0.
6. Complex numbers inside the quaternions
Using i2 = −1,
Reversing the factors produces
which is the same result because a,b,c,d are real. This two dimensional subalgebra is commutative
and isomorphic to the complex numbers.
7. Associativity versus commutativity
The left grouping gives
The right grouping gives
Hence multiplication is associative for these basis elements. But
so multiplication is not commutative. Associativity permits regrouping; commutativity would
permit reordering.
8. Arbitrary unit pure quaternion
Expand
Grouping reversed mixed pairs gives
Each mixed pair cancels, so
Since a2 + b2 + c2 = 1,
This result is one of the algebraic reasons arbitrary spatial axes can play the role of an imaginary
unit in later quaternion orientation formulas.
9. Identify a convention error
The colleague’s explanation is incorrect. Scalar first versus scalar last specifies only the order in
which the four real coefficients are displayed or stored.
The equation
instead identifies a multiplication law whose orientation is flipped relative to the PhysicsLibrary
Hamilton rule
The storage order did not cause the sign change.
13 What comes next
The component product derived above is correct and useful, but its pattern of signs can look
arbitrary. The next PhysicsLibrary quaternion entry rewrites
and derives the compact Hamilton scalar vector product
That form explains the multiplication table through the dot and cross products of ordinary three
dimensional vector analysis and is the principal bridge from quaternion algebra to mechanics and
later passive frame orientation.
14 Sources and historical notes
Hamilton’s Elements of Quaternions is the primary historical source for the relations among i,j,k,
including the failure of the commutative law and preservation of associativity.
Joly’s A Manual of Quaternions gives a compact development beginning from the scalar and
vector parts of a quaternion and explicitly discusses the algebraic properties of the product.
Kelland and Tait likewise separate products into scalar and vector parts and provide extensive
examples. Hathaway’s A Primer of Quaternions was written as an elementary treatment and
contains exercises on the fundamental basis relations.
The Wikibooks quaternion article provides a modern openly licensed elementary reference. The
notation and organization of this PhysicsLibrary entry are modernized for physics and engineering
use; the exposition and worked solutions here are newly written rather than transcribed from the
historical sources.
References
[1] W. R. Hamilton, Elements of Quaternions, 2nd ed., edited by C. J. Joly, Longmans,
Green, and Co., 1899. Public domain historical source. Internet Archive scan
[2] C. J. Joly, A Manual of Quaternions, Macmillan and Co., London, 1905. Public
domain historical source. Internet Archive search
[3] P. Kelland and P. G. Tait, Introduction to Quaternions, with Numerous Examples,
2nd ed., Macmillan and Co., London, 1882. Public domain historical source. HathiTrust
catalog search
[4] A. S. Hathaway, A Primer of Quaternions, 1896. Public domain historical source.
Project Gutenberg edition
[5] Wikibooks contributors, “Abstract Algebra/Quaternions.” Openly licensed
instructional source. Wikibooks quaternion article
License
Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative
Commons Attribution ShareAlike 4.0 International license.