Take a number, square it, the result is non-negative. Because positive * positive = positive and negative * negative is positive. Or
But someone wanted to take square roots of negative numbers, so they did, and called it 'i'.
The solution, to put imaginary and complex numbers on a solid foundation is something called a ring quotient. What you do is you start with the ring (meaning number system) of polynomials over the real numbers
-
$1, 2 3.5, \pi$ etc. -
$i, i^2, 0.3 + 9.5 i + 23 i^3$ and so on.
Then you take a quotient
In terms of programming the way this is done is every instance if (real,imag)
.
Another thing that we do a lot in calculations, especially in physics, is include units. But it's kind of "loose", we know that you can only add units that are like. But you can multiply and divide anything and the units join. For example if distance is measured in meters and time in seconds,
This is the amazing part I want to share in this post: You can do all this with a ring quotient.
Let's define
So in terms of implementation, I would start with code that implements multi-variable polynomials with basic arithmetic, reading in and printing out. And then add a normalization procedure which converts the variable cm
into 1/100 m
.
Functions like
I think that this is a really useful idea for programming calculations that involve units, but I also think it's valuable just in terms of how much it clarifies the informal way we work with numbers that have units.