On Thursday, 8 February 2018 at 15:23:05 UTC, Simen Kjærås wrote:
So I was bored in a meeting and decided to implement a generic template for defining complex numbers, dual numbers, quaternions and many other possible algebras by simply defining a set of rules and the components on which they act:

alias quaternion = Algebra!(
        op("1",     any)  = any,
        op("i,j,k", self) = "-1",
        op("i",     "j")  = "k".antiCommutative,
        op("j",     "k")  = "i".antiCommutative,
        op("k",     "i")  = "j".antiCommutative,




Nice. An interesting potential extension is to support composition (for instance, defining the complex numbers using the template and then defining the quaternions as an two-dimensional algebra over the complex).

Reply via email to