Quaternion Calculator

Multiply, add, divide or conjugate quaternions, find the magnitude, or rotate a 3D vector with a unit quaternion.

Math and PercentUpdated 2026-11-184 min read
Quaternion Calculator
Used for multiply, add, subtract and divide; ignored otherwise.
Used for the rotate operation only. q1 is normalised first.
Result
...
Scalar component...
i component...
j component...
k component...
Magnitude of the result...

What it does

Quaternions extend the complex numbers from two dimensions to four. A quaternion has one real part and three imaginary parts, written w + xi + yj + zk, where i, j and k are distinct square roots of minus one. They were introduced by William Rowan Hamilton in 1843 and are now a standard tool in computer graphics, robotics and flight software because they describe rotations without the gimbal lock that troubles Euler angles.

The multiplication rules follow from i squared = j squared = k squared = i j k = -1. From that single relation come ij = k, jk = i, ki = j and the reversed products with a minus sign. The Carnegie Mellon lecture notes derive these in a few lines and then show that the product of two quaternions combines a dot product and a cross product of the vector parts. That mix is why multiplication is associative but not commutative.

The conjugate flips the sign of the vector part, and the magnitude is the square root of the sum of the four squares. MIT notes by Berthold Horn show that the product of a quaternion with its conjugate is its squared magnitude, which gives the inverse directly: divide the conjugate by that squared magnitude. Division by zero is therefore impossible, and the tool refuses a second quaternion of zero magnitude.

For rotations, the vector to be turned is treated as a pure quaternion with zero real part. If q is a unit quaternion, the product q v q* is another pure quaternion holding the rotated vector. Cornell University lecture notes explain that q and minus q describe the same rotation, and that composing two rotations is just multiplying their quaternions. The tool normalises q1 before rotating so a non-unit input still gives a pure rotation.

Choose an operation, enter the components and read the result both as a single expression and as four separate numbers. The magnitude shown is that of the result, which for a product equals the product of the two input magnitudes. That identity is a quick way to spot an arithmetic slip.

How to use

  1. Pick the operation from the first menu: multiply, add, subtract, divide, conjugate, magnitude or rotate.
  2. Enter the scalar and i, j, k components of q1. The four defaults are 1, 2, 3 and 4.
  3. For multiply, add, subtract and divide, also enter the four components of q2. Defaults are 5, 6, 7 and 8.
  4. For rotate, enter the x, y and z components of the vector instead. The defaults rotate the x unit vector.
  5. Read the main result in w + xi + yj + zk form, or as a coordinate triple in rotate mode.
  6. Use the four component fields and the magnitude to check the answer, for example by confirming that a product's magnitude equals the product of the input magnitudes.

Formula

Product: q1 q2 = (w1 w2 - x1 x2 - y1 y2 - z1 z2) + (w1 x2 + x1 w2 + y1 z2 - z1 y2) i + (w1 y2 - x1 z2 + y1 w2 + z1 x2) j + (w1 z2 + x1 y2 - y1 x2 + z1 w2) k. Conjugate: w - xi - yj - zk. Magnitude: sqrt(w squared + x squared + y squared + z squared). Rotation: v' = q v q conjugate.
w
Scalar, or real, part of the quaternion.
x, y, z
Components of the vector part, along i, j and k.
q*
Conjugate of q, with the vector part negated.
|q|
Magnitude, the square root of the sum of the four squared components.
v
A 3D vector written as 0 + xi + yj + zk during a rotation.

Addition and subtraction act component by component. Division is multiplication by the inverse, which is the conjugate divided by the squared magnitude of the divisor. For a rotation the tool first divides q1 by its magnitude, then applies q v q*, so q1 need not be a unit quaternion. The result of a rotation has zero scalar part apart from rounding, which the tool sets to zero.

Worked example

Example: multiplying two quaternions

Defaults: operation multiply, q1 = 1 + 2i + 3j + 4k and q2 = 5 + 6i + 7j + 8k.

  1. Scalar part: 1 x 5 - 2 x 6 - 3 x 7 - 4 x 8 = 5 - 12 - 21 - 32 = -60.
  2. i part: 1 x 6 + 2 x 5 + 3 x 8 - 4 x 7 = 6 + 10 + 24 - 28 = 12.
  3. j part: 1 x 7 - 2 x 8 + 3 x 5 + 4 x 6 = 7 - 16 + 15 + 24 = 30.
  4. k part: 1 x 8 + 2 x 7 - 3 x 6 + 4 x 5 = 8 + 14 - 18 + 20 = 24.
  5. So the product is -60 + 12i + 30j + 24k.
  6. Magnitude: sqrt(3600 + 144 + 900 + 576) = sqrt(5220) = 72.249567. As a check, sqrt(30) x sqrt(174) gives the same number.
  7. The tool shows -60 + 12i + 30j + 24k, components -60, 12, 30, 24 and magnitude 72.249567.

Reference table

Products of the basis units i, j and k
Row x columnijk
i-1k-j
j-k-1i
kj-i-1

Limits

  • Works with real components only. Quaternions over other number systems are outside its scope.
  • The rotation mode treats q1 as an axis-angle rotation and normalises it, so any uniform scale on q1 is discarded.
  • It does not interpolate between rotations, which needs a separate slerp routine.
  • Very large components near the 1,000,000 cap can lose precision in the magnitude because the squares are large.

Common mistakes

  • Assuming q1 q2 equals q2 q1. Only real quaternions commute with everything.
  • Dividing by the magnitude instead of the squared magnitude when forming an inverse.
  • Rotating with a raw quaternion and forgetting that q and minus q represent the same turn.
  • Reading the displayed magnitude as the magnitude of q1 when the operation is a product.
  • Entering a zero quaternion as the divisor, which has no inverse.

Try it yourself

Quick checks. Answers sit tucked under each question.

Add 1 + 2i + 3j + 4k and 5 + 6i + 7j + 8k. What is the magnitude?

Component by component the sum is 6 + 8i + 10j + 12k. The magnitude is sqrt(344) = 18.547237.

What are the conjugate and magnitude of 1 + 2i + 3j + 4k?

The conjugate is 1 - 2i - 3j - 4k and the magnitude is sqrt(30) = 5.477226.

Rotate the vector (1, 0, 0) using q1 = 1 + 2i + 3j + 4k. What do you get?

After normalising q1 the tool gives (-0.666667, 0.666667, 0.333333). The length stays 1.000000, as a rotation requires.

Questions

What is a quaternion?

A number with one real part and three imaginary parts, written w + xi + yj + zk. The units i, j and k satisfy i squared = j squared = k squared = i j k = -1.

Why use quaternions for rotation?

They avoid gimbal lock, compose by ordinary multiplication and are easy to renormalise. The Cornell notes also point out that q and minus q encode the same orientation, which helps when interpolating.

Is quaternion multiplication commutative?

No. Reversing the order changes the sign of the cross product part, so q1 q2 and q2 q1 usually differ. Reversing two rotations changes the result.

How do I divide by a quaternion?

Multiply by its inverse, which is its conjugate divided by its squared magnitude. The tool does this for the divide operation and rejects a zero divisor.

What does the magnitude of a product equal?

The product of the magnitudes. For the default example sqrt(30) times sqrt(174) equals sqrt(5220), or 72.249567.

Does the rotation mode change the length of the vector?

No. The product q v q* is a rotation, so it preserves length and angles. The magnitude reported after a rotation equals the magnitude of the input vector.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.