If I try to instanstate a complex number with a type T <: Number but not <:Real returns not defined. Why isn’t defined for all numbers.,

What exactly is the julia code you trying to execute?

Because it only makes mathematical sense with real components.

Technically, it would be kind of sensible to define `const Quaternian{T<:Real} = Complex{Complex{T}}`

That seems like it would require a lot of additional care but it could work. I’m also unclear on how that leads to non-commutativity.

Would that really make more sense to people than a single layer of 4 distinct `Real`

fields? Personally, knowing nothing about quaternions, I would interpret `(3+1im) + (3+1im)im`

as `3 + 1i + 3i + i^2 = 2 + 4i`

, which is already how it’s parsed. Just easier to wrap my head around "2nd field in `Complex`

" is `im`

is `i`

is imaginary axis and nothing else.

Given any ring it makes sense mathematically to adjoin an element i that squares to -1. However if you will never get quaternions this way, since adjoining i preserves commutativity.

I had a go at something like this and wrote BiComplex.jl. I quite quickly found a work around for what I was trying to achieve (hence the terse readme) with it so stopped developing it.

That was my thought too—there’s nothing that gives the anti-commutative behavior of the quaternions so it must be a different ring. Also unclear to me if it’s even a ring at all since I vaguely recall something about there not existing a commutative ring over the reals with four generators.

To represent quaternions a + bi + cj + dk as complex of complex, you need I and J as distinct imaginaries, i.e. I^2 = -1, J^2 = -1, and letting IJ = -JI. Then do complex of complex like (a + bI) + (c + dI) J and associate i,j,k with I, J, IJ.

Also unclear to me if it’s even a ring at all since I vaguely recall something about there not existing a commutative ring over the reals with four generators.

Yes, there are multiple statements of the form there are not many nice rings slightly bigger than the reals. For instance, the complex numbers is the only finite dimensional field above the real numbers. And complex + quaternions are the only finite dimensional skew fields. There are many commutative rings that are finite dimensional over the reals, however. You can always adjoin elements that satisfy some polynomial relation and you always get a ring this way.

Ah yes, that makes sense. So it’s likely a ring but not a field.