cayley-dickson
implements Cayley-Dickson construction to produce a sequence of algebras over a field
Installation | Usage : Real > Complex > Quaternion > Octonion > Sedenion | License
Installation
With npm do
npm install cayley-dickson
Usage
Every code snippet below it is intended to be contained in a single file.
Define real operators, see also algebra-ring. Note that you could use any operators definition, for example using a big numbers lib.
const real = zero: 0 one: 1 a === b typeof a === 'number' && a + b -a a * b 1 / a
Import cayley-dickson.
const iterateCayleyDickson =
Now you can use Cayley-Dickson constructions to build algebras. Every iteration doubles the dimension. Let's take a trip through Cayley-Dickson algebras.
Real
start from here
Well, iteration 0 gives the common Real numbers. The result is just the return value of the algebra-ring function, nothing really exciting.
// Real numbers.const R = R // trueR // trueR // trueR // trueR // 3R // -1R // -2R // -6R // 5R // 0.5
Complex
a beautiful plane
First iteration gives Complex numbers, they are a field like the Real numbers.
// Complex numbers.const C = C // trueC // trueC // trueC // trueC // [2, 6]C // [-1, -2]C // [-1, -2]C // [5, 0]C // [1, -2]C // [0, -0.5]C // [1, -2]
Quaternion
here you loose commutativity
Second iteration gives Quaternion numbers, usually denoted as ℍ in honour of sir Hamilton. They are used in computer graphics cause rotations are far easier to manipulate in this land.
Let's check the famous formula for Quaternion multiplication ijk = i² = j² = k² = -1
// Quaternion numbers.const H = const minusOne = -1 0 0 0jconst i = 0 1 0 0const j = 0 0 1 0const k = 0 0 0 1 H // trueH // trueH // true // ijk - 1 = 0H // [0, 0, 0, 0]
Octonion
here you loose associativity
Third iteration gives Octonion numbers. A byte could be seen as an octonion of bits, which should define a new kind of bit operator.
// Octonion numbers.const O = const minusOne = -1 0 0 0 0 0 0 0 const i1 = 0 1 0 0 0 0 0 0 O // true O // [1, -2, -3, -4, -5, -6, -7, -8]
Sedenion
hic sunt leones
Fourth iteration gives Sedenion numbers, that are out of my scope sincerely. They are not a division ring, there are elements that divide zero 😱.
// Sedenion numbers.const S =