Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random | Template Test |  
Login
create new user
Username:
Password:
forget your password?
Main Menu
Sections

Meta

Talkback

Downloads

Information
[parent] example of quaternion definition and basic algebra (Example)

Quaternion Definition and Basic Algebra: Examples, Exercises, and Solutions

This entry is the self study companion to quaternion definition and basic algebra. Its purpose is to build fluency with quaternion notation and Hamilton multiplication before quaternions are used for axis angle rotations, attitude, or angular kinematics.

All exercises are stated first. Complete worked solutions follow afterward.

Formula summary

A quaternion is

$\displaystyle q=q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k,$ (1)

with real coefficients. PhysicsLibrary displays components scalar first:

$\displaystyle [q]_{\mathrm{PL}}= \begin{bmatrix} q_w\\ q_x\\ q_y\\ q_z \end{bmatrix}.$ (2)

The scalar and vector parts are

$\displaystyle \operatorname{Sc}(q)=q_w, \qquad \operatorname{Vec}(q)=q_x\mathbf i+q_y\mathbf j+q_z\mathbf k.$ (3)

Hamilton's basis rules are

$\displaystyle \mathbf i^2=\mathbf j^2=\mathbf k^2=-1,$ (4)
$\displaystyle \mathbf i\mathbf j=\mathbf k, \qquad \mathbf j\mathbf k=\mathbf i, \qquad \mathbf k\mathbf i=\mathbf j,$ (5)

and reversing two distinct basis factors changes the sign. quaternion multiplication is associative and distributive but not generally commutative.

Exercises

  1. Identify quaternion parts.

    For

    $\displaystyle q=3-2\mathbf i+5\mathbf j-7\mathbf k, $
    determine $q_w,q_x,q_y,q_z$, the scalar part, the vector part, and the PhysicsLibrary scalar first component column. Is $q$ pure? Is it a real quaternion?
  2. Quaternion equality.

    Let

    $\displaystyle p=a+2\mathbf i-3\mathbf j+b\mathbf k, \qquad q=4+c\mathbf i-3\mathbf j+5\mathbf k. $
    Find $a,b,c$ such that $p=q$. Explain why a quaternion equality represents four real coefficient equations.
  3. Addition and scalar multiplication.

    Let

    $\displaystyle p=3-2\mathbf i+4\mathbf j-\mathbf k, \qquad q=-1+5\mathbf i+2\mathbf k. $
    Compute $p+q$, $p-q$, $-2p$, and $3q$. Verify $2(p+q)=2p+2q$.
  4. Hamilton basis multiplication.

    Evaluate

    $\displaystyle \mathbf i\mathbf k,\quad \mathbf k\mathbf i,\quad \mathbf j\mathbf i,\quad \mathbf k\mathbf j, $

    $\displaystyle \mathbf i\mathbf j\mathbf k,\quad \mathbf j\mathbf i\mathbf k,\quad \mathbf i^4,\quad (\mathbf i\mathbf j)^2. $
  5. Derive a cyclic product.

    Starting from

    $\displaystyle \mathbf i\mathbf j\mathbf k=-1, $
    derive $\mathbf i\mathbf j=\mathbf k$ using associativity and $\mathbf k^2=-1$. Then derive $\mathbf j\mathbf k=\mathbf i$ in the same spirit.
  6. Direct general product expansion.

    Let

    $\displaystyle p=2+\mathbf i-2\mathbf j+\mathbf k, \qquad q=-1+3\mathbf i+2\mathbf k. $
    Compute $pq$ by distributing all terms and using the basis multiplication table.
  7. Order matters.

    Using the same $p$ and $q$, compute $qp$ and the commutator

    $\displaystyle \relax[p,q]=pq-qp.$ (6)
    Do the two quaternions commute?
  8. A cancellation identity.

    Show directly that

    $\displaystyle (\mathbf i+\mathbf j)^2=-2.$ (7)
    Explain what incorrect extra term appears if $\mathbf i$ and $\mathbf j$ are treated as commuting symbols.
  9. Associativity versus commutativity.

    Verify explicitly that

    $\displaystyle (\mathbf i\mathbf j)\mathbf k=\mathbf i(\mathbf j\mathbf k), $
    but

    $\displaystyle \mathbf i\mathbf j\ne\mathbf j\mathbf i. $
    State what each calculation demonstrates.
  10. Distributivity.

    Let

    $\displaystyle p=1+\mathbf i, \qquad q=\mathbf j, \qquad r=\mathbf k. $
    Compute both sides of $p(q+r)=pq+pr$ and $(q+r)p=qp+rp$.
  11. Complex subalgebra.

    Let

    $\displaystyle p=a+b\mathbf i, \qquad q=c+d\mathbf i, $
    with real $a,b,c,d$. Show
    $\displaystyle pq=(ac-bd)+(ad+bc)\mathbf i$ (8)
    and verify $pq=qp$ for this restricted pair. Explain why this does not imply that all quaternions commute.
  12. Arbitrary unit pure quaternion.

    Let

    $\displaystyle u=a\mathbf i+b\mathbf j+c\mathbf k, \qquad a^2+b^2+c^2=1. $
    Expand $u^2$ and prove
    $\displaystyle u^2=-1.$ (9)
    Why is this result important for later axis based quaternion formulas?
  13. Pure quaternion product and vector analysis.

    Let

    $\displaystyle u=u_x\mathbf i+u_y\mathbf j+u_z\mathbf k, \qquad v=v_x\mathbf i+v_y\mathbf j+v_z\mathbf k. $
    Expand $uv$ and show
    $\displaystyle \operatorname{Sc}(uv)=-\mathbf u\cdot\mathbf v,$ (10)
    while the vector part equals $\mathbf u\times\mathbf v$. Use $u=\mathbf i$, $v=\mathbf j$ as a sign check.
  14. Storage order diagnostic.

    Package A stores $[q_w,q_x,q_y,q_z]$ and Package B stores $[q_x,q_y,q_z,q_w]$. Both use Hamilton multiplication. A student claims Package B must use a different quaternion algebra. Is the claim correct? Write

    $\displaystyle q=0.8-0.1\mathbf i+0.2\mathbf j-0.55\mathbf k $
    in the array order expected by both packages.
  15. Multiplication convention versus attitude convention.

    An engineer writes quaternions scalar first and states

    $\displaystyle \mathbf i\mathbf j=-\mathbf k. $
    A colleague says the minus sign must indicate a passive attitude convention. Evaluate the claim. What does the basis equation actually reveal, and what additional information is required to decide whether an attitude quaternion is active or passive?

Solutions

Solution 1: identify quaternion parts

For

$\displaystyle q=3-2\mathbf i+5\mathbf j-7\mathbf k, $
we have

$\displaystyle q_w=3,\qquad q_x=-2,\qquad q_y=5,\qquad q_z=-7. $
Therefore
$\displaystyle \operatorname{Sc}(q)=3,$ (11)
and
$\displaystyle \operatorname{Vec}(q)=-2\mathbf i+5\mathbf j-7\mathbf k.$ (12)
The component column is
$\displaystyle [q]_{\mathrm{PL}}= \begin{bmatrix} 3\\ -2\\ 5\\ -7 \end{bmatrix}.$ (13)
A pure quaternion has zero scalar part, so $q$ is not pure. A real quaternion has zero vector part, so $q$ is not real either.

Solution 2: quaternion equality

Equality requires corresponding coefficients to agree. Thus

$\displaystyle a=4,\qquad c=2,\qquad -3=-3,\qquad b=5. $
Hence
$\displaystyle a=4,\qquad b=5,\qquad c=2.$ (14)
A quaternion has four independent real coefficients, so one quaternion equality is shorthand for four real equations.

Solution 3: addition and scalar multiplication

Componentwise addition gives

$\displaystyle p+q=2+3\mathbf i+4\mathbf j+\mathbf k.$ (15)
Subtraction gives
$\displaystyle p-q=4-7\mathbf i+4\mathbf j-3\mathbf k.$ (16)
Also,
$\displaystyle -2p=-6+4\mathbf i-8\mathbf j+2\mathbf k,$ (17)
and
$\displaystyle 3q=-3+15\mathbf i+6\mathbf k.$ (18)
Finally,

$\displaystyle 2(p+q)=4+6\mathbf i+8\mathbf j+2\mathbf k, $
and direct addition of $2p$ and $2q$ gives the same result.

Solution 4: Hamilton basis multiplication

Using the Hamilton table,

$\displaystyle \mathbf i\mathbf k=-\mathbf j, \qquad \mathbf k\mathbf i=\mathbf j, $

$\displaystyle \mathbf j\mathbf i=-\mathbf k, \qquad \mathbf k\mathbf j=-\mathbf i. $
Also,

$\displaystyle \mathbf i\mathbf j\mathbf k=(\mathbf i\mathbf j)\mathbf k=\mathbf k^2=-1, $
while

$\displaystyle \mathbf j\mathbf i\mathbf k=(-\mathbf k)\mathbf k=1. $
Since $\mathbf i^2=-1$,

$\displaystyle \mathbf i^4=1, $
and

$\displaystyle (\mathbf i\mathbf j)^2=\mathbf k^2=-1. $

Solution 5: derive a cyclic product

Starting with

$\displaystyle \mathbf i\mathbf j\mathbf k=-1, $
right multiply by $-\mathbf k$:

$\displaystyle (\mathbf i\mathbf j\mathbf k)(-\mathbf k)=(-1)(-\mathbf k). $
Associativity gives

$\displaystyle \mathbf i\mathbf j[\mathbf k(-\mathbf k)]=\mathbf k. $
Because $\mathbf k(-\mathbf k)=1$,
$\displaystyle \mathbf i\mathbf j=\mathbf k.$ (19)
Similarly, left multiply the fundamental relation by $-\mathbf i$:

$\displaystyle (-\mathbf i)(\mathbf i\mathbf j\mathbf k)=(-\mathbf i)(-1). $
Since $(-\mathbf i)\mathbf i=1$,
$\displaystyle \mathbf j\mathbf k=\mathbf i.$ (20)

Solution 6: direct general product expansion

Distribute without changing factor order:

\begin{equation*} \begin{aligned} pq={}&2(-1)+2(3\mathbf i)+2(2\mathbf k) +\math... ... k +\mathbf k(-1)+3\mathbf k\mathbf i+2\mathbf k^2. \end{aligned}\end{equation*}
Use

$\displaystyle \mathbf i^2=\mathbf k^2=-1, \quad \mathbf i\mathbf k=-\mathbf j, ... ...hbf k, \quad \mathbf j\mathbf k=\mathbf i, \quad \mathbf k\mathbf i=\mathbf j. $
Collecting coefficients gives
$\displaystyle pq=-7+\mathbf i+3\mathbf j+9\mathbf k.$ (21)

Solution 7: order matters

Reversing the factors gives

$\displaystyle qp=-7+9\mathbf i+\mathbf j-3\mathbf k.$ (22)
Therefore

\begin{equation*} \begin{aligned}[p,q]&=pq-qp\ &=(-7+\mathbf i+3\mathbf j+9\mathbf k)-(-7+9\mathbf i+\mathbf j-3\mathbf k), \end{aligned}\end{equation*}
so
$\displaystyle [p,q]=-8\mathbf i+2\mathbf j+12\mathbf k.$ (23)
The commutator is nonzero, so $p$ and $q$ do not commute.

Solution 8: a cancellation identity

Expand in factor order:

$\displaystyle (\mathbf i+\mathbf j)^2=\mathbf i^2+\mathbf i\mathbf j+\mathbf j\mathbf i+\mathbf j^2. $
Thus

$\displaystyle (\mathbf i+\mathbf j)^2=-1+\mathbf k-\mathbf k-1=-2. $
Therefore
$\displaystyle (\mathbf i+\mathbf j)^2=-2.$ (24)
If the basis elements were incorrectly assumed to commute, the middle terms would be combined as $2\mathbf i\mathbf j=2\mathbf k$, which is wrong because $\mathbf i\mathbf j\ne\mathbf j\mathbf i$.

Solution 9: associativity versus commutativity

First,

$\displaystyle (\mathbf i\mathbf j)\mathbf k=\mathbf k\mathbf k=-1. $
Also,

$\displaystyle \mathbf i(\mathbf j\mathbf k)=\mathbf i\mathbf i=-1. $
Hence associativity holds in this example. But

$\displaystyle \mathbf i\mathbf j=\mathbf k, \qquad \mathbf j\mathbf i=-\mathbf k, $
so commutativity fails. Quaternion factors may be regrouped but not generally reordered.

Solution 10: distributivity

For the first identity,

\begin{equation*} \begin{aligned} p(q+r)&=(1+\mathbf i)(\mathbf j+\mathbf k)\ ... ...bf j+\mathbf k+\mathbf k-\mathbf j\ &=2\mathbf k. \end{aligned}\end{equation*}
Separately,

$\displaystyle pq=\mathbf j+\mathbf k, \qquad pr=\mathbf k-\mathbf j, $
so $pq+pr=2\mathbf k$. For the second identity,

\begin{equation*} \begin{aligned} (q+r)p&=(\mathbf j+\mathbf k)(1+\mathbf i)\ ... ...bf j+\mathbf k-\mathbf k+\mathbf j\ &=2\mathbf j. \end{aligned}\end{equation*}
Also,

$\displaystyle qp=\mathbf j-\mathbf k, \qquad rp=\mathbf k+\mathbf j, $
so $qp+rp=2\mathbf j$.

Solution 11: complex subalgebra

Multiply directly:

\begin{equation*} \begin{aligned} pq&=(a+b\mathbf i)(c+d\mathbf i)\ &=ac+ad\ma... ...thbf i+bd\mathbf i^2\ &=(ac-bd)+(ad+bc)\mathbf i. \end{aligned}\end{equation*}
Thus
$\displaystyle pq=(ac-bd)+(ad+bc)\mathbf i.$ (25)
Reversing the factors yields the same expression because the real coefficients commute and only one imaginary basis direction is present. This restricted set is a copy of the complex numbers inside the quaternions. It does not imply that general quaternions commute because different imaginary basis directions do not commute.

Solution 12: arbitrary unit pure quaternion

Expand

\begin{equation*} \begin{aligned} u^2={}&a^2\mathbf i^2+b^2\mathbf j^2+c^2\mathb... ... i)\ &+bc(\mathbf j\mathbf k+\mathbf k\mathbf j). \end{aligned}\end{equation*}
Each mixed pair cancels because reversing distinct Hamilton basis factors changes the sign. Hence

$\displaystyle u^2=-a^2-b^2-c^2. $
Using $a^2+b^2+c^2=1$ gives
$\displaystyle u^2=-1.$ (26)
Thus every unit pure quaternion behaves algebraically like an imaginary unit. Later, this allows an arbitrary spatial unit axis to appear naturally inside quaternion axis angle formulas.

Solution 13: pure quaternion product and vector analysis

Expanding $uv$ gives the scalar terms

$\displaystyle -u_xv_x-u_yv_y-u_zv_z, $
so
$\displaystyle \operatorname{Sc}(uv)=-\mathbf u\cdot\mathbf v.$ (27)
The vector terms are

$\displaystyle (u_yv_z-u_zv_y)\mathbf i+(u_zv_x-u_xv_z)\mathbf j+(u_xv_y-u_yv_x)\mathbf k, $
which is exactly $\mathbf u\times\mathbf v$. Therefore
$\displaystyle uv=-\mathbf u\cdot\mathbf v+\mathbf u\times\mathbf v.$ (28)
For $u=\mathbf i$ and $v=\mathbf j$, the dot product is zero and the cross product is $\mathbf k$, so the formula gives $\mathbf i\mathbf j=\mathbf k$ as required.

Solution 14: storage order diagnostic

The claim is incorrect. Storage order changes only the order of the four real coefficients in memory or display; it does not change Hamilton multiplication. For Package A,

$\displaystyle [0.8,-0.1,0.2,-0.55].$ (29)
For Package B,
$\displaystyle [-0.1,0.2,-0.55,0.8].$ (30)
The semantic quaternion is identical in both cases.

Solution 15: multiplication convention versus attitude convention

The colleague's claim is incorrect. The basis equation

$\displaystyle \mathbf i\mathbf j=-\mathbf k $
identifies a multiplication law whose cross-like basis products are flipped relative to the PhysicsLibrary Hamilton rule $\mathbf i\mathbf j=+\mathbf k$. It does not by itself identify active or passive attitude semantics. Likewise, scalar first notation only specifies coefficient ordering. To determine attitude semantics, one needs the declared physical map, for example an active vector rule such as

$\displaystyle v'=qvq^*, $
or a frame labeled passive coordinate rule such as

$\displaystyle {}^Bv={}^Bq_A\,{}^Av\,({}^Bq_A)^*. $
Multiplication law, storage order, and attitude interpretation are separate convention choices.

Compact review

The central facts tested here are

$\displaystyle q=q_w+\mathbf q,$ (31)
$\displaystyle \mathbf i^2=\mathbf j^2=\mathbf k^2=-1,$ (32)
$\displaystyle \mathbf i\mathbf j=\mathbf k, \qquad \mathbf j\mathbf i=-\mathbf k,$ (33)
$\displaystyle (pq)r=p(qr), \qquad p(q+r)=pq+pr,$ (34)
and, for pure quaternions,
$\displaystyle uv=-\mathbf u\cdot\mathbf v+\mathbf u\times\mathbf v.$ (35)
The last identity is the bridge to the next PhysicsLibrary quaternion entry, which develops the scalar vector Hamilton product in compact form.

Sources and exercise provenance

The exercises and solutions in this companion are newly written or expanded for PhysicsLibrary. Hamilton is the foundational historical source; Joly, Kelland and Tait, and Hathaway provide later systematic and pedagogical treatments. The present article uses modern scalar first engineering notation rather than reproducing historical notation.

Bibliography

1
W. R. Hamilton, Elements of Quaternions, 2nd ed., edited by C. J. Joly, Longmans, Green, and Co., 1899. Internet Archive scan
2
C. J. Joly, A Manual of Quaternions, Macmillan and Co., London, 1905. Internet Archive search
3
P. Kelland and P. G. Tait, Introduction to Quaternions, with Numerous Examples, 2nd ed., Macmillan and Co., London, 1882. Internet Archive search
4
A. S. Hathaway, A Primer of Quaternions, 1896. Project Gutenberg edition

License

Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative Commons Attribution ShareAlike 4.0 International license.



"example of quaternion definition and basic algebra" is owned by bloftin.
(view preamble)
View style:
See Also: quaternion series overview and article guide, Notation Quaternions for Physics and Engineering: Orientation, quaternion definition and basic algebra


This object's parent.

Cross-references: cross product, dot product, relation, formulas, commutativity, identity, commute, commutator, quaternion multiplication, vector, scalar, kinematics, quaternion, quaternion definition and basic algebra
There is 1 reference to this object.

This is version 1 of example of quaternion definition and basic algebra, born on 2026-08-28.
Object id is 1114, canonical name is ExampleOfQuaternionDefinitionAndBasicAlgebra.
Accessed 13 times total.

Classification:
Physics Classification02.10.Hh (Rings and algebras)
 02.10.De (Algebraic structures and number theory)
 02.10.Ud (Linear algebra)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

Interact
rate | post | correct | update request | add example | add (any)