Welcome to Calcugo'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: 1, i, j, and 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 three-dimensional space. 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 + b i + c j + d k, where a, b, c, and d are arbitrary real numbers and i, j, and 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: 1, i, j, and k. The three letters don't stand for any particular value: they simply denote independent base vectors. Nevertheless, if i seems familiar, it well should! In fact, if the coefficients of j and k (i.e., c and d) are both zero, then we obtain the well-known complex numbers — so quaternions are indeed their extension.
Adding and subtracting quaternions
This one's easy. Recall that quaternions are spanned by four base elements: 1, i, j, and 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.
Formally, if p = a₁ + b₁ i + c₁ j + d₁ k and q = a₂ + b₂ i + c₂ j + d₂ k, then:
p + q = (a₁+a₂) + (b₁+b₂) i + (c₁+c₂) j + (d₁+d₂) k
Subtraction works exactly the same, only with minus signs instead of pluses.
Quaternion multiplication and division
Now the fun begins. Quaternion multiplication is not commutative: in general, p·q ≠ q·p. It is governed by Hamilton's famous rules:
i² = j² = k² = ijk = −1
ij = k, jk = i, ki = j(andji = −k,kj = −i,ik = −j)
Expanding the product p·q using these rules gives the Hamilton product:
a = a₁a₂ − b₁b₂ − c₁c₂ − d₁d₂
b = a₁b₂ + b₁a₂ + c₁d₂ − d₁c₂
c = a₁c₂ − b₁d₂ + c₁a₂ + d₁b₂
d = a₁d₂ + b₁c₂ − c₁b₂ + d₁a₂
Division follows from multiplication. To divide p by q, we multiply p by the inverse of q: that is, p / q = p · q⁻¹. Because multiplication isn't commutative, dividing on the left (q⁻¹ · p) can give a different result — our calculator uses the right-division convention p · q⁻¹.
The magnitude, conjugate, inverse, and matrix representation
Several key quantities describe a single quaternion q = a + b i + c j + d k:
- Magnitude (norm):
|q| = √(a² + b² + c² + d²)— the length of the quaternion as a 4D vector. - Conjugate:
q* = a − b i − c j − d k— flip the sign of the three imaginary parts. - Inverse:
q⁻¹ = q* / |q|²— the conjugate divided by the norm squared. It satisfiesq · q⁻¹ = 1. - Matrix representation: every quaternion can be written as a 4×4 real matrix
, turning quaternion multiplication into ordinary matrix multiplication.
3D geometry: quaternion rotation
The most celebrated use of quaternions is describing rotations in three dimensions. A unit quaternion (one with |q| = 1) encodes a rotation by angle θ about a unit axis (x, y, z) as:
q = cos(θ/2) + sin(θ/2)·(x i + y j + z k)
To rotate a 3D point v, we treat it as a pure quaternion and compute q · v · q⁻¹. Compared with rotation matrices and Euler angles, quaternions are compact, avoid gimbal lock, and combine smoothly — which is why they power computer graphics, robotics, spacecraft attitude control, and game engines. Our calculator recovers the rotation angle, the rotation axis, and the equivalent 3×3 rotation matrix from the quaternion you enter as p.
Example: using the quaternion calculator
Say we want to multiply p = 1 + 2i + 3j + 4k by q = 5 + 6i + 7j + 8k.
- Choose Multiply (p × q) as the operation.
- Enter the four components of
p:1,2,3,4. - Enter the four components of
q:5,6,7,8. - Read the answer:
p · q = −60 + 12i + 30j + 24k. The calculator also reports each quaternion's magnitude, conjugate, and inverse, the 4×4 matrix representation, and the rotation thatprepresents.
Frequently Asked Questions
What is a quaternion?
A quaternion is a four-dimensional number of the form a + b i + c j + d k, where a, b, c, d are real and i, j, k are imaginary units satisfying i² = j² = k² = ijk = −1. Quaternions extend the complex numbers.
Is quaternion multiplication commutative?
No. In general p·q ≠ q·p. Order matters, which is exactly why the Hamilton product has those cross terms and why quaternions can represent 3D rotations so naturally.
How do I find the inverse of a quaternion?
Take the conjugate (flip the signs of i, j, k parts) and divide it by the norm squared: q⁻¹ = q* / |q|². Only the zero quaternion has no inverse.
Why use quaternions instead of Euler angles?
Quaternions avoid gimbal lock, use only four numbers, interpolate smoothly (slerp), and compose rotations by simple multiplication. This makes them the standard tool in 3D graphics, robotics, and aerospace.
Does the unit system change the math?
No — the quaternion algebra is identical. The metric (meters, kilograms, liters) or US customary (feet, pounds, gallons) unit selector simply labels the result so it reads in the units your problem is stated in.