Complex And Hypercomplex Numbers

You created this dream out of bits and pieces
You’re caught inside a fantasy
But we’ll find the truth inside

Star One, Cassandra Complex

Scheme’s existing tower defines a level called `complex`, which contains the `rational` numbers and a single imaginary unit `i` (AKA `i₀`), as well as every sum and product of those numbers (i.e. it is closed under `+` and `×`).

If you’ve never encountered `complex` numbers before, they have two important properties which will be relevant to our more-general framework of GA. Firstly every `complex` number, no matter how much we mix and nest sums and products, will always reduce down to a single sum, of the form `(+ A (× B i))`, where `A` and `B` are `rational` (and potentially `zero`). A `complex` number will never require more parts, like `(× C i i)`, `(× D i i i)`, etc. since we know that `(= (× i i) -1)` (from the above definition of imaginary units), so all higher powers of `i` will reduce down to the `(+ A (× B i))` form. Secondly there is no meaningful way to further reduce this sum, so a `complex` number is always made of two “parts”; despite being a single number!

Racket’s notation for `complex` numbers is hence `A+Bi` (with no spaces); or using `-` instead of `+` when `B` is negative.

The problem with a dedicated `complex` level is that it gives preferential treatment to imaginary units relative to dual and hyperbolic units. Some might find this desirable, but I’ve decided to extend my `geometric` level to encompass `complex`, which makes the tower simpler and more consistent:

Aside: The Many Structures Found Inside `geometric`

Whilst `complex` is certainly a useful type of number, the reason I don’t want it as a level above `rational` is there are other numbers above `rational`, which are neither above or below `complex`.

The and vice “sibling” other non-`rational` units form perfectly there are two numbers As mentioned above, these non-`rational` units have appeared in various theories over the course of several centuries. You don’t need to know or care about these different algebras, since they crop up naturally as patterns in GA, but since a numerical tower is all about representing such nested structures it seems prudent to define them for those who care!

Complex Numbers

If we extend the `rational` numbers with a single imaginary unit, say `i₀`, we get a self-contained numerical system called the complex numbers. This has found uses which is useful in 2D geometry, wave mechanics, electrical engineering, etc. Indeed, this already exists in the standard Scheme tower, as the `complex` level!

Quaternions And Hyperimaginary Numbers

Extending `complex` with another imaginary unit doesn’t give a useful theory, but having three imaginary units (`i₀`, `i₁` and `i₂`) gives another useful system called the quaternions; which is especially useful for describing 3D rotations. The numerical tower in Kawa Scheme has a `quaternion` level above `complex`, so we’ll do the same!

There is actually an infinite family of such “hypercomplex” theories, each with twice as many units as the last (when counting all the imaginary units and the unique `rational` unit `1`); I’ll call these hyperimaginary, to distinguish them from the other flavours. The octonions have seven imaginary units, the sedeneons have fifteen, and so on. However, the further we go, the less useful those theories become, as they follow fewer (and weaker) algebraic rules. In particular, everything past the quaternions violates associativity, which I don’t consider “numeric” enough to live in our tower!

Dual Numbers

If we extend `rational` with a single dual unit, say `d₀`, we get the system of dual numbers, which is useful for e.g. automatic differentiation. Dual numbers don’t include an imaginary unit, and `complex` numbers don’t include a dual unit, so neither is a sub-set of the other. Hence they’ll need to live side-by-side in our tower!

Dual Quaternions

The combination of `quaternion` and `dual` forms a useful theory called the dual quaternions, which are used to describe rotation and translation in 3D space. Thankfully there’s a perfect spot for it in our unfortunately-wonky tower:

Hyperbolic Numbers

We’ve got one flavour of unit left, the hyperbolics, and you may have guessed that we can also extend `rational` with one of those, say `h₀`, to get the hyperbolic numbers.