The product of two

quaternions *p* = [

*a* *b* *c* *d* ] =

*a*+

*bi*+

*cj*+

*dk* and

*q* = [

*e* *f* *g* *h* ] =

*e*+

*fi*+

*gj*+

*hk* is given by the quaternion

*p**q*
= (*a*+*bi*+*cj*+*dk*)(*e*+*fi*+*gj*+*hk*)

= (*ae*-*bf*-*cg*-*dh*) + (*af*+*be*+*ch*-*dg*)i + (*ag*-*bh*+*ce*+*df*)j + (*ah*+*bg*-*cf*+*de*)k

= [ (*ae*-*bf*-*cg*-*dh*) (*af*+*be*+*ch*-*dg*) (*ag*-*bh*+*ce*+*df*) (*ah*+*bg*-*cf*+*de*) ].

To

derive this

formula, just remember the rules

*i*^{2} = *j*^{2} = *k*^{2} = -1
*i**j* = -*j**i* = *k*

*j**k* = -*k**j* = *i*

*k**i* = -*i**k* = *j*,

distribute the

multiplication, and

collect terms.