<?xml version="1.0" encoding="UTF-8"?>

<record version="1" id="1114">
 <title>example of quaternion definition and basic algebra</title>
 <name>ExampleOfQuaternionDefinitionAndBasicAlgebra</name>
 <created>2026-08-28 15:12:00</created>
 <modified>2026-08-28 15:12:00</modified>
 <type>Example</type>
<parent id="1091">quaternion definition and basic algebra</parent>
 <creator id="1" name="bloftin"/>
 <modifier id="1" name="bloftin"/>
 <comment>updated related objects</comment>
 <author id="1" name="bloftin"/>
 <classification>
	<category scheme="pacs" code="02.10.Hh"/>
	<category scheme="pacs" code="02.10.De"/>
	<category scheme="pacs" code="02.10.Ud"/>
 </classification>
 <related>
	<object name="QuaternionSeriesOverviewAndArticleGuide"/>
	<object name="NotationQuaternionsForPhysicsAndEngineeringOrientation"/>
	<object name="QuaternionDefinitionAndBasicAlgebra"/>
 </related>
 <preamble>% this is the default PhysicsLibrary preamble.  as your knowledge
% of TeX increases, you will probably want to edit this, but
% it should be fine as is for beginners.

% almost certainly you want these
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}

% used for TeXing text within eps files
%\usepackage{psfrag}
% need this for including graphics (\includegraphics).
% If you use \includegraphics{figure} with no file extension, PhysicsLibrary
% will prefer figure.png before falling back to figure.eps.
\usepackage{graphicx}
\DeclareGraphicsExtensions{.png,.jpg,.jpeg,.pdf,.eps}
% for neatly defining theorems and propositions
%\usepackage{amsthm}
% making logically defined graphics
%\usepackage{xypic}

% there are many more packages, add them here as you need them

% define commands here</preamble>
 <content>\section*{Quaternion Definition and Basic Algebra: Examples, Exercises, and Solutions}

This entry is the self study companion to \emph{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.

\section{Formula summary}

A quaternion is

\begin{equation}
q=q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k,
\end{equation}

with real coefficients. PhysicsLibrary displays components scalar first:

\begin{equation}
[q]_{\mathrm{PL}}=
\begin{bmatrix}
q_w\\q_x\\q_y\\q_z
\end{bmatrix}.
\end{equation}

The scalar and vector parts are

\begin{equation}
\operatorname{Sc}(q)=q_w,
\qquad
\operatorname{Vec}(q)=q_x\mathbf i+q_y\mathbf j+q_z\mathbf k.
\end{equation}

Hamilton's basis rules are

\begin{equation}
\mathbf i^2=\mathbf j^2=\mathbf k^2=-1,
\end{equation}

\begin{equation}
\mathbf i\mathbf j=\mathbf k,
\qquad
\mathbf j\mathbf k=\mathbf i,
\qquad
\mathbf k\mathbf i=\mathbf j,
\end{equation}

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

\section{Exercises}

\begin{enumerate}

\item \textbf{Identify quaternion parts.}

For
\[
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?

\item \textbf{Quaternion equality.}

Let
\[
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.

\item \textbf{Addition and scalar multiplication.}

Let
\[
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$.

\item \textbf{Hamilton basis multiplication.}

Evaluate
\[
\mathbf i\mathbf k,\quad
\mathbf k\mathbf i,\quad
\mathbf j\mathbf i,\quad
\mathbf k\mathbf j,
\]
\[
\mathbf i\mathbf j\mathbf k,\quad
\mathbf j\mathbf i\mathbf k,\quad
\mathbf i^4,\quad
(\mathbf i\mathbf j)^2.
\]

\item \textbf{Derive a cyclic product.}

Starting from
\[
\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.

\item \textbf{Direct general product expansion.}

Let
\[
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.

\item \textbf{Order matters.}

Using the same $p$ and $q$, compute $qp$ and the commutator
\begin{equation}
\relax[p,q]=pq-qp.
\end{equation}
Do the two quaternions commute?

\item \textbf{A cancellation identity.}

Show directly that
\begin{equation}
(\mathbf i+\mathbf j)^2=-2.
\end{equation}
Explain what incorrect extra term appears if $\mathbf i$ and $\mathbf j$ are treated as commuting symbols.

\item \textbf{Associativity versus commutativity.}

Verify explicitly that
\[
(\mathbf i\mathbf j)\mathbf k=\mathbf i(\mathbf j\mathbf k),
\]
but
\[
\mathbf i\mathbf j\ne\mathbf j\mathbf i.
\]
State what each calculation demonstrates.

\item \textbf{Distributivity.}

Let
\[
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$.

\item \textbf{Complex subalgebra.}

Let
\[
p=a+b\mathbf i,
\qquad
q=c+d\mathbf i,
\]
with real $a,b,c,d$. Show
\begin{equation}
pq=(ac-bd)+(ad+bc)\mathbf i
\end{equation}
and verify $pq=qp$ for this restricted pair. Explain why this does not imply that all quaternions commute.

\item \textbf{Arbitrary unit pure quaternion.}

Let
\[
u=a\mathbf i+b\mathbf j+c\mathbf k,
\qquad
a^2+b^2+c^2=1.
\]
Expand $u^2$ and prove
\begin{equation}
u^2=-1.
\end{equation}
Why is this result important for later axis based quaternion formulas?

\item \textbf{Pure quaternion product and vector analysis.}

Let
\[
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
\begin{equation}
\operatorname{Sc}(uv)=-\mathbf u\cdot\mathbf v,
\end{equation}
while the vector part equals $\mathbf u\times\mathbf v$. Use $u=\mathbf i$, $v=\mathbf j$ as a sign check.

\item \textbf{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
\[
q=0.8-0.1\mathbf i+0.2\mathbf j-0.55\mathbf k
\]
in the array order expected by both packages.

\item \textbf{Multiplication convention versus attitude convention.}

An engineer writes quaternions scalar first and states
\[
\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?

\end{enumerate}

\section{Solutions}

\subsection*{Solution 1: identify quaternion parts}

For
\[
q=3-2\mathbf i+5\mathbf j-7\mathbf k,
\]
we have
\[
q_w=3,\qquad q_x=-2,\qquad q_y=5,\qquad q_z=-7.
\]
Therefore
\begin{equation}
\operatorname{Sc}(q)=3,
\end{equation}
and
\begin{equation}
\operatorname{Vec}(q)=-2\mathbf i+5\mathbf j-7\mathbf k.
\end{equation}
The component column is
\begin{equation}
[q]_{\mathrm{PL}}=
\begin{bmatrix}
3\\-2\\5\\-7
\end{bmatrix}.
\end{equation}
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.

\subsection*{Solution 2: quaternion equality}

Equality requires corresponding coefficients to agree. Thus
\[
a=4,\qquad c=2,\qquad -3=-3,\qquad b=5.
\]
Hence
\begin{equation}
a=4,\qquad b=5,\qquad c=2.
\end{equation}
A quaternion has four independent real coefficients, so one quaternion equality is shorthand for four real equations.

\subsection*{Solution 3: addition and scalar multiplication}

Componentwise addition gives
\begin{equation}
p+q=2+3\mathbf i+4\mathbf j+\mathbf k.
\end{equation}
Subtraction gives
\begin{equation}
p-q=4-7\mathbf i+4\mathbf j-3\mathbf k.
\end{equation}
Also,
\begin{equation}
-2p=-6+4\mathbf i-8\mathbf j+2\mathbf k,
\end{equation}
and
\begin{equation}
3q=-3+15\mathbf i+6\mathbf k.
\end{equation}
Finally,
\[
2(p+q)=4+6\mathbf i+8\mathbf j+2\mathbf k,
\]
and direct addition of $2p$ and $2q$ gives the same result.

\subsection*{Solution 4: Hamilton basis multiplication}

Using the Hamilton table,
\[
\mathbf i\mathbf k=-\mathbf j,
\qquad
\mathbf k\mathbf i=\mathbf j,
\]
\[
\mathbf j\mathbf i=-\mathbf k,
\qquad
\mathbf k\mathbf j=-\mathbf i.
\]
Also,
\[
\mathbf i\mathbf j\mathbf k=(\mathbf i\mathbf j)\mathbf k=\mathbf k^2=-1,
\]
while
\[
\mathbf j\mathbf i\mathbf k=(-\mathbf k)\mathbf k=1.
\]
Since $\mathbf i^2=-1$,
\[
\mathbf i^4=1,
\]
and
\[
(\mathbf i\mathbf j)^2=\mathbf k^2=-1.
\]

\subsection*{Solution 5: derive a cyclic product}

Starting with
\[
\mathbf i\mathbf j\mathbf k=-1,
\]
right multiply by $-\mathbf k$:
\[
(\mathbf i\mathbf j\mathbf k)(-\mathbf k)=(-1)(-\mathbf k).
\]
Associativity gives
\[
\mathbf i\mathbf j[\mathbf k(-\mathbf k)]=\mathbf k.
\]
Because $\mathbf k(-\mathbf k)=1$,
\begin{equation}
\mathbf i\mathbf j=\mathbf k.
\end{equation}
Similarly, left multiply the fundamental relation by $-\mathbf i$:
\[
(-\mathbf i)(\mathbf i\mathbf j\mathbf k)=(-\mathbf i)(-1).
\]
Since $(-\mathbf i)\mathbf i=1$,
\begin{equation}
\mathbf j\mathbf k=\mathbf i.
\end{equation}

\subsection*{Solution 6: direct general product expansion}

Distribute without changing factor order:
\[
\begin{aligned}
pq={}&amp;2(-1)+2(3\mathbf i)+2(2\mathbf k)
+\mathbf i(-1)+3\mathbf i^2+2\mathbf i\mathbf k\\
&amp;-2\mathbf j(-1)-6\mathbf j\mathbf i-4\mathbf j\mathbf k
+\mathbf k(-1)+3\mathbf k\mathbf i+2\mathbf k^2.
\end{aligned}
\]
Use
\[
\mathbf i^2=\mathbf k^2=-1,
\quad
\mathbf i\mathbf k=-\mathbf j,
\quad
\mathbf j\mathbf i=-\mathbf k,
\quad
\mathbf j\mathbf k=\mathbf i,
\quad
\mathbf k\mathbf i=\mathbf j.
\]
Collecting coefficients gives
\begin{equation}
pq=-7+\mathbf i+3\mathbf j+9\mathbf k.
\end{equation}

\subsection*{Solution 7: order matters}

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

\subsection*{Solution 8: a cancellation identity}

Expand in factor order:
\[
(\mathbf i+\mathbf j)^2=\mathbf i^2+\mathbf i\mathbf j+\mathbf j\mathbf i+\mathbf j^2.
\]
Thus
\[
(\mathbf i+\mathbf j)^2=-1+\mathbf k-\mathbf k-1=-2.
\]
Therefore
\begin{equation}
(\mathbf i+\mathbf j)^2=-2.
\end{equation}
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$.

\subsection*{Solution 9: associativity versus commutativity}

First,
\[
(\mathbf i\mathbf j)\mathbf k=\mathbf k\mathbf k=-1.
\]
Also,
\[
\mathbf i(\mathbf j\mathbf k)=\mathbf i\mathbf i=-1.
\]
Hence associativity holds in this example.
But
\[
\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.

\subsection*{Solution 10: distributivity}

For the first identity,
\[
\begin{aligned}
p(q+r)&amp;=(1+\mathbf i)(\mathbf j+\mathbf k)\\
&amp;=\mathbf j+\mathbf k+\mathbf i\mathbf j+\mathbf i\mathbf k\\
&amp;=\mathbf j+\mathbf k+\mathbf k-\mathbf j\\
&amp;=2\mathbf k.
\end{aligned}
\]
Separately,
\[
pq=\mathbf j+\mathbf k,
\qquad
pr=\mathbf k-\mathbf j,
\]
so $pq+pr=2\mathbf k$.
For the second identity,
\[
\begin{aligned}
(q+r)p&amp;=(\mathbf j+\mathbf k)(1+\mathbf i)\\
&amp;=\mathbf j+\mathbf k+\mathbf j\mathbf i+\mathbf k\mathbf i\\
&amp;=\mathbf j+\mathbf k-\mathbf k+\mathbf j\\
&amp;=2\mathbf j.
\end{aligned}
\]
Also,
\[
qp=\mathbf j-\mathbf k,
\qquad
rp=\mathbf k+\mathbf j,
\]
so $qp+rp=2\mathbf j$.

\subsection*{Solution 11: complex subalgebra}

Multiply directly:
\[
\begin{aligned}
pq&amp;=(a+b\mathbf i)(c+d\mathbf i)\\
&amp;=ac+ad\mathbf i+bc\mathbf i+bd\mathbf i^2\\
&amp;=(ac-bd)+(ad+bc)\mathbf i.
\end{aligned}
\]
Thus
\begin{equation}
pq=(ac-bd)+(ad+bc)\mathbf i.
\end{equation}
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.

\subsection*{Solution 12: arbitrary unit pure quaternion}

Expand
\[
\begin{aligned}
u^2={}&amp;a^2\mathbf i^2+b^2\mathbf j^2+c^2\mathbf k^2\\
&amp;+ab(\mathbf i\mathbf j+\mathbf j\mathbf i)\\
&amp;+ac(\mathbf i\mathbf k+\mathbf k\mathbf i)\\
&amp;+bc(\mathbf j\mathbf k+\mathbf k\mathbf j).
\end{aligned}
\]
Each mixed pair cancels because reversing distinct Hamilton basis factors changes the sign. Hence
\[
u^2=-a^2-b^2-c^2.
\]
Using $a^2+b^2+c^2=1$ gives
\begin{equation}
u^2=-1.
\end{equation}
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.

\subsection*{Solution 13: pure quaternion product and vector analysis}

Expanding $uv$ gives the scalar terms
\[
-u_xv_x-u_yv_y-u_zv_z,
\]
so
\begin{equation}
\operatorname{Sc}(uv)=-\mathbf u\cdot\mathbf v.
\end{equation}
The vector terms are
\[
(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
\begin{equation}
uv=-\mathbf u\cdot\mathbf v+\mathbf u\times\mathbf v.
\end{equation}
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.

\subsection*{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,
\begin{equation}
[0.8,-0.1,0.2,-0.55].
\end{equation}
For Package B,
\begin{equation}
[-0.1,0.2,-0.55,0.8].
\end{equation}
The semantic quaternion is identical in both cases.

\subsection*{Solution 15: multiplication convention versus attitude convention}

The colleague's claim is incorrect. The basis equation
\[
\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
\[
v'=qvq^*,
\]
or a frame labeled passive coordinate rule such as
\[
{}^Bv={}^Bq_A\,{}^Av\,({}^Bq_A)^*.
\]
Multiplication law, storage order, and attitude interpretation are separate convention choices.

\section{Compact review}

The central facts tested here are
\begin{equation}
q=q_w+\mathbf q,
\end{equation}
\begin{equation}
\mathbf i^2=\mathbf j^2=\mathbf k^2=-1,
\end{equation}
\begin{equation}
\mathbf i\mathbf j=\mathbf k,
\qquad
\mathbf j\mathbf i=-\mathbf k,
\end{equation}
\begin{equation}
(pq)r=p(qr),
\qquad
p(q+r)=pq+pr,
\end{equation}
and, for pure quaternions,
\begin{equation}
uv=-\mathbf u\cdot\mathbf v+\mathbf u\times\mathbf v.
\end{equation}
The last identity is the bridge to the next PhysicsLibrary quaternion entry, which develops the scalar vector Hamilton product in compact form.

\section{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.

\begin{thebibliography}{9}

\bibitem{Hamilton1899}
W. R. Hamilton,
\emph{Elements of Quaternions}, 2nd ed., edited by C. J. Joly,
Longmans, Green, and Co., 1899.
\PMlinkexternal{Internet Archive scan}{https://archive.org/details/elementsofquater01hamiuoft}

\bibitem{Joly1905}
C. J. Joly,
\emph{A Manual of Quaternions}, Macmillan and Co., London, 1905.
\PMlinkexternal{Internet Archive search}{https://archive.org/search?query=A+Manual+of+Quaternions+Joly}

\bibitem{KellandTait1882}
P. Kelland and P. G. Tait,
\emph{Introduction to Quaternions, with Numerous Examples}, 2nd ed.,
Macmillan and Co., London, 1882.
\PMlinkexternal{Internet Archive search}{https://archive.org/search?query=Introduction+to+Quaternions+Kelland+Tait}

\bibitem{Hathaway1896}
A. S. Hathaway,
\emph{A Primer of Quaternions}, 1896.
\PMlinkexternal{Project Gutenberg edition}{https://www.gutenberg.org/ebooks/9934}

\end{thebibliography}

\section*{License}

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