Say we want to combine two complex numbers to give quaternion algebra:

In that case a,b,c and d are complex numbers, lets call them:

ax + i ay, bx + i by, cx + i cy and dx + i dy

so we get:

(ax + i ay,bx + i by)(cx + i cy,dx + i dy) =

((ax + i ay)(cx + i cy) - (dx + i dy)(bx + i by)* ,

(ax + i ay)*(dx + i dy) + (cx + i cy)(bx + i by))

=((ax cx- ay cy + i (ay cx + ay cx) - (dx bx + dy by + i (dy bx- dx by)) ,

ax dx+ i (ax dy- ay dx) + ay dy + cx bx + i (cy bx + cx by) - cy by

=(ax cx- ay cy - dx bx - dy by + i (ay cx + ay cx + dx by - dy bx),

ax dx + ay dy + cx bx - cy by+ i (cy bx + cx by - ay dx+ ax dy))

which gives 4 real numbers:

- ax cx- ay cy - dx bx - dy by
- ay cx + ay cx + dx by - dy bx
- ax dx + ay dy + cx bx - cy by
- cy bx + cx by - ay dx- ax dy

which is the same as quaternion multipication from this page:

z1 * z2= a*e - b*f - c*g- d*h + i (b*e + a*f + c*h - d*g) + j (a*g - b*h + c*e + d*f) + k (a*h + b*g - c*f + d*e)