Quaternion Calculator

Enter the w, x, y, z components of two quaternions to add, subtract, multiply (Hamilton product), or dot them, and find each one's magnitude and the inverse of quaternion 1.

Quick Facts

Magnitude (norm)
|q| = √(w² + x² + y² + z²)
The quaternion's length in 4D space; used to normalize or invert it.
Conjugate
q* = w − xi − yj − zk
Flip the sign of the vector part; this is the first step in building the inverse.
Inverse
q⁻¹ = q* / |q|²
Only defined for a nonzero quaternion; satisfies q × q⁻¹ = 1.
Multiplication is non-commutative
q1 × q2 ≠ q2 × q1 (in general)
Because ij = k but ji = −k, the order of multiplication changes the result.

Your Results

Calculated
Operation Result
-
Result of the selected operation above
‖q1‖ Magnitude
-
√(w1² + x1² + y1² + z1²)
‖q2‖ Magnitude
-
√(w2² + x2² + y2² + z2²)
q1⁻¹ Inverse
-
Conjugate(q1) / ‖q1‖²

Ready

Enter both quaternions, choose an operation, then press Calculate.

How Quaternion Arithmetic Works

A quaternion extends complex numbers into four dimensions: q = w + xi + yj + zk, where w is the real (scalar) part and x, y, z are the coefficients of the imaginary units i, j, k. Those units satisfy i² = j² = k² = ijk = −1, along with ij = k, jk = i, ki = j (and the reverse products negate: ji = −k, kj = −i, ik = −j). This calculator uses those rules to add, subtract, multiply, or dot two quaternions, and to compute the magnitude and inverse of the first one.

How the calculation works

Enter the four components (w, x, y, z) for quaternion 1 and quaternion 2, then choose an operation. Addition and subtraction just combine matching components: (w1±w2, x1±x2, y1±y2, z1±z2). The dot product w1w2 + x1x2 + y1y2 + z1z2 treats each quaternion as a 4D vector and returns a single scalar. The Hamilton product (true quaternion multiplication) expands q1q2 using the i/j/k rules above, giving w = w1w2 − x1x2 − y1y2 − z1z2, x = w1x2 + x1w2 + y1z2 − z1y2, y = w1y2 − x1z2 + y1w2 + z1x2, and z = w1z2 + x1y2 − y1x2 + z1w2. The calculator also reports the magnitude of each quaternion, |q| = √(w² + x² + y² + z²), and the inverse of quaternion 1, q1⁻¹ = q1*/|q1|², where q1* = w1 − x1i − y1j − z1k is the conjugate.

Common mistakes

  • Assuming multiplication commutes: unlike ordinary numbers, q1 × q2 generally does not equal q2 × q1 — the Hamilton product depends on order.
  • Confusing the dot product with the Hamilton product: the dot product returns a single scalar, while the Hamilton product returns another quaternion; they answer different questions.
  • Forgetting the sign flip in the conjugate: only the vector part (x, y, z) changes sign in q* — the real part w stays the same.
  • Trying to invert the zero quaternion: if w = x = y = z = 0, the magnitude is zero and the inverse is undefined (division by zero).

Real-world applications

  • 3D graphics and game engines use unit quaternions to represent rotations without the gimbal lock that can affect Euler angles.
  • Robotics and aerospace attitude-control systems track orientation and angular velocity of vehicles and manipulator arms with quaternions.
  • Animation software uses spherical linear interpolation (SLERP) between quaternions to produce smooth rotational motion between keyframes.
  • Physics and orbital-mechanics simulations use quaternion multiplication to compose sequential rotations efficiently.

Frequently Asked Questions

What is the Hamilton product of two quaternions?
The Hamilton product multiplies two quaternions using i² = j² = k² = ijk = −1, with ij = k, jk = i, ki = j (and the reverse products negate). For q1 = w1+x1i+y1j+z1k and q2 = w2+x2i+y2j+z2k, the product q1q2 = w + xi + yj + zk where w = w1w2 − x1x2 − y1y2 − z1z2, x = w1x2 + x1w2 + y1z2 − z1y2, y = w1y2 − x1z2 + y1w2 + z1x2, and z = w1z2 + x1y2 − y1x2 + z1w2. For q1 = 1+2i+3j+4k and q2 = 5+6i+7j+8k, q1q2 = −60 + 12i + 30j + 24k.
How do you find the magnitude (norm) of a quaternion?
The magnitude is |q| = √(w² + x² + y² + z²), the same Euclidean-length idea as a 4D vector. For q1 = 1+2i+3j+4k, |q1| = √(1+4+9+16) = √30 ≈ 5.477226.
Why isn't quaternion multiplication commutative?
Because the basis vectors satisfy ij = k but ji = −k (and similarly for jk/kj and ki/ik), swapping the order of two quaternions generally changes the vector part of the product, so q1q2 ≠ q2q1. Addition and the dot product are order-independent, but the Hamilton product is not.
How do you compute the inverse of a quaternion?
The inverse is the conjugate divided by the squared magnitude: q⁻¹ = q*/|q|², where q* = w − xi − yj − zk. For q1 = 1+2i+3j+4k, |q1|² = 30, so q1⁻¹ = (1 − 2i − 3j − 4k)/30 ≈ 0.033333 − 0.066667i − 0.1j − 0.133333k. This satisfies q1 × q1⁻¹ = 1, the multiplicative identity.