# Quaternion Multiplication: What is the correct way of doing it?

I am not very familiar with quaternions, I was just doing a programming homework were I had to implement quaternions' arithmetic, however I got puzzled by the multiplication of 2 quaternions.

Let's say I have the following:

$a = \alpha_1 + \beta_1i+\gamma_1j+\delta_1k$

$b = \alpha_2 + \beta_2i+\gamma_2j+\delta_2k$

I have been given the following rules $i^2=j^2=k^2=-1$, $ik=-j$, $ij=k$, $ji=-k$, $jk = i$, $ki = j$, $kj = -i$

Doing the algebra I get the following expression for the product of a and b:

$$\alpha_1\alpha_2 - \beta_1\beta_2 - \gamma_1\gamma_2 - \delta_1\delta_2 \\ +i(\alpha_1\beta_2+\beta_1\alpha_2+\gamma_1\delta_2-\delta_1\gamma_2)\\ +j(\alpha_1\gamma_2-\beta_1\gamma_2+\gamma_1\alpha_2+\delta_1\beta_2)\\ +k(\alpha_1\delta_2+\beta_1\gamma_2-\gamma_1\beta_2+\delta_1\alpha_2)$$

However, when I looked for documentation on this operation in some languages such as matlab, the quaternion product has other definition:

http://www.mathworks.com/help/aerotbx/ug/quatmultiply.html

So, when I test my implementation against the example given the result is different. So, Why is that? What is the correct definition?

• Just set $a=i,b=k$, so $\beta_1=\delta_2=1$ and all others equal zero. Do you get $ab=ik=-j$? Sep 13, 2015 at 18:56
• $\beta_1$ is represented twice times $\gamma_2$ is this correct? Sep 13, 2015 at 18:57
• Yep. @theREALyumdub, that duplication is the proble. There should be a $\beta_1\delta_2$ somewhere in there, and only one $\beta_1\gamma_2$. Sep 13, 2015 at 18:58
• Does the computation work out correctly now? Sep 13, 2015 at 19:00

Your expression for the $j$ term is wrong. It should be: $$\alpha_1 \gamma_2-\beta_1\delta_2 + \gamma_1 \alpha_2 + \delta_1 \beta_2$$