Alastar Gabriel (but you can call me anything). I'm an ex-professional software developer, now I make weird art and music :p I will give you bug facts unprompted


Twitch, Ko-fi, Neocities, Mastodon


We can be friends but I have to warn you, I am a little awkward and kind of hard to get ahold of :p


ENG/日本語 OK


website
444631.xyz/
Tumblr (I probably won't use this one much)
www.tumblr.com/444631

DecayWTF
@DecayWTF

They should teach complex math around about the same time exponentials and square roots are introduced in elementary school.

Okay I guess I'm pinning this. It is now the table of contents for my new textbook, Complex Math For The Little Queer People Who Live In My Computer


DecayWTF
@DecayWTF

Beware: This is a very basic intro to complex math. A lot of it is just intuitive and not incredibly rigorous, so if you come into my comments to complain that I didn't explain the Cayley-Dickson construction and that's not how we derive complex numbers or whatever, I'm going to laugh at you and shove you in a locker. Anyway!

In school, we learn various number systems. Until you start doing higher math, it's not usually broken down like this, but it's pretty straightforward:

  • Natural numbers, ℕ (the blackboard bold letter is just a shorthand name for each particular set of numbers): The basic counting numbers we learn in elementary school. 0, 1, 2, etc. Sometimes we talk about whole numbers (counting numbers excluding zero) as a discrete set too.
  • Integers, ℤ (the Z is from German because mathematicians are like that): The natural numbers plus all the negative numbers.
  • Rational numbers, ℚ (the Q stands for quotient and is also the giant letter on the NyQuil bottle): All the numbers you can create by dividing one integer by another non-zero integer. 3/4, 2/7, -12/5, that sort of thing.
  • Real numbers, ℝ (they couldn't justify using something more confusing I guess): This is where it gets slippery. Roughly, this is the set of all numbers you could, in principle, given infinite space and time, represent as something.something else, decimals. The tricky part here is that every finite or repeating decimal is also a rational; no matter how long it is, if it is finite or repeating, it can be represented as a ratio of two (maybe very large) integers. The numbers in the reals that really can't be represented that way are called irrational numbers; they have an infinitely long and non-repeating fractional part. The irrational number most people are familiar with (mostly because it's unavoidable in a lot of math and pop-math guys have an infinitely long, non-repeating hardon for it) is pi, the ratio of the length of a semicircle to its radius.

Now, the thing laying these out like this shows is that each set contains the last one: The reals contain all the rationals, the rationals contain all the integers (they're rationals of the form x/1), and the integers contain all the natural numbers. So this brings us to a question:

What contains the reals? Is there anything "above" them?


DecayWTF
@DecayWTF

So in the first post I talked about the basic properties of complex numbers, how addition and multiplication work, and how they relate in a basic sense to vectors. For a second post, I wanted to talk about some of the more interesting parts of complex arithmetic, especially how division works, and another way of representing complex numbers that makes handling them as vectors much more convenient for certain applications.


As we learned above, complex multiplication follows normal algebraic rules of multiplication, with the one additional rule that i^2 = -1.

(5+i) (3+2i) = 15 +10i +3i +2i2 = 15 +13i 2 = 13 +13i

We can always FOIL it out like that, and it'll always work, but it's a bit clunky and because complex numbers are always of the same normal form, a+bi, there's a simple rule you can follow:

(a+bi) (c+di) = (acbd) + (ad+bc)i

That follows just from expanding the general form and it's the usual way you do complex multiplication.

Now, the reason I bring this up is because complex division is sort of a pain in the ass and you have to do some multiplication to do it, so being able to do multiplication fast helps. So! How do we do this:

13+13i 3+2i

Now, we know what the answer is from above but how would we divide it out if we didn't? This is seeming a bit intractable, or at least really annoying. Fortunately, we have something called the complex conjugate that can help us out.

Every complex number z (typically, for arbitrary complex values, we use z instead of x so that we know we're working in the complex plane and also it doesn't remind us of Elon Musk) has what is called its conjugate, denoted , which is the complex number with the sign of its imaginary part reversed; it can also be denoted z* which is used in physics and engineering to let the mathematicians know who's boss. A graphical representation explains what this does a little better:

3+2i and its conjugate, 3-2i

It's reflecting the vector across the real axis.

The conjugate has some interesting properties in its own right, a very important one being that if you multiply a number by its conjugate, the result is a real number, the modulus squared:

(a+bi) (a-bi) = (a2b(b) ) + (abab)i = a2+b2

The vector interpretation of this is obvious: We're rotating the vector by exactly the negative of its angle, and scaling it as the square of its own length.

3+2i, e-2i, and their product, 13

Because multiplying a complex number by its own conjugate gives us a real number, which we can conveniently divide complex numbers by, we can use the the conjugate of the denominator of a complex fraction to change the fraction into something easier to deal with:

13+13i 3+2i = ( 13+13i 3+2i ) ( 3-2i 3-2i ) = 65+13i 13 = 5+i

There's no magic here; the important thing to remember is that (3-2i)/(3-2i) is just a fancy way of writing 1 so multiplying the fraction by that changes its representation into something we can work with, without altering its value.

We keep talking about multiplication as scaling and rotation (and division is the same, since that's just multiplying something by 1/something) and it's clear that complex numbers are useful as vectors, but it's really not convenient to deal with the angles if we want to use these for rotation explicitly; we have to take the inverse tangent to get the angle which is expensive and difficult, and frankly not very exact if you're just doing things with a calculator. We also have this idea we just saw of altering the representation of a number without changing its value; we do this all the time without thinking about it, even in the reals and rationals, like when we reduce a fraction.

What if we combined these two thoughts? Is there a representation we could use for a complex number that would keep the same value but make it more convenient for transformations? (Obviously the answer is yes or I wouldn't be going down this road)

Warning: Trig ahead

Let's say we have a vector with a length r that's at an angle θ to the x axis. This forms a right triangle with side lengths adj and opp:

A ray of length r with angle θ, forming a right triangle with adjacent side length adj and opposite side length opp

From basic trig, we know the following:

sin θ = opp r r sin θ = opp cos θ = adj r r cos θ = adj

So since our triangle starts at (0,0), that means that r sin θ is exactly the y value of the vector, and r cos θ is exactly the x value. In the complex plane, our number a + bi encodes those coordinates as a for x and b for y. If that number has a length of r (the modulus of a + bi) and forms an angle of θ to the x-axis, we can say:

a+bi = r cos θ+ ir sin θ = r(cos θ+ i sin θ)

Okay we're done with the explanation. The trig below is unavoidable. Sorry.

The form r(cos θ + i sin θ) for a complex number is called its polar form. It expresses a complex number by its length and the angle it forms with the x-axis. Any complex number in a+bi form (what we call rectangular coordinates) can be expressed in polar form as well, and vice versa. From the derivation above, the relationship is exactly:

a = rcos θ b = rsin θ

By the trig identity above, they're exactly the same number, just different representations, and if you want to deal with angles and lengths directly, polar form can be incredibly useful. Again, and I have to stress this: There is no difference between a number in rectangular coordinates and the polar representation of the same value. You can even intermix them if you want to, and this can be extremely useful in many cases.

For instance, let's say we have a complex number 6 + 3i and we want to rotate it by 30 degrees (π/6 radians) and not change its length. We know that if we multiply that number by a complex number of length 1 with an angle of π/6 radians, we'll get exactly what we want. As a note so that it doesn't look like we're doing fucking magic below, cos π/6 = sqrt(3)/2 and sin π/6 = 1/2. There's ways to determine this but we won't go into that; they're very well-known identities you can look up:

(6+3i) (cosπ6+isinπ6) = 6 cosπ6+ 6isinπ6+ 3icosπ6+ 3i2sinπ6 = 632+ 6i12+ 3i32 312 = 632+ 6i2+ 33i2 32 = 632+ 6i2+ 33i2 32 = 6332+ 6+33 2i

That seems a pretty uninspiring answer, but let's graph it:

Graph of the above vectors

Sorry for the font change, I had to switch to using LaTeX to typeset the formulas in the graph. The things I do for you people.

That looks right! The new vector has a length of 3*sqrt(5), just like 6+3i, and its angle is is equal to the sum of pi/6 and arctan(1/2), our original angles, approximately 0.9872.

There's a lot of cool things about polar coordinates for complex numbers and one of them is that they make multiplication and division easier. Remember, from what we've seen, complex multiplication multiplies vector lengths and adds the angles, and complex division divides the lengths and subtracts angles. So that means that, using some trig angle identity bullshit, we can do the following:

Warning: More trig fuckery to show the derivations, you can skip those if you want. Sorry about the long lines but I can't get it to break in a non awful way

r ( cos α + i sin α ) s ( cos β + i sin β ) = r s cos α cos β + r s i cos α sin β + r s i sin α cos β r s sin α sin β = r s ( cos α cos β sin α sin β ) + r s i ( cos α sin β + sin α cos β ) = r s ( cos ( α + β ) + i sin ( α + β ) ) r ( cos α + i sin α ) s ( cos β + i sin β ) = r s ( cos α + i sin α cos β + i sin β ) = r s ( cos α + i sin α cos β + i sin β ) ( cos β i sin β cos β i sin β ) = r s ( cos α cos β i cos α sin β + i sin α cos β + sin α sin β cos 2 β i sin β cos β + i sin β cos β + sin 2 β ) = r s ( cos α cos β + sin α sin β + i ( sin α cos β cos α sin β ) cos 2 β + sin 2 β ) = r s ( cos ( α β ) + i sin ( α β ) )

Okay cool

No conjugates needed, no distributing shit, just simple arithmetic!

And that is basically it, you now have all the tools you need to use complex math in most basic applications! The next step is getting into exponents and logarithms, and that's where things get ugly and you start learning about multiple- and infinite-valued functions, branch cuts and all kinds of groovy things that we was talking about on the group W bench.


You must log in to comment.

in reply to @DecayWTF's post:

100% agreed!

My biggest problem with really understanding math was always that it looked like there were connections, but nobody was ever able to show me those connections, and I didn't know where to look for more information, and I wasn't quite able to suss all of them out myself. My high school calculus teacher saw that and helped as much as he could, but he was an over-worked teacher with a new baby, so time was limited.

In college, though. Oh man. I had plenty of resources to learn about those connections and explore what they meant. I know not everyone wants to see how things fit together in a wider view (it might be overwhelming), but it sure helps me.

So the only quibble I have with this (though I maybe should save it to go over it again) is the "we get to reals from rationals with roots that yield irrationals" step.

Because, of course, that's not how we get there, the way that the rationals are just the quotient field of the integers.

Adding in all the roots only gets us to the algebraic numbers, but not to something transcendental like π. (or one of the non-algebraic solutions that occasionally happen with quintic equations)

I think that at this point you don't want to introduce algebraic numbers, so what I'd suggest is pausing at the rationals, pointing out that there was a cult in ancient Greece that was very into the idea that the rationals were all the numbers there could ever be, and that this cult had a serious crisis of faith around the square root of two (predicted by the Pythagorean theorem) resulting murder of the little git who first pointed this out.

So from this, clearly there are things that are somehow "in between" rational numbers in a way that hurts the head to think about too much, and we go from rationals to reals by declaring the reals to be "the rationals and everything that could possibly be in-between" with an optional link off to a formal explanation of Dedekind cuts.

I also think it'd be good to accompany your explanation of expanding one's view of numbers with a mention of what you lose as you expand your view of numbers.

In going from the naturals to the integers, you lose the idea that a+b ≥ a for all a. With that, you also lose the idea of easy induction proofs parameterized by something. You lose the ability to explain a number easily by pointing to a basket and saying "the number of apples in this basket is the number"; in a way you lose the tight connection to counting that you had since pre-school and before.

In going from the integers to the rationals, you lose the idea that there's always a "next largest" number. You can't count by rationals and know where it's going to go as anyone knows who's ever had a parent "count to 3" by going "1, 2, 2-and-a-half, 2-and-three-quarters, 2-point-9, 2-point-99", etc.

In going from the rationals to the reals what you lose is the idea that you will always be able to write your number down without inventing bespoke symbols just for that number. This is related to the fact that you've lost countability, though an explanation of countable and uncountable sets is obviously beyond the scope. However, I think it's reasonable to say that there are so many real numbers - so many more than rational - that any system for writing them down that is limited to finite space will leave the vast majority as simply unrepresentable. Uncountability is weird and big and the sort of thing I'd expect Lovecraft to write about.

When going from real to the complex, obviously you lose the idea that z*z ≥ 0 for all z, but more than that you lose the idea that "≥" means anything important at all. Oh, sure, you can establish some total ordering on the complex numbers (e.g. lexicographic ordering), but there's no way to make the function "f(x) = x ≥ 3" discontinuous only at 3. There's no way to say "this number a is in-between these other two numbers b and c, and therefore if something moves continuously from b to c it must pass through a".

(this sets students up for the shock that when going from complex numbers to quaternions you lose commutativity for multiplication, but that's probably at least high-school level)

As I noted at the top, this was just an intuitive explanation and I explicitly did not go into fussier details like the difference between irrational roots and transcendentals or other ways of constructing irrationals, since real numbers are fussy and slippery and I was just trying to introduce the idea of each larger set containing the previous. Especially when you get into countability and ordering, that pulls in a lot of other complex (so to speak) ideas and I was trying to stay relatively focused without having to get into cardinalities of sets or notions of continuity.

Yeah, countability pulls in the monsters. I can understand why you'd want to stay away. I might still handwave that "there's other stuff here for later", and who doesn't love a good ancient-cult murder story?

I do think it's possible to mention that with complex numbers you no longer have the same sort of idea of "in between" that you do with real numbers; like when you go from -3 to 3 in the reals you have to go through 0, there's no way around it. (e.g., you can talk about how normally when going from frozen ice to water you have to go through that temperature in the middle where water melts; there's no way around it) However, complex numbers introduce another thing and suddenly it is possible to go from -3 to 3 without ever touching 0.

Sure. There's a lot to talk about, I just wasn't sure what other things I would want to touch on in such a very basic introduction. I'd be more likely to talk about conjugates and division first and maybe point out the lack of ordering as a small note or as a point when going over numbers in polar form.

Ok, this was cool as hell to see complex numbers tied in with vectors. I'd done math with i before and even vaguely understood quaternions once, but the explanation with vectors made it more intuitive somehow. I still need to brush up on my basic trig some but really great explanation of imaginary numbers. "Oh fuck off" is a great reaction to trying to figure out the square root of -1 lmao

Can I just say, as someone with a brain that is capable of understanding, but withheld by other problems (Dopamine-Addicted Brain Goblins!), this is the first time I've ever had even a remote understanding of what the hell irrational numbers even are, let alone complex and imaginary numbers and then seamlessly expanding upon how they're cool, why they're cool, and that they're actually super useful, which is mind-boggling in and of itself, while also providing visual examples and real reactions and observations - IT WAS ROTATING AND SCALING- ...

I suppose I'm maybe exactly the kind of person this post was for. I soaked this right up. Thank you. :3

hey, I'm glad this is working out for you! I really love complex analysis but I'm all self taught so part of the impetus of this has been "write a teaching thingy to help myself get better at it" and to pass on a really interesting and useful section of math that gets kind of unfairly treated as useless and obscure a lot of the time...