# Math and Magic

The most inspiring math teacher I had in college was Persi Diaconis, who, before becoming a Harvard math professor, was… a card magician. This made him legendary around the math department, because his path into higher math (he started to learn calculus because it would help him invent even more awesome card tricks) was not exactly the most traditional way of getting into the subject. By the time I met him, Persi was already a leading mathematician and statistician (he’s the guy who proved that you need seven riffle shuffles to randomize a fifty two-card deck, among other things), but he still kept his interest in magic. And while I only got a rough idea of what math-driven magic tricks were like when I studied with him, I finally got a better sense a few years ago, when he published an absolutely, well, magical book devoted to the subject. It’s called Magical Mathematics.

I read the book soon after it came out, and showed my kids a few of the tricks I learned from it. They didn’t get the math, but they liked the tricks. And that was about it, until sometime last year, when my older son started learning card tricks too, via YouTube videos. For a while he was mostly doing traditional sleight-of-hand stuff, but this weekend he showed me a trick that’s very mathematical! It’s simpler than most of the tricks in Persi’s book, but very much in the same spirit. You should see it too. Here goes:

We start with a deck of cards, cut as many times as you like. I hand you the deck, asking you to cut it one last time. Then I show you the top and bottom card in the deck. I’m not going to know what they are, so you need to remember them. Follow along:

We’ll put the two cards back in the deck, say on top, and I ask you to cut the deck again, multiple times if you like, so we lose your cards in the deck:

The trick is to find them again. First, we deal the cards out into four piles:

Next, we combine these piles into two by joining together alternating piles (first and third into one single pile, second and fourth into another). Finally, we flip over one of the piles and riffle shuffle the two piles together. (My son’s been doing all the steps to this point, but I’m going to take over for this step because he hasn’t learned to riffle shuffle yet:)

Now let’s spread out our cards:

Notice that all the cards facing up have the same color… except one. That’s one of your cards!

Flip the deck over. Again, all the cards facing up have the same (other) color. There’s one exception: your other card!

How did we do that?

Unlike magic tricks based in sleight of hand, we didn’t hide anything: what you see is what you get. Except for one thing: you probably didn’t know that the original deck we started with looked like this:

The deck was set up to alternate red and black cards: one red, one black, one red, one black… Knowing that, stop for a moment and try to step through each step of the trick. Can you see how it works? If you can, congratulations! If not, let’s walk through it together:

We started by cutting the deck multiple times. That’s meant to make the audience think we’re making things random, but in fact it just cycles the deck around, and leaves the basic alternating red-black structure in place.

Now the key step: we took off the top and bottom cards, showed them to the audience, and put them back on top — almost, but not exactly, how we found them. That almost is the key to the trick. The point is that those two cards are now in opposite order to the rest of the deck. For example, say the top card was red. At that point, the deck must have been ordered as red (top), black, red, black, and so on, with black (the other card we picked up) on the bottom. After we take off the top and bottom card, the remainder of the deck is ordered as black (left on top), red, black, and so on, with red now on the bottom. And when we put our two cards on top, the order becomes red, black, black, red, black, red, black, red, and so on, with red still at the end. What’s special about our two cards is that they are out of phase with the others. And wherever they happen to go in the deck now, after we cut the cards, that’s how we’re going to find them again.

The way we find them by separating the reds from the blacks, which is what dealing the cards into piles was designed to do. For example, say that after we cut the cards, red was on top. Follow the cards into piles: red (1st pile), black (2nd pile), red (3rd pile), black (4th pile), red (back to the 1st pile), black (2nd pile), and so on. Each pile has all the same color cards — except the two out of phase cards! So piles 1 and 3 will be all red cards, with one exception, which is one of your cards. And piles 2 and 4 will be all black cards, also with one exception, which is your other card. Here’s how it looks under the hood:

Q (you might be asking): Why four piles? Since the colors alternate, wouldn’t two piles be enough?

A: Good math observation! Only it’s harder to keep track of what you’re doing with just two piles (I tried it). Since just one misdeal messes up the color separation, using four piles makes the trick more secure.

Now of course at this point we could just pick up the red pile and the black pile separately, find the off color card in each pile, and be done with things. But… that isn’t very theatrical, is it? So instead we flip one of the piles over, and shuffle them together. Which has exactly the same effect, but looks way cooler!

Again, this isn’t in Persi’s book, but it’s a good introduction to math-based tricks. If you like it, or know some kids who might, I’d very much encourage you to check Magical Mathematics! You can see a couple sample chapters online at the Princeton University Press site:

Chapter 1

Chapter 5

And if you know more tricks in this spirit, my son and I would love to see them!

# First Day of Spring

Don’t look for the start of spring in the calendar. You can’t predict ahead of time when it’ll come, yet you always know it on the day, when something makes you rush outside without bundling up first, and once you’re out, you start inventing reasons to stay out longer, not reasons to come back in.

This year the start of spring came on a Sunday, about a week after the official date. The snow had mostly melted a couple weeks earlier, and the temperature was rising steadily through the early afternoon. My sons and I decided we needed to give the local ball field a try. It can’t be that muddy, can it? We took our baseball things — bat, gloves, and balls — and headed over.

It wasn’t muddy at all, and more than warm enough to play. We tossed a ball around to warm up, then took our regular spots — me pitching, one boy batting, the other catching. Despite the winter layoff, they remembered what to do, where to stand, how to swing. Within a few minutes they were as comfortable with their new metal bat as they had been with a wiffle bat by the end of last summer. They swung and missed often, but got their share of hits too, a few balls going past the infield, boys running happily around the bases when they made contact. It must have looked fun, because pretty soon other kids started wandering over to play. A friend from the school bus, two chatty third graders we didn’t know but who soon seemed like old friends, one quiet boy who knew to take over catching when my sons wanted to go out in the field, still another who was too shy to ask but looked like he really wanted to play.

A batting order was formed. After a couple cycles through it, my younger son announced he wanted to pitch. I was skeptical — but OK, sure, give it a shot. We agreed on how far he should stand from the plate, and he started firing balls in. I stood over to the side and watched. He was no worse at getting the ball over the plate than I had been, and the batting rotation went on — swings, misses, balls hit up the middle, balls hit straight up in the air. Everyone knew to run when they hit the ball. Boys who weren’t up to bat stood out in the field, chased balls, tried to throw to each other, to tag the runner — without much grace, for now. Out here, in the developmental leagues of Montclair, NJ, it’s very much a hitter’s world.

No longer needed in the game, I could look around, taking in the whole park — the field, the pond to my right, the playground to my left. We have been regulars since we moved to town, almost seven years ago now, when the first boy was just a year old and the second was just a plan. How many times have we celebrated the first day of spring here? Around this time two years ago, my older son was in kindergarten, and we came out on a sunny day to find that all his friends from school were at the park too. The kids ran off to play, the parents stood and chatted, everyone happy to see each other, and suddenly my embarrassing suburban fantasy, of a real community and life lived at a sustainable pace, crystallized into something real and true. And then last year, we came here on a similar day, expecting more of the same, only the kids got bored at the playground after half an hour, and went off to join another set of kids playing baseball on the field. They’d never played before, didn’t know what to do, couldn’t hit the ball, and left in frustration, which led directly to a summer’s baseball education through backyard wiffle ball games. And now here we were a year later, starting up a game of our own, pulling in other kids. Oh what Proust could have done with a playground and a ball field.

In the actual day, time passed in a more humdrum manner. First one kid got called home by his parents, then another, and finally it was just the three of us on the field again. I went back to pitching. More time went by, and we all started to drag a bit. I would miss the plate more often than not, and when I did get the ball over, the boys didn’t put level swings on it, and hardly connected any more. Time to go.

We walked over toward the car. I carried the bat, the boys carried gloves and balls. We bumped fists, patted shoulders and backs, complimented each other, and meant it: Good game. And as we walked, I went back even further in time, to pre-parent days, evening endings to long afternoon frisbee games when I was still a student, walking off the field with friends, sweaty and exhausted, arms and legs sore, barely able to see in the approaching darkness. Good game. My sons and I walked off the ball field together, side by side, and it felt like the first day, not just of spring, but of something else too.

# Why Your Kids Should Help in the Kitchen

We were emptying the dishwasher in the morning, and my younger son’s job was putting away the silverware. He brought the silverware basket over to the silverware drawer, and said:

You know what I’m going to do? First I’m going to collect together all the spoons, and put them in the spoon bin. Then I’ll take all the knives and put them in the knife bin. Then I’ll take the forks…

Any idea that a five year old can come up with must be really simple, right? But simple ideas can still be deep and powerful. Among other things, this one is at the heart of an important mathematical technique called Lebesgue integration, which one of my favorite math teachers once explained to me like this:

Say you’re trying to count a really big pile of money. You can stack it really high and count it a bill at a time. Or you could separate it into piles of ones, fives, tens, and twenties, count how many bills are in each pile, multiply the count in each pile by the denomination, and add the results. Lebesgue integration is when you break the bills into separate piles first.

What my son figured out was that if you focus on one kind of utensil at a time, you can work faster because everything you pick up goes in the same place, so you don’t need to think about switching from one bin to another all the time. From a computer science perspective, you’re doing fewer operations. From a math perspective, you’re representing a single function that appears complex (because it jumps around all the time, from knife to fork to spoon to knife or from \$1 to \$10 to \$5 to \$1) in terms of a few simple (constant) functions defined on different domains. I’ve written before about how math is about finding, creating, and making use of order, and this is a great example.

You can apply this idea to the problem of finding the area under a really jumpy curve. Henri Lebesgue is famous, with an integration technique named after him, because he worked out the details, about 100 years ago. But the underlying idea truly is accessible to a five year old. At least, as long as that five year old pays attention to his chores.

# Boyhood

So I was reading my Facebook feed on the bus ride home, with the typical smattering of kid pictures, and I started to think about how there are many people in my life that I don’t get to see that much, but Facebook lets me watch their kids growing into people, with sparks in their eyes and faces that remind me of their parents, and that really feels quite moving. And then I came home and went upstairs to drop off my work things, and my own growing son ran to me enthusiastically, and then he dropped his pants and mooned me.

# Litmus Test

The Eric Garner video is bad enough, but then there is the Tamir Rice video. You can find it online easily enough. The gist of it is that a 12-year old black kid is playing with a toy gun by a playground, and a cop car rolls up, and the cops burst out of the car, and in two seconds the cops shoot the kid dead.

There were, as always, attenuating circumstances. The boy was large for his age, and someone had phoned in a tip about a gun, and said the gun probably wasn’t real, but the last part didn’t get relayed to the cops, and the tipster also said the kid might be 20, which did get relayed to the cops… but still. Tamir Rice is a 12-year old kid with a toy gun, the cops see Tamir Rice, they shoot Tamir Rice, and Tamir Rice dies.

As a parent, with boys, who are large for their age, I can see only two possible ways you can react to this:

1.  You can be completely, utterly, genuinely terrified that this might happen to your kid. Terrified enough that you go out and protest, or the equivalent, because if you don’t, you know down deep that you haven’t done all you can to keep your kid safe.

2.  You can be horrified, and even scared up to a point, but down deep you figure that this probably won’t happen to your kid, even if your kid does something goofy or weird at the playground once in a while, because, you know, you live in a different kind of town, and your kid isn’t… isn’t… bl

And then you have to go out and protest too. Don’t you?

# Tom Lehrer and Moral Education

Tom Lehrer has done many great things, but one of my all time favorites is a sly dig at McCarthyism that he managed to sneak in toward the end of an Electric Company song. Pay attention around the 1:50 mark of this video:

When I came to the US as a kid (age 7), I watched a lot of PBS kids’ shows to learn English. The Electric Company was my favorite, and for some reason that one song really imprinted itself on my subconscious brain (though I figured out that it was by Tom Lehrer only a few years ago). I don’t know for sure how much it contributed to my moral education, but I like to think that maybe it had some impact.

As a grown up, I love the premise that if you think things through, you really can frame current events, and the issues of right and wrong embedded therein, in terms that kids can understand. That’s helped a lot with my own kids over the last few days as we try to process the events in Ferguson and now New York City.

# Fall Math Notes I: The Area Table

This fall, I’ve been teaching a math workshop for grade school kids (grades 3-6) in my town. Once a week for an hour and a half, covering the typical topics for kids this age: multiplication, division, place value, fractions. We’ve wrapped up now (last week was the last class), so I wanted to note down a few impressions before I forget it all.

One thing that worked pretty well was identifying multiplication and area. I started one of the first classes with the following exercise: take a grid (say 10 by 10). Pick a box in the grid, count the number of boxes that are above and/or to the left of that box, and write that number in your box. (Alternately, draw a rectangle extending from the top left of the grid to the box you picked, and count the number of boxes in that rectangle.) For example, if you pick the box in the 4th row (counting from the top) and 5th column (counting from the left) of your grid, then the boxes above and to the left are marked in green in the picture below, and there are 20 of them:

You don’t need to do anything more here than count boxes, but of course the point is that 20 boxes = 4 rows × 5 columns and also that 20 is the area of the green rectangle (each 1 by 1 box has an area of 1 square unit, so 20 boxes is 20 square units of area).

I had the kids repeat this for every box in the grid. The number you write down in each box is the product of the corresponding row and column, and you end up with the good old multiplication table. I liked how this worked out for a few reasons:

1. It was a way for the kids to figure out the multiplication table themselves, and get it right. No memorization, and little required in the way of prerequisites or arithmetic skills. (When you’re working with kids with different backgrounds, that’s a very important advantage.) The kids were pretty enthusiastic about doing it.
2. It was a big enough table that counting boxes over and over got tedious, so the kids started to look for shortcuts. They noticed right away that the numbers in each row increase by the index of that row (e.g., 5th row = counting by 5’s). That helped them fill the table out pretty quickly. It also gave us an excuse to talk about why that worked (each time you take a step to the right in the 5th row, you add 5 boxes).
3. When we were done, we didn’t just have a multiplication table, we had good geometric intuition to go with it. Meaning, we knew how to think of the table as a family of overlapping rectangles, and every number in the table as an area! (I almost wanted to call the thing the area table instead of the multiplication table, but decided I shouldn’t saddle the kids with made up terminology.) Then we could find more patterns in the table, and try to explain those patterns geometrically. For example, a 5 × 5 square has one more box than a 6 × 4 rectangle (25 = 24 + 1), a 7 × 7 square has one more box than an 8 × 6 rectangle (49 = 48 + 1), etc., and we could explain that by moving boxes around. For another example, if you just stick to the nested squares, the number of boxes you need to add to each square to get the next square grows in a linear way (4 = 1 + 3, 9 = 4 + 5, 16 = 9 + 7, 25 = 16 + 9, 36 = 25 + 11, and so on), and you can see and count the extra boxes explicitly. There are hints here of algebra (x2 – 1 = (x + 1) (x – 1)) and even calculus (derivative of x2 is 2x), and you can get at them just by counting and moving boxes.

More to come (Division! Fractions! Place value!). You can’t wait, can you? Meanwhile, happy Thanksgiving.