Quaternion calculator
Compute Hamilton products, sums, differences, quotients, norms, conjugates, inverses, matrix forms, and 3D rotations from one validated model.
Inputs
Use decimal-point notation. Coefficients may be positive, zero, or negative.
The input groups and result details adapt to the selected operation.
q₁ = a + bi + cj + dk
Required real coefficient.
Required coefficient of i.
Required coefficient of j.
Required coefficient of k.
q₂ = e + fi + gj + hk
Required real coefficient.
Required coefficient of i.
Use 0 when the j term is absent.
Required coefficient of k.
Rotation axis and angle
Any nonzero axis direction.
Any real coordinate.
Any real coordinate.
Signed angle; positive follows the right-hand rule.
Changing units converts the current angle.
Vector v = (x, y, z)
Required x coordinate.
Required y coordinate.
Required z coordinate.
Results
Results update as soon as the active inputs form a complete valid state.
Primary result
5 – 10i + 12j + 19k
Hamilton product q₁ × q₂. Multiplication order matters.
Component details
Canonical values before display rounding
| Component | q₁ | q₂ | q₁ × q₂ |
|---|---|---|---|
| Real | 2 | 5 | 5 |
| i | – 1 | – 4 | – 10 |
| j | 3 | 0 | 12 |
| k | 1 | 1 | 19 |
The Hamilton product uses i² = j² = k² = ijk = – 1. The output norm equals the product of the two input norms.
Matrix representation
Rows and columns follow the selected operation.
Matrix values are generated from the same canonical result used by the summary and workbook.
How to use this quaternion calculator
What this calculator does
This calculator evaluates common quaternion algebra and rotation operations. A quaternion is written as q = a + bi + cj + dk, with one real coefficient and three imaginary-basis coefficients. The tool can add or subtract two quaternions, calculate both multiplication orders, divide using the inverse of q₂, find the magnitude, conjugate, inverse, or 4 × 4 real matrix of q₁, construct a unit quaternion from an axis and angle, and rotate a three-dimensional vector. It reports exact numerical identities for the entered values, but it does not determine whether a chosen coordinate-frame convention is appropriate for a particular engineering or graphics system.
When to use it
Use the calculator to check hand calculations in algebra courses, compare q₁ × q₂ with q₂ × q₁, verify an inverse or norm identity, convert an axis-angle description into a rotation quaternion and 3 × 3 matrix, or test how a vector changes under a specified 3D rotation. For deeper background, the Wolfram MathWorld quaternion overview summarizes the algebra and Hamilton's multiplication rules.
How to calculate
- The calculator opens with a complete product example: q₁ = 2 – i + 3j + k and q₂ = 5 – 4i + k. Its result and a validated example workbook are available immediately.
- Choose an operation in I want to find the.... The relevant input groups appear automatically.
- Replace the displayed coefficients or rotation values. Use a decimal point, optional leading sign, and ordinary decimal notation; commas and scientific notation are rejected to prevent ambiguous parsing.
- Read Primary result, the optional Secondary result, the four norm/scalar cards, and the adaptive Component details table. Matrix-producing operations also show Matrix representation.
- Select Download Excel to export the current validated inputs and canonical outputs. Reset clears the demonstration and all semantic data, so Excel export becomes unavailable until a complete valid state is entered again.
Input guide
I want to find the... is required and selects the formula. For binary algebra, Real part (a), The i coefficient (b), The j coefficient (c), and The k coefficient (d) define q₁; Real part (e), The i coefficient (f), The j coefficient (g), and The k coefficient (h) define q₂. Each is a required real number when its group is active. Enter 0 for a missing term – for example, g = 0 in the startup q₂. Larger coefficient magnitudes generally increase norms, but signs and multiplication order control the output components. A frequent mistake is to omit an implicit coefficient of 1 or – 1.
For rotation modes, Axis x, Axis y, and Axis z define any nonzero direction; the calculator normalizes it, so (1, 0, – 1) and (2, 0, – 2) describe the same axis. Rotation angle is a required signed real value, while Angle unit chooses degrees or radians and converts the current value when changed. The startup rotation example uses 60 degrees. For Rotate a 3D vector, Vector x, Vector y, and Vector z are also required; the saved demonstration is (1, 2, 3). Do not use a zero axis, because it has no direction.
Output guide
The header pills show Operation, First input norm, Second input norm, and Status. In quaternion modes, the first and second norms are ‖q₁‖ and ‖q₂‖; in rotation modes they map to the axis length and, when applicable, vector length. Primary result is the selected operation's main scalar, quaternion, matrix summary, or rotated vector. Secondary result appears when order creates a second meaningful answer, notably q₂ × q₁ and the alternative quotient. Output norm measures the magnitude of the primary quaternion or rotated vector, and Output scalar is the real coefficient when a quaternion is produced. Zero can be valid for a component or scalar; a zero norm is valid for the zero quaternion but prevents inversion or division.
The Component details table lists the real/i/j/k components for quaternion operations and adapts to axis, rotation-quaternion, or vector coordinates in rotation modes. Its values are estimates only in the sense of floating-point display rounding; algebraic identities are computed from full JavaScript number precision. Matrix representation is exact for the canonical floating-point values and appears for the 4 × 4 left-multiplication matrix or the 3 × 3 rotation matrix.
Worked example
With q₁ = 2 – i + 3j + k and q₂ = 5 – 4i + k, the real component of q₁ × q₂ is 2×5 – ( – 1)×( – 4) – 3×0 – 1×1 = 5. The i component is 2×( – 4) + ( – 1)×5 + 3×1 – 1×0 = – 10; the j component is 12; and the k component is 19. Therefore the first-open Primary result is 5 – 10i + 12j + 19k. Reversing the order gives 5 – 16i + 18j – 5k, demonstrating noncommutativity. The output norm, about 25.099801, also equals ‖q₁‖‖q₂‖ within floating-point precision.
Learn more
For rotations, Stanford's Quaternions and Rotations notes derive the algebra, axis-angle form, and vector conjugation method. NASA's Euler angles, quaternions, and transformation matrices report provides an engineering treatment of attitude representations and convention choices.
Formulas and interpretation
For p = (w₁, x₁, y₁, z₁) and q = (w₂, x₂, y₂, z₂), the Hamilton product combines a scalar term with dot- and cross-product behavior. This is why multiplication is associative but generally not commutative.
The magnitude is √(w² + x² + y² + z²). The conjugate keeps the real part and negates the other three components. A nonzero quaternion's inverse is its conjugate divided by the squared magnitude. MathWorld's quaternion norm reference states the same norm and conjugate identity.
For an axis u and angle θ, the calculator first normalizes u, then builds q = cos(θ/2) + u sin(θ/2). A vector is treated as a pure quaternion and rotated by qvq⁻¹. Rotation preserves vector length; if the displayed input and output norms differ beyond normal floating-point rounding, recheck the axis, angle unit, and coordinate convention.