Saturday, December 28, 2013


Most things that we encounter in our lives follow some sort of predictable pattern. Microwaving something for 26 seconds instead of 25 makes it just a little bit hotter, though we might not be able to really tell the difference. Depress the accelerator of your car just a little more and you go just a little faster. Move your mouse to the left and the little cursor on the screen goes ... left.

Imagine a world in which things routinely were not at all predictable. Where microwaving a frozen burrito for 23 seconds sort of thaws it out, for 24 seconds causes the cheese to boil, and for 25 seconds seems to make it colder than just frozen. Where pressing the accelerator sometimes makes you go faster, sometimes slows you down, and sometimes changes the radio station. Where moving your mouse left makes the cursor go left, except for the times when it goes right, up, down, or clicks the "Buy Now" button.

We'd rightly call living in such a world "chaos."

In mathematics, we revel in situations where things behave predictably. Calculus is built upon continuous functions. A function \(f\) is continuous if, when \(x\) and \(y\) are "close" in value to each other, \(f(x)\) and \(f(y)\) are "close" in value to each other. Since 25 and 26 are "close" in value, the temperatures of frozen burritos after being microwaved for 25 or 26 seconds are about the same.

How does all of this relate to the animated gif above?

There is a famous algorithm called Newton's Method that approximates, accurately, solutions to equations. Given a function \(y=f(x)\), Newton's Method allows us to approximate the solution to an equation like \(f(x)=0\). One starts with an initial guess \(x_0\), and Newton's Method gives the approximation \(\hat x\) that is usually a great approximation to \(f(x)=0\); that is, \(f(\hat x)\approx 0\).

We can think of Newton's Method as a function \(N\) itself, where \(N(x_0) = \hat x\). Returning to the "predictability" theme of this post, we would expect two things to be true of \(N\):
  1. If \(x_0\approx y_0\), then \(N(x_0) \approx N(y_0)\). That is, initial guesses that are close to each other return good approximations that are also close to each other. In other words, initial guesses of 3 and 3.001 should return the same approximate solution.
  2. If \(\overline x\) is a solution to \(f(x)=0\), that is, \(f(\overline x)=0\), and if \(x_0\) is close to \(\overline x\), then we'd expect \(N(x_0)\) to be really close to \( \overline x\). Without all the fancy notation, suppose 5 is a solution to \(f(x)=0\); that is, \(f(5)=0\). We would expect that the initial guess of 5.1 would return something really, really close to 5.
Those are reasonable expectations. And they can fail spectacularly. 

Consider the complex plane, where we plot the complex number \(a+bi\) as the point \((a,b)\) on the familiar Cartesian plane and consider the function \(f(z) = z^5-1\). Since \(f\) is a polynomial with degree 5, we know \(f(z)=0\) has 5 solutions. One of them is real, \(z=1\), and the other 4 are complex. 

Apply Newton's Method to thousands of points in the complex plane and color each point according to the solution of \(f(z)=0\) Newton's Method returns. If Newton's Method returns a solution near \(z=1\), color the point red. If it returns one of the other 4 complex solutions, color the point purple, green, yellow or blue. 

The animated gif above starts with a view of the complex plane with corners at \(-2-2i\) and \(2+2i\). Note how large regions of the plane behave nicely. The big patch of red to the right means lots of points near each other all give the solution \(z=1\). (This means Expectation #2 is holding up: solutions near \(z=1\) return an approximation of \(z=1\).)

But the crazy part is that there are lots of places where the points very close to each other lead to very different solutions. Between the big regions of red and purple there are regions of blue, yellow and green.

And then we zoom in. Over and over we see that the borders between "large" regions of solid color are actually smaller regions of solid color. This goes on forever - no matter how far you zoom in, you will always find that the border between "large" regions of color is made up of a similar pattern of smaller regions of solid color.

The upshot is this: applying Newton's Method to two points that are really close to each other can lead to completely different solutions. That's chaos

The following gif shows the first frame of the gif above in a different way. Newton's Method is an algorithm - a repeated set of steps. We stop repeating once we get close enough to a solution. In the gifs above and below, we indicate how many steps it takes to converge to a solution by the brightness of the color. The darker the color, the more steps it takes. Note how some regions stay black - these do not converge after 50 steps. They might after more, but we stopped after that number in the picture below.

Note how some points converge very quickly - even points that are not close to the solution they converge to.

There are lots of ways to illustrate chaotic behavior. We picked a common one above: showing convergence regions of Newton's Method. Another popular one is shown below.

Start with a quadratic, complex function. We chose \(f(z) = z^2-0.8+0.157i\). For every point in the complex plane, apply this function over and over again. For instance, if we start with \(z_0=1\), applying \(f\) gives \(z_1=f(1) = 0.2+0.157i\). Apply \(f\) again: \(z_2 = f(z_1) = -0.785+0.2198i\). Keep doing this until the results start to get "big." For instance, if you start with \(z_0 = 10\), then \(z_1=f(z_0) = 99.2+0.157i\) and \(z_2 = 9839.82+31.3058i\). Clearly these numbers are getting big. Fast.

Starting with \(z_0=1\) is a different story. After applying \(f\) 250 times, we find \(z_{250} = -1.33+0.575i\), hardly big. Apply \(f\) just a few more times, though, and the result is big: \(z_{255} \approx 1587-2822i\). And once the result is "big," it never gets small again.

Below, we color points in the complex plane according to how many applications of \(f\) it takes to make the result "big." Dark spots get big fast, bright points get big slowly. Pure white spots haven't gotten "big" after 150 iterations of \(f\).

The initial picture is interesting enough, but zooming in tells more of the story. We see that points that "get big fast" are always located near points that do not get big, fast. Chaos. And like our "zooming-in" gif at the top of this post, we see that as we zoom in, we see similar shapes repeated over and over, smaller and smaller.

Below we show the plane as it gets colored in. We see that points that get big, fast, are located throughout the region, as are points that don't get big after 150 iterations.

In both of our examples of chaos, there exist points that never converge. In our Newton's Method example, there are points that never converge to a solution of \(f(z)=0\), and in the current example there are points that never get "big." Never. These points form what is called a Julia Set. Tweaking some things gives the infamous Mandelbrot Set.

So while mathematics brings structure to so much of our lives, it also brings chaos. It shows us behavior that, at present, is beyond our ability to predict and fully understand. And that's awesome.

Consider following us on Twitter; we'll tweet only when a new post is up.

Friday, December 13, 2013

Sonic Booms

Why does a sonic boom ... boom? That is, why is it so loud? Above a plane flies at twice the speed of sound (it's Wonder Woman's plane, which is why you can't see it, just its sound waves), and we can see it sound waves dissipate over time/distance. (The sound waves get less dark to show the sound energy is dissipating.)

Compare this to a helicopter hovering in one spot:

A person standing at the red dot will hear the helicopter with a constant "loudness," or magnitude. Compare this to the person standing at the red dot when the plane flies by, in the picture at top, at mach 2. The guy at the red dot hears nothing until ... BOOM! ... and the plane has already passed him by. Then the magnitude decreases.

Below, we have a plane flying at half the speed of sound. Note how the guy at the red dot hears the plane with increasing, then decreasing, magnitude.

The plane is again loudest once it has passed the guy.

Notice that the sound waves are all distinct, as with the helicopter picture. Compare this to the plane flying at mach 2 above, or the still image of a plane flying at mach 1.3 below.

See how all the sound waves seem to converge at the red dot? Here is the simplest explanation of a sonic boom that I know, which avoids things like compressed pressure waves, etc.: in a sonic boom, you are hearing the sound of a plane from different places in the sky at the same time. In the above picture, there are 6 circles that go through the red dot, corresponding to the idea that that guy is hearing the sound of the plane from 6 spots in the sky at the same time. Of course, in real life, you don't hear sound from distinct, discrete places, but the concept is the same.

By the way, the "cone" that is formed by these circles is called a Mach cone. It is an example of a mathematical envelope, which we discuss in a previous post.

Consider following us on Twitter; we'll tweet only when a new post is up.

Friday, December 6, 2013

Mathematical Envelopes

Start with a circle and let two points go around it, one twice as fast as the other. At each step of the way, draw a line to connect the points. You'll get a picture similar to the one above. This set of lines somehow clearly draws a cardioid. This is an example of a mathematical envelope.(For a gallery of envelopes that is way better than this one, see this.)

The official definition of a mathematical envelope is a bit tricky, so we offer just a pseudo-definition. A "family" of lines is an infinite set of lines, sharing some common trait. In the case above, the common trait is that each line goes through two specially chosen points on a circle. (We of course don't show the whole family, just about 100 of the lines.) The envelope of a family \(F\) of lines is a curve \(C\) such that each line is tangent to \(C\) at a point, and that for each point on \(C\), there is a line in \(F\) that is tangent to \(C\) at that point.  

There are tons of interesting ways of creating envelopes. We start by adjusting the process above. Instead one circle traveling twice as fast as the other, what if one moves only 1.5 times as fast? We get the image below, another cardioid.

One point going around four times as fast as the other gives this image.

You can make your own! When you get some free time, or are wishing you were somewhere else (like when you are in the middle of English class, or a faculty meeting, or getting your molars pulled or spleen removed), pick your own pattern for dot connecting and try it on the image below, with dots helpfully numbered for you. (I highly recommend starting with the "twice as fast" method first, where 1 is connected to 2, 2 to 4, etc. As you go around, note that 30 goes to 60, which is 0 on the diagram, and 31 goes to 62 \(\equiv\) 2, etc.)

If you put pins on a board in the above locations and connect dots with strings, you get string art.

It is a common calculus exercise to note that if \((x,y)\) lies on a circle centered at the origin, then the tangent line has slope \(-y/x\). So it should be no surprise that drawing a bunch of lines through \((\cos\theta,\sin\theta)\) with slope \(-\sin\theta/\cos\theta\) gives the following image:

One of the fun things about all of this is that one can play. Using Mathematica as we do, it isn't hard to change the slopes of the lines and see what comes out. Changing the above slopes from  \(-\sin\theta/\cos\theta\) to  \(\sin\theta/\cos\theta\), we get this image:

This shape has a name. We don't know what it is. (It may be an astroid.) There are ways of determining what the envelope are, but we won't go into that here.

A famous way of creating envelopes is to start with a known curve, then draw through each point a line perpendicular to the curve at that point. This is called the evolute. (The evolute is also the set of all centers of circles of curvature, if you know what that means.) Below, we start with a parabola, then draw the perpendicular lines:

We show one more, starting with an ellipse:

One doesn't have to use a family of lines to create envelopes; any curve will do. Below, we start with a circle \(C\) and a point \(C\) on that circle. Our family of curves is the set of circles with center on \(C\), each passing through \(P\). 

Another cardioid! Pretty cool.

Again, you can use any kind of curve to create an envelope. In the following image we use a family of parabolas. One can define a parabola with a line, called the directrix, and a point, called a focus. We create a family of parabolas by using the red line as the directrix for all the parabolas; the foci for the parabolas lie on the blue parabola, and are indicated with the yellow dot. The image it creates is our MathGifs logo.

Envelopes are important beyond their ability to make pretty pictures. The picture of the cardioid above is related to the sensitivity of certain microphones to sound. In a later post we'll show how we can understand sonic booms in terms of envelopes. 

Don't forget to print out the pic of the points on the circle above and make your own envelopes. If you come up with something cool, show us in the comment section below. If it is really cool, fold it up, put a stamp on it, and mail it to us. Then your envelope really becomes a ... nevermind. Too meta.

Consider following us on Twitter; we'll tweet only when a new post is up.