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

Meta

Talkback

Downloads

Information
[parent] example of quaternion product (Example)

Quaternion Product in Scalar Vector Form: Examples, Exercises, and Solutions

This entry is the self study companion to quaternion product in scalar vector Form.

The emphasis is the Hamilton product itself: how its scalar and vector pieces arise, why the cross product sign determines the multiplication convention, and how noncommutativity is encoded geometrically.

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

1 Formula summary

Write

p = pw + p,     q = qw + q,

where pw,qw and p,q are pure quaternions identified with three dimensional vectors.

PhysicsLibrary uses the Hamilton product

pq = (pwqw −  p ⋅ q) + (pwq + qwp + p × q).
(1)

Equivalently,

(pw,p )(qw,q) = (pwqw −  p ⋅ q, pwq + qwp + p × q).
(2)

For pure quaternions,

ab  = − a ⋅ b + a × b.
(3)

Reversing the factors gives

qp = (pwqw −  p ⋅ q) + (pwq + qwp − p × q).
(4)

Therefore the commutator is

[p,q] = pq − qp = 2p × q.
(5)

The symmetric combination is

pq + qp = 2 (pwqw − p ⋅ q ) + 2 (pwq + qwp ).
(6)

2 Exercises

  1. Derive the pure quaternion product.

    Let

    a = axi + ayj + azk

    and

    b = bxi + byj + bzk.

    Starting from Hamilton’s basis products, derive

    ab  = − a ⋅ b + a × b.

    Identify the scalar and vector parts explicitly.

  2. Product from scalar and vector parts.

    Let

    p = 2 + i − 2j + k

    and

    q = − 1 + 3i + 2k.

    Compute pq using the scalar vector formula rather than a sixteen term component expansion.

  3. Reverse the product efficiently.

    For the quaternions in Exercise 2, compute qp without repeating the full calculation.

    Use the symmetry of the dot product and antisymmetry of the cross product.

  4. Commutator.

    Using the same p and q, compute

    [p,q] = pq − qp

    both from the two products and directly from

    [p,q] = 2p × q.

    Verify agreement.

  5. Anticommutator.

    Define

    {p, q} = pq + qp.
    (7)

    Derive the scalar vector formula for {p,q} and evaluate it for the quaternions in Exercise 2.

    Which geometric term disappears?

  6. Pure quaternion square.

    Use the scalar vector product to prove

    a2 = − ∥a∥2

    for every pure quaternion a.

    What follows when a= 1?

  7. Perpendicular pure quaternions.

    Suppose

    a ⋅ b = 0.

    Show that

    ab =  a × b

    and

    ba =  − a × b.

    Use

    a = 2i + j,    b =  i − 2j

    as a numerical example.

  8. Parallel pure quaternions.

    Let

    b = λa.

    Show that ab is purely real.

    Then evaluate

    (2i − j + 2k )(6i − 3j + 6k).
  9. Geometric angle encoded in a pure product.

    Let a and b be unit pure quaternions separated by an angle γ.

    Show that

    ab = − cos γ + ^n sin γ,
    (8)

    where n points in the direction of a × b.

    Evaluate the result for γ = 60 and n = k.

  10. When do two quaternions commute?

    Starting from

    [p,q] = 2p × q,

    prove that

    pq = qp

    if and only if the vector parts p and q are parallel, antiparallel, or one vector part is zero.

  11. A complex subalgebra.

    Let u be a fixed unit pure quaternion, and let

    p = a + bu,     q = c + du.

    Show directly that

    pq = (ac − bd) + (ad +  bc)u.

    Then show that pq = qp.

    Explain why this set is algebraically equivalent to the complex numbers.

  12. Component formula recovery.

    Starting from

    pq = (pwqw − p ⋅ q, pwq + qwp + p × q ),

    derive the scalar first component formula

            ⌊ p q  − p q  − p q  − p q ⌋
        |  w w    x x    y y    z z|
[pq]PL = | pwqx + pxqw + pyqz − pzqy| .
        ⌈ pwqy − pxqz + pyqw + pzqx⌉
          pwqz + pxqy − pyqx + pzqw
    (9)

  13. Left multiplication matrix.

    For a fixed quaternion

    p = pw +  pxi + pyj + pzk,

    show that left multiplication can be written

    [pq]PL = L (p)[q]PL,
    (10)

    where

           ⌊ p   − p   − p   − p ⌋
       |  w     x     y     z|
L (p ) = | px  pw   − pz   py | .
       ⌈ py   pz    pw   − px⌉
         pz  − py   px    pw
    (11)

  14. Right multiplication matrix.

    For fixed q, derive a matrix R(q) satisfying

    [pq]PL = R (q)[p]PL.
    (12)

    Compare the signs in R(q) with those in L(q).

  15. Associativity as a matrix identity.

    Use the left multiplication matrix to explain why associativity implies

    L(pq) = L (p)L(q).
    (13)

    Verify this identity numerically for

    p = 1 + i,    q = 1 + j.
  16. Hamilton versus flipped multiplication diagnostic.

    A source defines

    (pw,p ) ⋆ (qw,q) = (pwqw − p ⋅ q, pwq + qwp − p × q) .
    (14)

    Does agree with PhysicsLibrary Hamilton multiplication?

    Show that

    p ⋆ q = qp

    when the right hand side uses Hamilton multiplication.

  17. Passive attitude does not change Hamilton multiplication.

    PhysicsLibrary later represents a positive passive frame rotation about +z by

    q  = 1√−-k-.
 P      2

    A student argues that because the attitude convention is passive, PhysicsLibrary should replace the +p × q term in the Hamilton product by a minus sign.

    Explain why this reasoning is incorrect.

    Use the basis check

    ij

    to show what would break if the multiplication law were changed.

3 Solutions

Solution 1: derive the pure quaternion product

Expand without changing factor order:

ab =  axbxi2 + axbyij + axbzik
                      2
      +  aybxji + aybyj + aybzjk
      +  azbxki + azbykj + azbzk2.

Use

i2 = j2 = k2 = − 1,

ij = k,    jk =  i,     ki = j,

and the reversed negative products.

The scalar terms are

− axbx − ayby − azbz = − a ⋅ b.

The i coefficient is

a b −  a b .
 y z    z y

The j coefficient is

azbx − axbz.

The k coefficient is

axby − aybx.

These are exactly the components of a × b.

Therefore

ab  = − a ⋅ b + a × b.
(15)

The scalar part is a b and the vector part is a × b.

Solution 2: product from scalar and vector parts

Write

                ⌊    ⌋
                   1
pw = 2,     p = ⌈ − 2⌉ ,
                   1

and

                  ⌊ 3⌋
                  ⌈  ⌉
qw = − 1,     q =   0  .
                    2

The dot product is

p ⋅ q = 1 (3 ) + (− 2)(0) + 1 (2 ) = 5.

The cross product is

        ⌊    ⌋
          − 4
p × q = ⌈  1 ⌉ .
           6

The scalar part is

p q  −  p ⋅ q = 2(− 1) − 5 = − 7.
 w w

The vector part is

                       ⌊  ⌋   ⌊    ⌋   ⌊   ⌋
                         3       1       − 4
p  q + q p + p × q =  2⌈ 0⌉ − ⌈ − 2⌉ + ⌈ 1 ⌉
 w      w
                      ⌊  2⌋       1       6
                       1
                   =  ⌈3 ⌉.

                       9

Hence

pq = − 7 + i + 3j + 9k.
(16)

Solution 3: reverse the product efficiently

The scalar part remains unchanged because

q ⋅ p = p ⋅ q.

The scalar multiplication terms in the vector part are also unchanged:

qwp + pwq =  pwq + qwp.

Only the cross product changes sign:

                   ⌊   ⌋
                     4
q × p = − p × q =  ⌈− 1⌉ .

                    − 6

Thus the vector part of qp is

                        ⌊   ⌋     ⌊  ⌋   ⌊    ⌋
                          1         3      4
qwp +  pwq + q × p =  − ⌈− 2⌉ +  2⌈ 0⌉ + ⌈ − 1 ⌉
                          1         2      − 6
                      ⌊   ⌋
                        9
                   =  ⌈ 1 ⌉ .
                       − 3

Therefore

qp = − 7 + 9i + j − 3k.
(17)

Solution 4: commutator

From Solutions 2 and 3,

[p,q] = pq − qp

     =  (− 7 + i + 3j + 9k ) − (− 7 + 9i + j − 3k ).

Thus

[p,q] = − 8i + 2j + 12k.
(18)

Directly,

           ⌊    ⌋   ⌊    ⌋
             − 4      − 8
2p × q =  2⌈  1 ⌉ = ⌈  2 ⌉ ,

              6       12

which gives the same pure quaternion.

Solution 5: anticommutator

Add the general products:

pq = (pwqw −  p ⋅ q, pwq + qwp + p × q)

and

qp = (pwqw − p ⋅ q, pwq + qwp − p × q ).

The cross products cancel.

Therefore

{p,q} =  2(pwqw −  p ⋅ q) + 2(pwq + qwp ).
(19)

For Exercise 2,

pq = − 7 + i + 3j + 9k

and

qp = − 7 + 9i + j − 3k.

Thus

{p, q} = − 14 + 10i + 4j + 6k.
(20)

The oriented cross product term disappears from the symmetric combination.

Solution 6: pure quaternion square

Set b = a in

ab  = − a ⋅ b + a × b.

Then

a2 = − a ⋅ a + a × a.

Since

a ⋅ a = ∥a∥2

and

a × a = 0,

we obtain

a2 = − ∥a∥2.
(21)

If a= 1, then

a2 = − 1.
(22)

Solution 7: perpendicular pure quaternions

If

a ⋅ b = 0,

then

ab = a × b.

Reversing the order gives

ba = b ×  a = − a × b.

For

    ⌊  ⌋           ⌊   ⌋
      2              1
a = ⌈ 1⌉ ,    b =  ⌈− 2⌉ ,

      0              0

the dot product is

2(1) + 1(− 2 ) = 0.

The cross product is

        ⌊    ⌋
           0
a × b = ⌈  0 ⌉ .
          − 5

Therefore

ab = − 5k,     ba =  5k.
(23)

Solution 8: parallel pure quaternions

If

b = λa,

then

a × b = λa ×  a = 0.

Thus

ab  = − a ⋅ b,

which is purely real.

For

a = 2i − j + 2k

and

b = 6i − 3j + 6k = 3a,

we have

a ⋅ b = 2(6) + (− 1)(− 3) + 2(6) = 27.

Therefore

ab  = − 27.
(24)

Solution 9: geometric angle encoded in a pure product

For unit vectors,

a ⋅ b = cosγ.

Also,

∥a × b∥ = sin γ.

If n is the unit vector in the direction of the cross product,

a × b = n^sinγ.

Therefore

ab = − cos γ + ^n sin γ.
(25)

For

γ = 60∘,     ^n = k,

we get

            √ --
        1     3
ab =  − --+ ---k.
        2    2
(26)

Solution 10: when do two quaternions commute?

The commutator is

[p,q] = 2p × q.

Therefore

pq = qp

if and only if

p ×  q = 0.

In three dimensional Euclidean space, a cross product is zero exactly when the vectors are linearly dependent or one is zero.

Thus the vector parts must be parallel, antiparallel, or one vector part must vanish.

Hence

pq = qp   ⇐ ⇒    p × q =  0.
(27)

Solution 11: a complex subalgebra

Let

p = a + bu,     q = c + du,

with

  2
u  =  − 1.

Multiply:

pq = ac + adu + bcu +  bdu2

   = (ac − bd) + (ad +  bc)u.

Therefore

pq = (ac − bd) + (ad +  bc)u.
(28)

Reversing the factors gives

qp = (ca − db) + (cb + da)u.

Real coefficients commute, so

qp = pq.

The map

a + bu ← →  a + bi
                  ℂ

preserves addition and multiplication because both imaginary units square to 1.

Thus this two dimensional quaternion subalgebra is isomorphic to the complex numbers.

Solution 12: component formula recovery

The scalar part is

pwqw − (pxqx + pyqy + pzqz),

so the first component is

pwqw − pxqx − pyqy − pzqz.

For the vector part,

pwq +  qwp + p × q,

the cross product is

        ⌊            ⌋
          pyqz − pzqy
p × q = ⌈ pzqx − pxqz⌉ .
          pxqy − pyqx

Add the scalar multiple terms componentwise.

The i component becomes

pwqx + pxqw + pyqz − pzqy.

The j component becomes

pwqy − pxqz + pyqw + pzqx.

The k component becomes

p q  + p q −  p q +  p q .
 w z    x y    y x    z w

Therefore

        ⌊ p q  − p q  − p q  − p q ⌋
        |  w w    x x    y y    z z|
[pq]PL = | pwqx + pxqw + pyqz − pzqy| .
        ⌈ pwqy − pxqz + pyqw + pzqx⌉
          pwqz + pxqy − pyqx + pzqw
(29)

Solution 13: left multiplication matrix

Start from the component formula for pq and collect coefficients multiplying

q  ,  q ,  q ,  q .
 w     x    y    z

The scalar component is

pwqw − pxqx − pyqy − pzqz.

The i component is

pxqw + pwqx − pzqy + pyqz.

The j component is

p q  + p q +  p q  − p q .
 y w    z x    w y    x z

The k component is

pzqw − pyqx + pxqy + pwqz.

Hence

         ⌊                    ⌋
          pw   − px − py  − pz
         ||px   pw   − pz   py ||
[pq]PL = ⌈py    pz   pw   − px⌉ [q]PL.
          p    − p   p     p
            z     y   x     w
(30)

Thus

       ⌊ pw  − px  − py  − pz⌋
       |                     |
L (p ) = | px  pw   − pz   py | .
       ⌈ py   pz    pw   − px⌉
         pz  − py   px    pw
(31)

Solution 14: right multiplication matrix

Now collect the component formula for pq by coefficients of the components of p.

The result is

        ⌊                    ⌋
         qw  − qx  − qy  − qz
        |qx   qw    qz   − qy|
R (q) = |⌈                    |⌉,
         qy  − qz   qw    qx
         qz   qy   − qx   qw
(32)

so that

[pq]PL = R (q)[p]PL.
(33)

Compare R(q) with

        ⌊                   ⌋
         qw  − qx  − qy  − qz
        ||qx   qw   − qz   qy||
L (q) = ⌈qy   qz    qw   − qx⌉ .

         qz  − qy   qx   qw

The scalar row is identical, but the signs associated with the cross product structure differ. This is the matrix manifestation of left versus right Hamilton multiplication.

Solution 15: associativity as a matrix identity

For any quaternion r,

L(pq)[r]  =  [(pq)r]  .
       PL          PL

Associativity gives

(pq)r = p(qr).

Therefore

[(pq )r]  = L (p)L(q)[r]  .
      PL              PL

Since this holds for every r,

L(pq) = L (p)L(q).
(34)

For

p = 1 + i,    q = 1 + j,

the Hamilton product is

pq = 1 + i + j + k.

Thus

        ⌊                ⌋
          1  − 1 − 1  − 1
L(pq) = || 1  1   − 1   1 || .
        ⌈ 1  1    1   − 1⌉
          1  − 1  1    1

Also,

       ⌊               ⌋
         1  − 1  0   0
       || 1   1   0   0 ||
L (p ) = ⌈ 0  0   1  − 1⌉ ,
         0   0   1   1

and

       ⌊               ⌋
         1   0   − 1  0
L (q ) = || 0  1    0   1|| .
       ⌈ 1   0    1   0⌉
         0  − 1   0   1

Direct matrix multiplication gives

            ⌊                ⌋
             1  − 1  − 1  − 1
            |1   1   − 1   1 |
L(p)L (q) = |⌈                |⌉ = L (pq).
             1   1    1   − 1
             1  − 1   1    1
(35)

Solution 16: Hamilton versus flipped multiplication diagnostic

PhysicsLibrary Hamilton multiplication uses

+p  × q

in the vector part.

The proposed operation uses

− p × q.

Therefore it does not agree with PhysicsLibrary Hamilton multiplication.

Under Hamilton multiplication,

qp = (qwpw − q ⋅ p, qwp + pwq + q × p ).

Use

q ⋅ p = p ⋅ q

and

q × p  = − p × q.

Then

qp = (pwqw − p ⋅ q, pwq + qwp − p × q ).

Hence

p ⋆ q = qp.
(36)

The proposed operation is the reversed Hamilton product.

Solution 17: passive attitude does not change Hamilton multiplication

The passive attitude convention specifies how a quaternion is interpreted as a frame transformation.

Hamilton multiplication specifies the algebra used to multiply quaternion elements.

These are separate choices.

PhysicsLibrary retains

ij = k

whether the quaternion is being used as a passive attitude map, an algebraic quantity, or a pure quaternion encoding a vector.

If the cross product sign were changed merely because an attitude convention was passive, then the pure product rule would become

ij = − i × j = − k.

That would contradict the declared Hamilton basis relation

ij = k.

Thus the later passive attitude quaternion

      1 − k
qP =  -√----
         2

changes the interpretation of the quaternion’s vector sign for a positive frame rotation. It does not change the multiplication law.

4 Compact review

The multiplication companion can be summarized by four identities:

pq = (pwqw − p ⋅ q, pwq + qwp + p × q ),
(37)

ab  = − a ⋅ b + a × b,
(38)

[p,q] = 2p × q,
(39)

and

pq = qp   ⇐ ⇒    p × q =  0.
(40)

The cross product sign is a direct multiplication convention diagnostic: PhysicsLibrary Hamilton multiplication uses the positive sign.

5 Sources and exercise provenance

The exercises and solutions in this companion are newly written or expanded for PhysicsLibrary from the algebra developed in Quaternion Product in Scalar Vector Form.

Hamilton is the foundational source for the quaternion product. Joly and Kelland–Tait provide classical systematic treatments and examples. Sommer and coauthors provide a modern discussion of Hamilton versus reversed quaternion multiplication in engineering applications.

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. Internet Archive search

[4]   H. Sommer, I. Gilitschenski, M. Bloesch, S. Weiss, R. Siegwart, and J. Nieto, “Why and How to Avoid the Flipped Quaternion Multiplication,” Aerospace, vol. 5, no. 3, article 72, 2018. Published under CC BY 4.0. Publisher article

License

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


"example of quaternion product" is owned by bloftin.
(view preamble)
View style:
See Also: quaternion series overview and article guide, Quaternions for Physics and Engineering: Orientation, Notation, and Conventions, quaternion definition and basic algebra, example of quaternion definition and basic algebra, quaternion product, quaternion conjugate, example of quaternion conjugate, quaternion norm, example of quaternion norm, quaternion inverse, example of quaternion inverse, Axis Angle Representation and Unit Quaternion, example of Axis Angle Representation and Unit Quaternion, rotating vectors with quaternions, example of rotating vectors with quaternions, composition of rotations and quaternion order, example of composition of rotations and quaternion order, quaternions and direction cosine matrices, example of quaternions and direction cosine matrices, quaternions and Euler angles, example of quaternions and Euler angles, quaternion kinematics and angular velocity, example of quaternion kinematics and angular velocity, relative attitude and error quaternions, example of relative attitude and error quaternions, numerical quaternion propagation and IMU attitude state integration, example of numerical quaternion propagation and IMU attitude state integration, quaternion exercises for physics and engineering

Keywords:  quaternion, Hamilton product, scalar vector form, dot product, cross product, pure quaternion, commutator, noncommutative algebra, quaternion multiplication, vector analysis, exercises, worked solutions

This object's parent.

Cross-references: relation, algebraic, operation, matrix multiplication, unit vectors, identity, matrix, commute, square, dot product, formula, commutator, quaternions, cross product, vector, scalar, quaternion product
There is 1 reference to this object.

This is version 2 of example of quaternion product, born on 2026-08-28, modified 2026-08-28.
Object id is 1115, canonical name is ExampleOfQuaternionProduct.
Accessed 151 times total.

Classification:
Physics Classification02.10.Hh (Rings and algebras)
 02.10.Ud (Linear algebra)
 02.10.Xm (Multilinear algebra)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

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