Omni Calculator logo

Quaternion Calculator

Created by Maciej Kowalski, PhD candidate
Reviewed by Anna Szczepanek, PhD and Steven Wooding
Last updated: Jan 18, 2024


Welcome to Omni's quaternion calculator, where we'll deal with this mysterious extension of complex numbers: the quaternions. In short, we represent them using four real values, each corresponding to one of the basic unity quaternions: 11, i\text i, j\text j, and k\text k. To some, they may seem like an artificial creation to make math even more tricky than it already is. To others, they are a useful tool in 3D geometry: mainly to study quaternion rotation. Unfortunately, this doesn't kill the "tricky" part, and, e.g., quaternion multiplication is not a straightforward operation.

But let's not get ahead of ourselves! We begin with where every math topic begins: with an introduction. In our case, it's the quaternion definition.

The quaternion definition

Quaternions are an extension of complex numbers. They were first introduced by Sir William Hamilton, who used them to describe several properties of the three-dimensional space (for more, see the dedicated section).

However, nowadays, most often, we introduce them from the algebraic point of view. Let's take a look at the formal quaternion definition.

💡 Quaternions are expressions of the form q=a+bi+cj+dkq = a + b \,\text i + c \,\text j + d \, \text k, where aa, bb, cc, and dd are arbitrary real numbers and i\text i, j\text j, and k\text k are base elements sometimes called the basic unity quaternions.

By the above quaternion definition, we see that the space is spanned by four base elements: 11, i\text i, j\text j, and k\text k. The three letters don't stand for any particular value: they simply denote independent base vectors. Nevertheless, if i\text i seems familiar, it well should! In fact, if the coefficients of j\text j and k\text k (i.e., cc and dd in the above quaternion definition) are both zero, then we obtain the (well-known) complex numbers! As such, we indeed obtain their extension.

More or less, Hamilton's idea was to have one expression whose individual parts (i.e., the base elements' coefficients) describe the distinct directions in a three-dimensional space. From there, he only needed to introduce operations between these new thingies. On the one hand, we'd like them to satisfy some properties and form a nice algebraic structure. On the other, the operations should be usable and have real-life explanations. After all, quaternions originated from geometry — a very real-life area of mathematics.

Now that we know what a quaternion is, we can go further. The subsequent sections describe the basic rules governing these numbers. Note how Omni's quaternion calculator lets you find all values and objects we mention. For more information on how to use the tool, see the last section.

Adding and subtracting quaternions

This one's easy. Recall from the above section that quaternions are spanned by four base elements: 11, i\text i, j\text j, and k\text k. As such, if we want to add or subtract two such expressions, we do it the same way as in any vector space: move from one base element to the other and add or subtract the respective coefficients of the two quaternions. And since these coefficients are simply real numbers, it boils down to the very basics of mathematics which we learned in primary school.

(a+bi+cj+di)+(e+fi+gj+hk)=(a+e)+(b+f)i+(c+g)j+(d+h)k(a+bi+cj+di)(e+fi+gj+hk)=(ae)+(bf)i+(cg)j+(dh)k\footnotesize \begin{split} & (a + b\,\text i + c\,\text j + d\,\text i) + (e + f\,\text i + g\,\text j + h\,\text k) = \\ &(a + e) + (b + f)\,\text i + (c + g)\,\text j + (d + h)\,\text k \\[1.5em] & (a + b\,\text i + c\,\text j + d\,\text i) - (e + f\,\text i + g\,\text j + h\,\text k) = \\ &(a - e) + (b - f)\,\text i + (c - g)\,\text j + (d - h)\,\text k \end{split}

Plain sailing, wouldn't you say? Such addition satisfies all the reasonable properties: it's associative, commutative, and every quaternion qq has its opposite q-q such that q+(q)=(q)+q=0q + (-q) = (-q) + q = 0.

Unfortunately, the story is a bit more difficult for multiplication and even more so for division.

Quaternion multiplication and division

In real and complex numbers, we got used to the distributive property of multiplication over addition, so we'd like to have a similar law here. After all, quaternions are sums of four elements: the real part and the i\text i, j\text j, and k\text k parts. In other words, we want to have:

(a+bi+cj+dk)(e+fi+gj+hk)=a(e+fi+gj+hk)+bi(e+fi+gj+hk)+cj(e+fi+gj+hk)+dk(e+fi+gj+hk)\footnotesize \begin{split} &(a + b\,\text i + c\,\text j + d\,\text k) \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &= a \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &+ b\,\text i \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &+ c\,\text j \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ &+ d\,\text k \cdot (e + f\,\text i + g\,\text j + h\,\text k) \\ \end{split}