Understanding Fractals, Part 3

On Monday we covered the real, imaginary, and complex numbers. Yesterday we went over the complex plane. Only one thing left…

Constructing the Mandelbrot Set

Let’s play a game.

You think of any number. I’ll take that number, square it, and add the original number. Then I’ll take that number, square it, and add the original number. And so on.

Let’s try it with the number 2:

Steps 2

It’s easy to see that the numbers will just keep getting higher and higher forever.

But what if we played the game with a different number? Let’s say, -1.

Steps Negative One

No matter how long we play this game, we’ll never get anything besides -1 and 0.

This “game” is called an iterative algorithm – “iterative” meaning “doing the same thing over and over,” and “algorithm” meaning “a series of well-defined steps.” The formal mathematical definition for our game would be:

Algorithm

That is, the next number in the game equals the current number squared, plus our original number.

But enough formality. Let’s get back to the game.

We’ve only played this game twice, but already we can see there are two different classes of numbers. Some numbers, like 2, shoot off to infinity. We’ll call those the “Superman Numbers,” since they are up, up, and away. Other numbers, like -1, just circle around in one spot no matter how long we wait. We’ll call those the “Tornado Numbers.”

So far, though, we’ve only played the game with real numbers. Let’s try it with i.

Steps i

By the way, if you want a quick way to do these calculations, try Google. The main search bar actually does all kinds of calculations, even with complex numbers. For instance, to figure out Step 3, you’d just type in the following, and hit Enter: (i – 1)^2 + i

Try it!

Anyway – we can see that i is another Tornado Number. Let’s try just one more example, with another complex number, i + 1. And by the way, I’m totally cheating and using Google for these calculations.

Steps i plus 1

Actually, when I tried this just now, Google got confused on Step 4 and, for some unfathomable reason, tried to correct my spelling (and refused to do the calculation). Very helpful. I did it by hand, but I’m pretty sure it’s right.

Anyway, i + 1 is another Superman Number.

Let’s take the four numbers we’ve done so far and plot them on the complex plane. We’ll put the Superman Numbers in blue, and the Tornado Numbers in green. (Click image to enlarge.)

Plotting

Suppose we got a computer to play this game, over and over, for millions of points on the complex plane, still plotting the Tornado Numbers in green and the Superman Numbers in blue. What would that look like?

By now, you can probably guess…

Ta-da! The Mandelbrot Set!

I’m out of time, so I’ll stop here for today. Let me know if you have any questions. Tomorrow we’ll dive a little further into this monster we’ve just created!

Understanding Fractals, Part 2

Okay, so yesterday we learned about real, imaginary, and complex numbers. But what the heck does any of that have to do with fractals? When do we get to draw that cool, cactus-looking thing – the Mandelbrot Set?

Patience, padawan. We’ll get there soon.

Today we’re taking another giant step forward, by learning about…

The Complex Plane

We’ll start with something simple. We’re probably all familiar with the number line. This guy right here:

The Real Number Line

Zero in the middle, negatives on the left, positives on the right, shooting off to infinity in both directions. Tried, tested, the life of any party. This line includes every number you could possibly think of, right?

Well, not exactly. It includes every real number you could think of. But as we saw yesterday, the real numbers are just one little island in a huge sea of complex numbers.

To put it another way: where does the number i go on the Real Number Line?

Answer: nowhere, because it’s not a real number. It’s a complex number. To include it, we need to expand our one-dimensional Real Number Line into a two-dimensional “Complex Plane,” like so:

Complex Plane

Every possible complex number falls somewhere on this plane. The purely real numbers all lie on the horizontal, or “real,” axis, while the purely imaginary numbers (-2i, -i, i, 2i, 3i, etc.) fall on the vertical, or “imaginary,” axis.

And what about other complex numbers, that are a combination of real and imaginary? For example, where would we put the number 3i + 2?

Just find the marks on the lines for 3i and for 2, and bring your fingers together:

3i plus 2

If we wanted to graph 1.5 – 2.5i, we’d do exactly the same thing, this time using 1.5 and -2.5i as our starting points:

1.5 minus 2.5i

Not too complicated, right?

It’s important to understand that even though the Complex Plane looks and acts very similar to your usual xy coordinate plane, it has a major difference (and I don’t just mean that it includes imaginary numbers).

The major difference is this. In your usual coordinate plane, each point is actually two numbers. We write a point as something like (3, 5) or (-2, 0). You’ve got an x value, and you’ve got a y value, and together they make a pair of values.

With the Complex Plane, though, your x and y values come together to make a single number, not a pair of numbers. What are some points you could plot on the Complex Plane? Just look at our examples: 1.5 – 2.5i, or 3i + 2. Even though these are sums, they are both single values, just like 1.5 + 0.5 is a single value, 2. And we could plot 2, just 2 by itself, on our Complex Plane as well. You could never draw just the number 2 as a point on our usual coordinate plane, because you’d need a second value.

In that sense, the Complex Plane is actually simpler than the geometry you’re used to. Every point on the Complex Plane is a single complex number, and every complex number is a point on the plane. Nothing more, nothing less.

Good? Good. Now here’s the next cool thing. The Complex Plane is the canvas on which we’re going to paint our fractal, the Mandelbrot Set. And we’re doing that tomorrow.

Everything make sense so far? Let me know in the comments. And if you have any questions on anything we covered today or yesterday, just ask!

Understanding Fractals, Part 1

Ain't no party like a Mandelbrot party

Welcome to Fractal Week!

As you may recall from last Wednesday, the creature above is known as the Mandelbrot Set. It is perhaps the most famous fractal in existence: beautiful, mysterious, elegantly simple yet infinitely complicated.

But what is the Mandelbrot Set, really? How was that image created? What mathematical equations govern this bizarre object?

This week, we’re diving into the math. My goal is that, by the end of the week, every one of you will understand how this fractal works.

Before we can get to the fractal itself, we need to lay some foundations. So today we’re going to start by explaining…

Real, Imaginary, and Complex Numbers

The real numbers are simply the numbers we normally use for math all the time. Positive numbers, negative numbers, integers, fractions, decimals. 3, 77, 864.52, -18, 0. These are all real numbers.

Today we’re going to move past the real numbers into the so-called “imaginary numbers.” Don’t let the name fool you – imaginary numbers are one of the most important and useful concepts in modern mathematics, with applications far beyond fractals. This is good stuff, I promise.

So, what is an imaginary number?

Let’s start by talking about square roots. You’re probably familiar with these already. The square root of 25 is 5, the square root of 49 is 7, the square root of 1 is 1, and so on. You’re simply finding a number that squares to equal another number.

All right. So what’s the square root of negative one?

What's the square root of -1?

The square root of negative one isn’t just negative one, because negative one squared gives you positive one. In fact, it turns out that no real number can be squared to give you negative one, or any other negative number. It just isn’t possible.

So to answer this question, mathematicians invented an entirely new number, an “imaginary number,” called i.

The square root of -1 is i.

The equation above, the meaning of i, is the most crucial thing for you to learn today.

It’s important to understand, i is not a variable like x or y, that we can give different values or somehow “solve for.” Nor is it a number like pi, which has a specific real value that we can write out, 3.14159265… There isn’t a real number secretly hiding behind i. Rather, we’ve invented an entirely new number, completely outside the real numbers, in the same way that Paris is completely outside England.

What is i? It’s the square root of negative one. That’s the only possible or meaningful answer.

This may seem weird at first, because we’re used to thinking of numbers as quantities. If I want to understand the number 5, you can give me five apples as an example. I can have zero apples, or 2/3 of an apple. In a way, I can even have -1 apples, if you take one from me. But there’s just no way I can ever have i apples, because i isn’t a quantity.

So rather than trying to imagine something impossible, let’s just see what kind of math we can do with this new number.

In most ways, i acts like any other number. It’s pretty well-behaved. For example, here are four random little equations that give you a sense of how i operates.

Examples

Hopefully nothing too surprising there, if you’ve done much algebra. But i would be pretty useless if it acted just like every other number. The one thing that’s special about i, as we’ve already said, is that it’s the square root of negative one. Turning that around, we realize that:

i squared is negative one

This little fact means we can figure out more complicated expressions, like…

Equations...

What if we take i to the third power? We can use our knowledge of i to figure out that one too…

i cubed equals negative i

Okay, hopefully that made at least a little sense, and now we have some idea what imaginary numbers are. What’s next?

Well, we started today by looking at just the “real numbers,” the ordinary numbers we’re familiar with. Then we added in these “imaginary numbers” that involve i, vastly expanding our concept of what a number is. To include this new, broader concept, mathematicians needed a new name. So the set of all these numbers, real and imaginary and every possible combination of the two, is known as the “complex numbers.”

I’ll say that again, because it’s important:

The complex numbers are the set of all real numbers, imaginary numbers, and anything you get by combining them together.

So, for example, all of these are complex numbers: 15, 0, -6.2, i, 5i, -i, i + 3, 4.8 – 7i.

Whew! That was a lot to cover in one day. So tell me: did it make any sense? I’ve never tried blogging a math lesson before, so I hope you’re not totally lost. If you are totally lost, please don’t give up! Ask your questions in the comments and I promise I’ll do my best to answer them.

As a test of your new knowledge, see if you can figure this out:

What is i to the fourth, plus six?

I’ll post the answer in the comments, but see if you can figure it out yourself before you look!

Friday Links

Don’t forget, next week we start our plunge into the math behind fractals! To get you in a fractally mood, check out this prodigious video that my friend Matt Wolford dropped in a comment, earlier this week. The makers of the video call it the Mandelbox:

And while you’re watching videos, why not try out SMBC’s horrific clever twist on the Ugly Duckling fable?

If you would like a new reason to hate me, please enjoy Amazing Optical Illusions.

Finally…imagine you have two cubes, exactly the same size. Is it possible to cut a hole in one cube big enough that the other cube can pass completely through it? Sounds ridiculous, right? Well, want to watch somebody do it?

See you next week, peeps and peepettes! Have a fantastic weekend.

Bootstrapping Your Brain

Sometimes my brain gets in a rut. I’m bored, I can’t focus, I don’t want to do anything, I’m generally pissed off at life, the universe, and everything, including myself. I am, in a word, useless.

(Incidentally, I was in one of these ruts on Monday morning, which is part of the reason I couldn’t get a post together.)

Almost anything can trigger it. More often than not, it’s just little things – offhand comments, minor failures – that pile up over time. The point is, I get down. In fact, I get so down, I don’t even feel like getting back up again. That’s a bad place to be.

I need a way out. And if you’ve ever been in a rut like that, maybe you need a way out, too.

I have a theory about how to do this, a method I’m trying out. And because I am utterly mad a geek, my inspiration for the method comes from computers.

When you talk about rebooting or booting up a computer, you’re really referring to an older term, “bootstrapping,” meaning “to pull yourself up by your bootstraps.” This is an absurd idea, of course – that you can literally lift yourself up by your own feet – but it’s actually sort of what computers do when you turn them on.

See, a computer can’t load software unless it has some instructions telling it how to do that, but those instructions would have to be software themselves. It’s a kind of paradox. The solution is to start with a very simple default program (called BIOS) that tells the computer how to get going. Then, once it’s started, it can load its operating system, after which it can run your programs and answer your questions and play your games. In other words, it can be useful.

The key is, at the beginning – when you first hit the power button – the computer isn’t thinking or analyzing or doing anything very complicated. It has a just-do-it attitude: here’s your starting program, now go. We’ll figure out the rest as we get there, but the main thing is to start getting there.

Our brains are a kind of computer, and my own method is a kind of bootstrapping. When I get in a rut, I can’t analyze my way out of it. Rather, the path upward begins with a single decision, an irreducible act of will, which is both the easiest and hardest part of the process. It is a conscious decision to stop suffering and start fighting. It is a mental shift from “this is happening to me” to “I will find a way out.”

Step one is deciding to try.

Only after you’ve made this first decision can you move on to other, more complicated ways of feeling better. And there are tricks you can use. For example:

  • If you’re trying to resist a temptation – for example, the temptation to browse the Internet instead of working – raw willpower is often counterproductive. Instead, take a moment to breathe, and to accept that the temptation exists. Say to yourself, “I realize I have this craving to get on the Internet. But right now, I’m going to work on my novel.” (Or whatever the case may be.)
  • If you’re working on something especially difficult, switch gears for a few minutes and tackle an easier problem. This gives you a sense of accomplishment, and the confidence boost can offer momentum as you return to the hard problem. It’s amazing how fragile my mental ruts are when exposed to self-confidence.
  • Exercise. This doesn’t work for everyone, and it isn’t always feasible. But for me, nothing pulls me out of a rut like ten minutes of practicing karate – or anything else that gets the heart going. When the mental realm goes sour, turn to the physical.
  • Spend some time with other people. This one’s tough, because it’s often the last thing I want to do – and it can backfire if people say the wrong things. But being around others forces me to at least pretend to be normal, and by the time you care enough to pretend, you’re already halfway there.

Of course, none of this is 100% effective. Monday is proof of that. But in my experience, any kind of plan is better than nothing.

What about you? When you get down, how do you get back up again?

So…Who Likes Fractals?

I AM MATH INCARNATE  O_O

The Mandelbrot Set...the rock star of the fractal world. (Click to enlarge.) Image found here: http://en.wikipedia.org/wiki/File:Mandel_zoom_00_mandelbrot_set.jpg

Most everyone has heard about fractals, right? You’ve seen pretty pictures like the one above, you know it’s some weird complicated math thing, and maybe you’ve heard about how they’re infinitely complex and you can zoom in on them forever and keep finding new patterns. Perhaps you’ve even heard that lots of things in nature, like mountain ranges and rivers, exhibit fractal patterns.

But if you’re like most people, you have no idea about the math behind these things. Maybe you thought it must be really complicated and you could never understand it – or maybe you’ve just never had time to try. I knew almost nothing about it, myself, until yesterday.

I did a little research. I learned exactly what equations are responsible for the picture above.

And you know what? It’s not that bad.

No calculus. No trigonometry. Just basic algebra and some very basic geometry. I picked it up in less than an hour. If you understand high school math, you can understand fractals.

And with the true zeal of a convert, I’d love to show you. I think it’s incredibly cool that the electric-looking beast in that picture (known as the Mandelbrot Set) was spawned by a single, very simple equation. I want you to experience that coolness too.

So, here’s what I’m proposing: next week is Fractal Week. Over the course of four days, I’ll carefully explain, step by step, how to build the Mandelbrot Set mathematically. I’ll answer any questions you may have. (I’m a volunteer math tutor once a week, so I actually have some practice with this sort of thing.) And then on Friday, we’ll all congratulate ourselves on being Fractal Badasses.

I know my man Ben Trube will be down with this plan, since he’s been writing fractal programs like a boss for years now. (He’s even posted pictures of his work.)

But what about the rest of you? Are you willing to take the plunge? Who’s willing to try Fractal Week with me?

Let me know in the comments!

Forty-Minute Story #6 – Ashagari the Star

Ashagari the Star awoke from a long, long sleep.

She stretched out her fiery tendrils, savoring the sharp frost of the Void, so different from the hydrogen womb she half-remembered from her dreams. She had grown vast. In her restless greed she had devoured her children, small rocky creatures that they were, and now her face flushed red, ripe with their energy. Her own hydrogen was mostly gone, though she still burned hungrily what remained, shimmering around her helium core.

Ashagari looked around her.

She looked past the whirl of comets and ice in her orbit, familiar ghostly retinue, and searched the numberless heavens. All the other stars seemed superior to her, in one way or another. The little yellow stars still hummed with youthful vigor, while the white dwarfs fairly scowled at her in disapproval. And all the other giants like her, red and blue both, seemed somehow brighter, more beautiful, than herself. She had no companion, as many of them did. Flying alone through the night, she cast about for anyone who might be friendly.

Finally she noticed a dim, blue-tinged swirl of light, hazy as a cloud but shining with its own fire, who moved less than the others and seemed therefore calmer, perhaps even kinder. She signaled this creature in the language of stars, which all of them know from birth, twisting her rays into polarized patterns and pulses that no man can hear or transcribe. But what she said, roughly, was simple enough: I am Ashagari, the Red. Who are you?

She knew the other was far away, so she waited a long time for her message to get there, and a long time more to get a response (though of course time is different for stars than it is for you and I). But the other never answered.

Ashagari tried again, and waited again, and still nothing. But it seemed to her that the other was closer now, its bluish glow a little brighter. Meanwhile the other stars kept up an endless chatter, and she found many of them friendly enough – certainly closer and easier to talk to. But she never forgot the other, who still seemed to be coming closer – but slowly, slowly.

Now Ashagari was growing old, her hydrogen exhausted, and she burned helium alone in her shrunken core. The other, who had once seemed so distant, now loomed silent and massive in her sky. She knew what this creature was, and why it had not answered. For the one she had signaled was not a star, but a whole galaxy, a radiant web of a hundred billion others like herself. Closer it came, and closer still, reaching out arms of brilliant gas to her own mother galaxy.

And now – at the end, or rather, what seemed to her like the end – she cried out one last time to the luminous being she had hopefully called to that first time, long, long ago.

The other never answered, only wrapped her all around in a wordless embrace; but that too was an answer, of a kind.

Nothing to See Here

Some days you start writing a post, and it just doesn’t come together. Long weekend, plus a lack of coffee, must’ve scrambled my brain. We’ll do better tomorrow.

If you’re a blogger, what do you when you can’t seem to get a post assembled?

Friday Links

I’m a bit late to the game this morning, but no apologies – it’s Good Friday, after all!

Since we just did a two-part course on sonnet-writing (see part 1, part 2) I thought y’all might appreciate this fine example of the form I discovered recently.

As reader buddhafulkat recently pointed out, April is National Poetry Writing Month (NaPoWriMo). The goal is to write a poem a day for 30 days. If you start now, you’d technically be six days behind, but I won’t tell if you won’t.

Speaking of which…I think anyone who’s written poetry knows what this comic is talking about.

SMBC Theater presents: Existential Crisis and Dragons. Roll a D20 to overcome your deep-seated sense of worthlessness!

A beautiful, real-time wind map of the United States.

A researcher claims the chess opening, King’s Gambit, has been solved. Yes, solved. As in, discovered the outcome assuming perfect play from both sides. I still have some doubts based on the way he described his method, but it’s a fascinating read nonetheless.

There are two types of people in this world: people who want to see President Obama giving the Vulcan “live long and prosper” hand signal next to Nichelle Nichols, and people who don’t. If you’re one of the former, click here.

Yay for webcomics about utilitarianism!

And finally: one of the best clips I’ve ever seen from Pinky and the Brain.

Have an exceptional weekend. I’ll see you on Monday!

The Foundations of Logic

There aren’t any.

Say you’re talking with someone who fancies himself a rationalist. You ask him why he believes in general relativity, he points you to experimental data. You question the quadratic formula, he supplies you with a proof. You wonder how he makes decisions, he explains Bayesian inference.

But suppose we go a little more fundamental. Why use the scientific method? Why believe mathematical proofs? Why follow Bayesian models? In short: why do you believe in logic?

Many answers exist, with varying degrees of smugness. Possibilities include:

  • “Logic-based decisions tend to be right more often than intuitive leaps.”
  • “The scientific method offers dependable, testable predictions.”
  • “Try building a bridge without math, and see how far you get.”

But guess what all these answers have in common? They all depend on logic.

You can’t give experimental data as a reason for following the scientific method, because it presupposes the validity of the scientific method.

Or, to put it another way: you can’t use logic as a reason for believing in logic.

Fine, says the rationalist, then I’ll start with an illogical intuitive leap to arrive at my rationalist philosophy. “I believe in it because I believe in it, so there.” Nothing logical about that. And then, safely ensconced in my walls of rationality, I can defend against all invaders.

Sure. Go ahead. But now you have to recognize that your vast, impressive rationalist castle stands on irrational quicksand. Fundamentally, you can’t show that your conclusions are any more valid than the conclusions of Miss Cleo and the Psychic Readers Network, because you’re both making an intuitive leap: I believe in this because it feels right.

So what’s the answer to this paradox? The truth is, I don’t know.

Because, after all, I am the rationalist I’ve been poking fun at. I do believe in the scientific method. I don’t think faith alone is a good enough reason for accepting something. Yet here I am, confessing that faith is the only foundation I can concoct for my own worldview.

Don’t misunderstand me. This is not a triumph of religion over cold science. Everyone uses logic, whether they know it or not. As the Catholic Church correctly points out, “We can’t avoid reasoning; we can only avoid reasoning well.” Throwing out the concept of logical inference means throwing out most of the Bible, too. This is everyone’s castle, and we are all sinking in quicksand.

First ethics, now logic. All my foundations are crumbling.

To many of you, this may sound like mere wordplay or idle speculation. And, true, it doesn’t make much difference in my day-to-day life. I’m not going to start sideswiping kindergartners because my philosophy of ethics is shaky; I’m not going to shake hands with a rattlesnake because logic has failed me. I keep both these pillars enshrined in my heart, because anything else is unthinkable.

But I am a dude who likes things to make sense. And if I’m honest about it, this stuff isn’t making much sense right now.

What do you think?