# Multiplication order for difference between two quaternions

Given two normalized quaternions $$p$$ and $$q$$, what do the following products compute, in terms of relative differences in rotation between the two quaternions?

• $$qp^{-1}$$
• $$q^{-1}p$$
• $$pq^{-1}$$
• $$p^{-1}q$$

I assume one of these represents the relative rotation from $$p$$ to $$q$$, but I have seen conflicting information about which of these formulas represents that difference. I assume that $$p^{-1}q \neq qp^{-1}$$, because otherwise this would imply that $$q = pqp^{-1}$$ (and also because rotations do not commute).

Second question: how should $$pqp^{-1}$$ and $$p^{-1}qp$$ be interpreted?

• I have seen conflicting information about which of these formulas represents that difference - The key point is that you need to understand precisely how you are representing a rotation as a quaternion. There are different ways to do this which leads to different interpretations of what $p$ or $pq$ means. Aug 4, 2020 at 14:39
• @Kimball can you please elaborate? Aug 6, 2020 at 3:20
• For instance, in the answer below $v \mapsto p v p^{-1}$ is the representation used, but you could also do $v \mapsto p^{-1} v p$. See also math.stackexchange.com/q/331539/11323 and math.stackexchange.com/q/3682934/11323. Aug 6, 2020 at 12:43

For me, a quaternion is a scalar plus a 3D vector. These can be called the real and imaginary parts.

Perpendicular vectors anticommute (i.e. $$\mathbf{uv}=-\mathbf{vu}$$) and parallel vectors commute. Scalars are central; they commute with everything. The square roots of $$1$$ are scalars $$\pm1$$ and the square roots of $$-1$$ are precisely the unit 3D vectors. The absolute value of a quaternion $$p=a+\mathbf{v}$$ is $$|p|=\sqrt{a^2+\|\mathbf{v}\|^2}$$. This is multiplicative, i.e. $$|pq|=|p||q|$$ for all $$p,q$$. Every nonzero quaternion has a polar form $$r=e^{\theta\mathbf{u}}=r(\cos\theta+\sin\theta\mathbf{u})$$ where $$r=|p|$$ is the magnitude, $$\theta$$ is a convex angle, and $$\mathbf{u}$$ is $$p$$'s normalized imaginary part. (This is unique except if $$p$$ is one of $$-1,0,1$$.)

Incidentally, how should $$pqp^{-1}$$ be interpreted?

If $$\mathbf{v}$$ is a 3D vector and $$p=re^{\theta\mathbf{u}}$$ then $$p\mathbf{v}p^{-1}$$ is $$\mathbf{v}$$ rotated around the oriented $$\mathbf{u}$$-axis by $$2\theta$$. Note there is some redundancy: $$r$$ doesn't matter and $$\pm p$$ effect the same rotation. Thus $$pqp^{-1}$$ will have the effect of rotating $$q$$'s imaginary part by $$2\theta$$ around $$p$$'s imaginary part (as an axis).

4D rotations, interpreted as functions which turn quaternions into quaternions, are all of the form $$x\mapsto axb$$ for unit quaternions $$a$$ and $$b$$, with some redundancy: $$(a,b)$$ and $$(-a,-b)$$ effect the same rotation.

Given any two unit quaternions $$p$$ and $$q$$, there will be infinitely many 4D rotations that turn $$p$$ into $$q$$ or vice-versa. The ones which are left or right multiplications are unique, though: for mapping $$p$$ to $$q$$ they are $$x\mapsto (qp^{-1})x$$ or $$x\mapsto x(p^{-1}q)$$, or for $$q$$ to $$p$$ they are $$x\mapsto (pq^{-1})x$$ or $$x\mapsto x(q^{-1}p)$$, respectively. In some sense, these are not "minimum energy," or the most efficient, rotations that do this (but nor are they quite the "maximum energy" ones either...).

The "minimum energy" rotation turning $$p$$ into $$q$$ is "halfway" between these, however: it is given by the expression $$x\mapsto \sqrt{qp^{-1}}x\sqrt{p^{-1}q}$$, where square roots are taken by halving convex angles in polar form, which I discuss in my answer here.

In 3D we can think of the "energy" of a rotation as the size of the (convex) angle it rotates by - the bigger the angle the greater the energy. Given two 3D unit vectors $$\mathbf{u}$$ and $$\mathbf{v}$$ (distinct, not antipodal), the "maximum energy" rotation is by $$180^{\circ}$$ around midpoint between them, and "minimum energy" rotation is by the angle between them around the axis perpendicular to the plane they span.

In 4D, every rotation is by two angles in two orthogonal planes (uniquely determined if the convex angles are distinct), and the "energy" is an increasing function of both angles. More precisely, we can measure the "energy" of a rotation matrix $$R$$ as $$\|R-I\|^2$$ where $$I$$ is the identity matrix and we use the Frobenius norm $$\|A\|^2=\mathrm{tr}(A^TA)=\sum |a_{ij}|^2$$.

• They do rotate $p$ to $q$ along different paths. Which means they don't "represent the same rotation," they are different rotations even though they both slide $p$ to $q$.
– anon
Aug 4, 2020 at 7:16
• No. Left-multiplying by $qp^{-1}$ or right-multiplying by $p^{-1}q$ will both turn $p$ into $q$, but in general these are still different rotations! If by "same effectual rotation" you merely mean they move $p$ to the same place, then sure, but that should be phrased as "have the same effect on $p$" since they still have different effects on other points besides $p$! Similarly for left-multiplying by $pq^{-1}$ and right-multiplying by $q^{-1}p$ both moving $q$ to $p$; these don't move other points to the same place as they do for $q$.
– anon
Sep 4, 2020 at 4:12
• No. Left-multiplication-by-$a$ means the function $L_a(x):=ax$ and right-multiplying-by-$b$ means the function $R_a(x):=xa$. Of course, the conjugation action $C_a(x)=(L_a\circ R_a^{-1})(x)=axa^{-1}$ is important for 3D rotations, but both left and right multiplications independently are important for 4D rotations. I am saying $L_{qp^{-1}}(p)=q$ and $R_{p^{-1}q}(p)=q$, but I am not saying $L_{qp^{-1}}(v)=R_{p^{-1}q}(v)$ for all $v$! Similarly $L_{pq^{-1}}(q)=p$ and $R_{q^{-1}p}(q)=p$ but $L_{pq^{-1}}\ne R_{q^{-1}p}$ are not the same function.
– anon
Sep 4, 2020 at 5:01
• Also, none of these four quotients conjugate $p$ to $q$ or vice-versa; as I pointed out in my answer, you have to take the square root for that, because conjugating by a versor rotates by twice the angle in that versor's polar form ("versor" means "unit quaternion" which has polar form $e^{\theta\mathbf{u}}$).
– anon
Sep 4, 2020 at 5:04
• Suppose $p=\exp(\theta{\bf u})$ with $\mathbf{u}$ a unit vector and $\theta$ convex. Extend $\{{\bf u}\}$ to an ordered, oriented basis $\{{\bf u},{\bf v},{\bf w}\}$ of $\Bbb R^3$. Both $L_p$ and $R_p$ rotate by $\theta$ in the $1{\bf u}$-plane and the $\bf vw$-plane, however $R_p$ rotates the opposite direction in the latter plane (i.e. from ${\bf v}$ towards $-\bf w$). These are called "left isoclinic" and "right isoclinic" rotations respectively. Inverting $R_p$ and combining them for conjugation makes them cancel in the $1{\bf u}$-plane and double in the other...
– anon
Sep 5, 2020 at 6:28