# Error performing multiplication of Quaternions

Alright I'm going to try one last time to explain my problem with quaternions and multiplication of two quaternions in specific. This time hopefully I'll get an explanation that makes sense. (I posted 2 other versions of this question before that I wasn't happy with so I scrapped them)

Assume we have a quaternion $q \in \Bbb{H}$, where $q = w + xi + yj + zk$ with $w, x, y, z \in \Bbb{R}$. We can represent this quaternion in terms of an ordered pair $[s, v]$ where $s$ is the scalar component (i.e. $s = w$) and $v$ is a vector in $\Bbb{R}^3$ such that $v = xi + yj + zk$.

Now, moving on to the derivation of multiplication of two quaternions. Assuming we had $q_a = [s_a, a]$ and $q_b = [s_b, b]$.

$$q_aq_b = [s_a, a][s_b, b] = (s_a + x_ai + y_aj + z_ak)(s_b + x_bi + y_bj + z_bk) \\ = (s_as_b + s_ax_bi + s_ay_bj + s_az_bk) + (s_bx_ai - x_ax_b + x_ay_bk - x_az_bj) + (s_by_aj - y_ax_bk - y_ay_b + y_az_bi) + (s_bz_ak + z_ax_bj - z_ab_yi - z_az_b)$$

$$= (s_as_b - x_ax_b - y_ay_b - z_az_b) + (s_ax_b + s_bx_a + y_az_b - z_ay_b)i + (s_ay_b - x_az_b + s_by_a + z_ax_b)j + (s_az_b + x_ay_b - y_ax_b + s_bz_a)k$$

$$= (s_as_b - x_ax_b - y_ay_b - z_az_b) + s_a(x_bi + y_bj + z_bk) + s_b(x_zi + y_aj + z_ak) + (y_az_b - z_ay_b)i + (z_ax_b - x_az_b)j + (x_ay_b - y_ax_b)k$$ $$= [s_as_b - x_ax_b - y_ay_b - z_az_b, s_a(x_bi + y_bj + z_bk) + s_b(x_zi + y_aj + z_ak) + (y_az_b - z_ay_b)i + (z_ax_b - x_az_b)j + (x_ay_b - y_ax_b)k]$$ $$= [s_as_b - x_ax_b - y_ay_b - z_az_b, s_ab + s_ba + a \times b]$$ Where $a \times b$ denotes the cross product between $a$ and $b$. So far so good, maybe a little messy but we're getting somewhere. The thing that confuses me now is simplification of the scalar component of the result ordered pair (which is $s_as_b - x_ax_b - y_ay_b - z_az_b$).

One can observe that this is incredibly close to the dot product of $a$ and $b$: $$a \cdot b = x_ax_bi^2 + y_ay_bj^2 + z_az_bk^2 \\ = -x_ax_b - y_ay_b - z_az_b$$ This is because $$i^2 = j^2 = k^2 = ijk = -1$$ Thus, the scalar component of the ordered pair should be equal to $s_as_b + a \cdot b$, right? WRONG

According to here, here, here, and any other resource you can find, the scalar component of $q_aq_b$ would ACTUALLY be $s_as_b - a \cdot b$. This doesn't make a lick of sense to me. All the terms in $a \cdot b$ are already negative, so negating them again would only make them positive, giving you $s_as_b + x_ax_b + y_ay_b + z_az_b$, which is not what the calculations above revealed. What am I doing wrong? What am I missing? It feels like it's such an obvious step that I'm missing but I just can't figure it out.

## 1 Answer

When you evaluate $a\cdot b$ you're assuming that $a=x_a i + y_a j + z_a k$ which is wrong. $a$ and $b$ are real vectors.

If it were true that $v=xi+yj+zk$ then you could write $q=s+v$. So why would you write $q=[s,v]$? The reason is because this particular notation takes a scalar $s$ and a real vector $v=(x,y,z)$.

• OHHHHHHHHHHHHHHHHHH. I think I got confused when I read at 3dgep.com/?p=1815#Quaternion_Products that $a \cdot b$ = $x_ax_bi^2 + y_ay_bj^2 + z_az_bk^2$ which is clearly written there, so that must've been an error on the writer's part. Thanks for clarifying that! – user3002473 Jun 22 '14 at 10:43
• You're welcome. What doesn't help is that $i$, $j$, and $k$ are used to mean two different things. When representing a real vector, $v=xi+yj+zk$, they are unit vectors with the properties $i^2=j^2=k^2=1$. It's only in the context of quaternions that they adopt the $i^2=j^2=k^2=-1$ rule. – lemon Jun 22 '14 at 10:45
• So what would that mean about the vector component of $q_aq_b$? Which parts of the expression $s_ab + s_ba + a \times b$ would become the $i$, $j$, and $k$ components respectively? – user3002473 Jun 22 '14 at 10:52
• Since $a$ and $b$ are real vectors, the result of $s_ab+s_ba+a\times b$ will also be a real vector so you evaluate it in the usual way (i.e. with $i^2=...=+1$). Suppose the result is $(u,v,w)$ then you get $[s,(u,v,w)] = s + ui + vj + wk$ where, in this context, $i^2=...=-1$. – lemon Jun 22 '14 at 10:56