Quaternions, octonions and the doubling ladder
One construction builds the complex numbers from the reals, the quaternions from the complex numbers, the octonions from the quaternions, and keeps going. Each step doubles the dimension and gives up one law of arithmetic. Everything here is exact.
The construction
A number of the next level is a pair of numbers of this one, with
Starting from the reals, where , the pairs are the complex numbers with . Pairs of those are the quaternions, with and . Then come the octonions (dimension 8), the sedenions (16), and so on without end.
import { quaternions, octonions, sedenions, cayleyDickson, quaternion, octonion } from "@ratmath/complex/cayley";
const [one, i, j, k] = quaternions.units;
String(i.mul(j)); // "k"
String(j.mul(i)); // "-k": order matters
String(i.mul(j).mul(k)); // "-1": Hamilton's i j k = −1
const q = quaternion(1, 2, 3, 4); // or quaternion("1 + 2i + 3j + 4k")
String(q.norm()); // "30"
String(q.conj()); // "1 - 2i - 3j - 4k"
String(q.inv()); // "1/30 - 1/15i - 1/10j - 2/15k"
String(q.mul("i")); // "-2 + i + 4j - 3k"
String(quaternion("i").mul(q));// "-2 + i - 4j + 3k"
String(octonion("e1 + 2 e7").mul(octonion("1 - e3"))); // "e1 + e2 - 2 e4 + 2 e7"
cayleyDickson(5).dim; // 32; levels 0 to 8 are available
Elements are immutable, with coordinates in .coeffs on the basis (written for the quaternions). The methods are add sub mul neg scale conj norm inv pow rightDivide leftDivide commutator associator equals. Arguments may be elements, numbers, coefficient lists or text.
What each level loses
| Level | Name | Dimension | Loses | Still has |
|---|---|---|---|---|
| 0 | real numbers | 1 | order, and everything below | |
| 1 | complex numbers | 2 | order; | commutative, associative |
| 2 | quaternions | 4 | commutativity | associative: a division ring |
| 3 | octonions | 8 | associativity | alternative, , division |
| 4 | sedenions | 16 | alternativity, the norm law, division | flexible, power-associative, inverses |
algebra.properties() finds these by exact computation instead of quoting them, and for the sedenions and beyond it returns an actual pair of zero divisors:
octonions.properties();
// { name: "octonions", dimension: 8, commutative: false, associative: false,
// alternative: true, flexible: true, composition: true, zeroDivisors: null }
const [a, b] = sedenions.properties().zeroDivisors;
String(a); String(b); // "e1 + e10", "e4 - e15"
String(a.mul(b)); // "0", though neither factor is 0
Alternative means and : any two elements generate an associative algebra, even though three do not. Flexible means . Power-associative means does not depend on how it is bracketed, which is why pow works at every level.
Norm and inverse
At every level , the sum of the squares of the coordinates, so is a two-sided inverse of any nonzero . What changes is what an inverse is good for. Up to the octonions , which makes impossible unless a factor is 0, and solves . In the sedenions the norm law fails, zero divisors appear, and may have no solution or many; rightDivide and leftDivide check their answer there and refuse (code no-quotient) when it does not hold.
The norm law is a statement about sums of squares. For the complex numbers it is the two-square identity of Diophantus, for the quaternions Euler's four-square identity, for the octonions Degen's eight-square identity. Hurwitz proved in 1898 that there are no others: an identity of this kind exists only for 1, 2, 4 and 8 squares. The ladder goes on, but the good behaviour stops at the octonions.
Commutators and associators
measures the failure of commutativity and the failure of associativity.
const O = octonions;
String(O.basis(1).mul(O.basis(2)).mul(O.basis(4))); // "e7"
String(O.basis(1).mul(O.basis(2).mul(O.basis(4)))); // "-e7"
String(O.basis(1).associator(O.basis(2), O.basis(4))); // "2 e7"
Other fields
cayleyDickson(level, field) builds the algebra over any RatMath field object. Over CQ from the main entry point the level-2 algebra is the biquaternions (quaternions with complex coefficients), which do have zero divisors: where is the scalar one.
@ratmath/complex and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.