Follow Me!

Follow mmmaaatttttt on Twitter

Lego Math Maniac

Though I have lived in Southern California for several years, I have never been to Legoland, a theme park based around the classic (and awesome) children’s toys.  The park perennially sits in the shadow of more popular parks in the region (e.g. Disneyland, Universal Studios, and the Banana Club Museum), and its prices make it hard to justify a visit for an adult male with no children, no matter how many fond Lego memories he may have from his childhood.  However, given the recent attention Lego has received in the context of mathematics, it may be time to finally plan a trip.

A recent article on Wired’s website discusses the mathematics of Lego – more specifically, it highlights an article on the complexity of Lego systems.  As any child will tell you, Lego sets can vary from very simple, small sets, to much larger and more complicated ones.  As a simple corollary, smaller sets will have fewer pieces, and larger sets will have more pieces.  But how does the number of types of pieces grow as the size of the set grows?  For example, if a 100 piece set consists of 10 different types of pieces, is it reasonable to guess that a 1000 piece set will consist of 100 different types of pieces?

In a word, no.  Though the number of different types of pieces will grow as the size of a set grows, it will grow slower than the size of the set (in other words, it will grow sub-linearly).  To put it another way, as the size of the Lego set grows, rather than building more and more new types of pieces, the same types of pieces that are present in smaller sets tend to be used in new ways.  The effect is that the proportion of distinct piece types decreases as the size of the set grows.  From a mathematical standpoint, if we let y denote the number of different types of pieces, and x be the number of pieces, then this power law is giving us the following equation:

y = Ax^{b},

for some constants A and b, with b between 0 and 1.  While y grows as x grows, it does not grow as quickly as x itself.

Taken in a broader context, though, this should not be surprising.  Examples of similar phenomena are prevalent throughout nature, as well as in made-made phenomena such as urban planning.  One example cited in the Wired article is Kleiber’s Law, which states that the ratio of an animal’s metabolic rate to its mass tends to decrease as mass increases (in other words, larger animals are capable of metabolizing more efficiently).  Here’s an article that discusses an analogue of this power law in the context of brain development, and relates this to the development of cities.

So the next time you give a Lego set to a child, feel free to explain this connection – I’m sure any child will welcome the math lesson (at least, any child worth giving a Lego set to in the first place).  It’s also worth noting that this phenomenon is most likely not unique to Lego sets – I am eagerly awaiting a similar report on the mathematics of Tinkertoys – though unfortunately, in this case the number of piece types seems not to have increased in nearly a century.

Car Talk Mathematics

Happy 2012! I hope you all has a restful and calorie-filled holiday.  For my part, the holidays typically involve a fair amount of driving, and ergo, a fair amount of listening to podcasts.  To that end, I’d like to ease into a new year of mathematics by considering a simple puzzle, one which was featured recently on NPR’s Car Talk.  If you are not fortunate enough to have listened to this show, it centers on two brothers from Cambridge, Massachusetts, affectionately known as Click and Clack, the Tappet Brothers (though their real names are Tom and Ray Magliozzi).  Each week, in between a fair amount of good-natured banter, the brothers field a variety of automotive questions from callers nationwide.

Even XKCD is on the Car Talk bandwagon! (Click the image to go to the source)

Most significant to our present discussion, however, is Car Talk’s weekly diversion known as the Puzzler.  Each week, the brothers read a Puzzler (i.e. a brain teaser) to their listeners and request solutions.  The Puzzler’s solution is revealed the following week, and a new Puzzler is then presented; moreover, one of the correct listener submissions is chosen at random, and the winner receives a gift certificate for some Car Talk schwag.  While these puzzles are sometimes car-related, this is not a prerequisite, and indeed the puzzler I would now like to discuss makes no mention of cars.

Here’s the puzzle, with wording modified slightly from Car Talk’s website: Suppose there are 20,000 lights in a row, all turned off.  One person comes through and pulls the cord on every light, turning each of them on.  A second person then comes through and pulls the cord on every second light. A third person then pulls the cord on every third light, and so on. After the 20,000th person has gone through the room, which lights are turned on?

This problem also goes by the name of the Locker Problem, with open and shut lockers substituting for on and off lights.  But no matter how you contextualize the problem, the solution is the same.  To get some idea of what the answer should be, let’s consider what happens just for the first few (say, 10) light bulbs.  Feel free to think about this problem on your own before continuing on!

After the first person walks through the room, all the light bulbs are on.  So, the first 10 light bulbs will look like this:

After every second cord is pulled, half the lights will be on, and half will be off:

Now here’s where the fun begins.  When every third cord is pulled, off lights will turn on, and on lights will turn off.  This means that the arrangement of the first ten lights will look like this:

And, when every fourth cord is pulled, we get the following picture:

You can probably fill in the rest.  Note that when every 6th, 7th, 8th, 9th, or 10th cord is pulled, only one light in first 10 switches, so most of the work is already done.  In the end, the string of the first 10 lights will look like this:

Here we see that three of the first ten lights remain lit: the 1st, 4th, and 9th.  The astute reader will note that 1, 4, and 9 all share a common property; they are all perfect squares (1 = 12, 4 = 22, 9 = 32).  The question to be asked, of course, is whether this pattern continues, and if it does, why?

To answer these questions we’ll need to think a bit more deeply about what’s going on.  First, when does a given light bulb in our string of 20,000 get its cord pulled?  Extrapolating from the first few cases, we see that if a person goes through the chain and pulls every dth cord, then the light bulbs with their cords pulled are precisely the ones whose numbers are multiples of d.  Therefore, the nth bulb’s cord is pulled once for every divisor of n.  More concretely, we see for example that the 12th light bulb will have its cord pulled 6 times: by the 1st, 2nd, 3rd, 4th, 6th, and 12th person, since 1, 2, 3, 4, 6, and 12 are precisely the divisors of 12.

What does this divisibility information tell us about the status of a given light bulb?  Since all the lights start in the off position, we see that a light will be off at the end if its cord is pulled an even number of times, and it will be on at the end if its cord is pulled an odd number of times.  In other words, the nth light will be on at the end of this process precisely when n has an odd number of divisors.

All we need to do now is convince ourselves that the numbers with an odd number of divisors are precisely the squares.  There are a couple of ways to do this.

Way 1: Pick your favorite whole number n.  For any divisor d of n, n/d is also a divisor (for example, if n = 30, the fact that 5 is a divisor immediately tells us that 30/5 = 6 is a divisor too).  In this way, we can naturally count up all the divisors of n in pairs.  Because of this, the only way we can have an odd number of divisors is if one of the pairs has the same number repeated twice, i.e. if for some divisor d, d and n/d are equal.  But if they are equal, this means that n = d2, in other words, n is a square.

Way 2: By the fundamental theorem of arithmetic, Any positive whole number n > 1 can be written in an essentially unique way as a product of prime numbers, i.e. for any n > 1 we can write

n = p_{1}^{k_{1}}p_{2}^{k_{2}}\ldots p_{r}^{k_{r}},

where the numbers p_{i} are primes, and the exponents k_{i} are greater than zero (for example, 180 = 2^{2} \cdot 3^{2} \cdot 5).  In particular, any divisor of n must be composed of the same primes as n itself, so that if d is a divisor, we can write

d = p_{1}^{m_{1}}p_{2}^{m_{2}}\ldots p_{r}^{m_{r}},

where each exponent m_{i} is no larger than k_{i} (for example, 12 is a divisor of 180 but 24 isn’t, since 2 goes into 24 three times but into 180 only twice).

How many divisors are there? Well, p_{1} could divide d as few as 0 times, or as many as k_{1} times – we have k_{1}+1 different ways to choose the exponent on p_{1}, corresponding to the numbers 0, 1, 2, …, up to k_{1}.  Similarly, we have k_{2} + 1 different ways to choose the exponent on p_{2}, and so on for each prime, so that there are k_{r} +1 different ways to choose the exponent on p_{r}.  By the fundamental counting principle, this means that the number of divisors of n is equal to

(k_{1}+1)(k_{2}+1)\ldots (k_{r}+1).

Remember that our light will be on only if the number of divisors is odd, in other words, only if the above product is odd.  Notice that if any term in the above product is even, the product itself will be even – so in order for the product to be odd, each term in the product must be odd.  Since each k_{i}+1 must be odd, this means that each exponent k_{i} must be even.  But if each k_{i} is even, then k_{i}/2 is always a whole number, so

p_{1}^{k_{1}/2}p_{2}^{k_{2}/2}\ldots p_{r}^{k_{r}/2}

is a whole number whose square is equal to n.  Hence, once again we conclude n is a square.

There are plenty of variants to this problem worth pondering – for example, what if people only come in and pull every dth cord only for d prime?  Or, what if instead of the 2nd person pulling every 2nd cord, and the third person pulling every 3rd cord, the second person pulls every 2nd cord twice, the third person pulls every 3rd cord three times, and so on?  No doubt you can come up with some variants on your own as well.

If you prefer the locker version, here’s an interactive site where you can watch with satisfaction as lockers open and close.  No matter what model you use, though, this is a cute little problem on integers and their divisibility, and the result can be surprising for first time viewers.  So kudos to Car Talk for discussing this problem on a national stage! (Kudos also to Tom for drawing my attention to this particular episode of the program.)

 

Two Cups of Mathematics

With the holidays in full force, many of you are no doubt spending time in the kitchen; those of you who aren’t are nevertheless reaping the benefits provided by those who are.  ‘Tis the season of baked goods, and if you are lucky enough to have a family member who knows how to bake, then for the month of December you will eat like a king.

This dude knows a thing or two about baked goods.

For my money, the best part of the baking process (aside from the delicious final act) is the careful and precise initial measurement of the ingredients.  Keeping an accurate account of the relative proportions of each piece of the recipe is a hallmark of baking, and reflects the nature of baking itself: one part art, one part science.  Unlike some other culinary arts, the measurements really do matter.  Screw up these proportions and those fudgy brownies you want to make will be too cakey (or vice versa).

But what in the recipe accounts for the qualitative differences we see and taste in the wide assortment of baked goods available at this time of year?  This question has been mulled over by electrical engineer and baking aficionado Michael Ohene, who in this article essentially considers all baked goods as a function of three parameters: Moistness Value, Butter Content, and Egg Content.

How are these values computed?  First, each wet and dry ingredient is assigned a value per cup – these values are used in the calculations to follow.  For examples of wet ingredients, buttermilk has a value of 1 per cup, applesauce has a value of .6 per cup, and so on.  With dry ingredients, things like flour and almond paste have a value of 1 per cup, while peanut butter has a value lightly less (2/3 per cup).  More detailed tables of values can be found at the link given above.  Note that flavorings, leavenings, seasonings, and food pieces (such as whole walnuts) are not included in the calculations.  You can think of these values as a weighing the ingredients according to their relative wetness or dryness.

Once the value of each ingredient is known, that value is multiplied by the volume of the ingredient appearing in the recipe, and these products are totaled up for both wet and dry ingredients – let me call these final values the wetness value and the dryness value, respectively.  Let’s see how this works in practice by analyzing my wife’s spectacular recipe for Pfeffernusse cookies (they are delicious bites of gingerbready goodness).  The ingredients are as follows:

3/4 cup molasses
1/2 cup butter
2 large eggs
4 1/4 cup all purpose flour
1 1/4 teaspoon baking soda
1/2 cup white sugar
1 1/2 teaspoon cinnamon
1/2 teaspoon clove
1/2 teaspoon nutmeg
dash of pepper
confectioners sugar

(In case you’re curious, here’s the recipe, cribbed from my wife’s 8th grade German class:

In a saucepan, combine molasses and butter. Stir until butter melts. Cool to room temperature. Mix in the eggs. In another bowl combine flour, baking soda, sugar, cinnamon, cloves, nutmeg, and a big dash of pepper. Add the flour mixture to the molasses mixture and mix well. Chill for 1-2 hours or overnight. Shape into 1”inch balls. (These can be frozen after this point and baked later if desired) Bake on greased cookie sheet at 350 degrees for 8-9 minutes, they should still be somewhat soft as they will continue to cook after they come out (underdone is better than overdone with these). Cool a bit and role in confectioners sugar. Makes 4 1/2 dozen cookies.)

Like a child who has eaten too much candy, these pfeffernusse cookies are the illest.

According to Mr. Ohene, there are three wet ingredients (butter, large eggs, and molasses) and one dry ingredient (flour).  The rest of the ingredients are not considered in the computations.  Butter has a corresponding value of .5, large eggs have a value of 1/6 per egg, and molasses has a value of 1.  Therefore, the wetness value is .5 times the volume of butter, plus 1/6 times the number of eggs, plus 1 times the volume of molasses, or

.5 x .5 + 1/6 x 2 + 1 x .75 = 1.33.

Similarly, flour has a corresponding value of 1, so the dryness value is simply 4.25, as the recipe calls for 4 1/4 cups of flour.  So the wetness value is 1.33, and the dryness value is 4.25.

The Moistness Value is the ratio of these two numbers, i.e. the ratio of wet to dry.  Meanwhile, the Butter Content is the ratio of the value coming from the butter to the dryness value, and the Egg Content is the ratio of the number of eggs to the dryness value.  In the example of Pfeffernusse, we see that the Moistness Value is 1.33/4.25, or about .3129.  Similarly, the Butter Content is .25/4.25, and the Egg Content is 2/4.25, or .0588 and .4706, respectively.

Varying these three values distinguishes different baked goods from one another.  Want a baked good with relatively high Moistness Value and Butter Content, but relatively low Egg Content?  Perhaps a coffee cake is what you’re after.  How about a moderately wet dough with high Egg Content and low Butter Content?  In this case, maybe a brioche is what you’re after.  A periodic table of sorts that plots baked goods according to these three values can be found here; note that the Pfeffernusse discussed above fall into a square marked “biscotti.”  It’s quite possible that the Pfeffernusse dough would make for good biscotti, though the process of baking is quite different for these two treats, since biscotti are typically twice baked.

You can do other cool things with this analysis.  For example, you can compute these values for a list of ingredients and make an educated guess about what type of baked good the ingredients will produce.  Also, one can automatically create recipes for baked goods based solely on the qualities one would like that baked good to have.  This service is provided here – you entire the baked good you want, the desired level of richness, and the desired level of sweetness, and it creates a recipe for you on the spot!  So if you can’t find just the right recipe for what you want, I’d encourage you to try this recipe creator on for size and see what comes out.

Whatever you or your family decide to bake this holiday, know that adding a little mathematics to the mix never hurt.  And, as evidenced by the work of Mr. Ohene, added analysis can provide some interesting and unexpected insights. Thanks go to him for sending me the links that I’ve shared with you here!

An Introduction to Pumpkin Chunkin’

In a recent episode of ABC’s Modern Family, Cameron and Mitchell (the show’s unambiguously gay duo) are with some friends talking about Thanksgiving when Cameron decides to tell a story from his youth which, in his opinion, is quite compelling.  Mitchell knows better, but doesn’t have the heart to tell him that this particular story suffers from some basic structural flaws.  As Mitchell puts it, the story can be summarized as follows: “Once Cam and his friends tried to slingshot a pumpkin across a football field.  Three seconds.  That’s all you need to tell that story.”  Readers in the U.S. can see the full clip below:

Needless to say, Cameron’s version of the story is much more embellished. In his rendition, their experiment was a success; as he puts it, the pumpkin flew across the field, “goal post to goal post.”

When I first heard him say this, my initial thought was “Is Cameron telling the truth?”  How likely is it that a pumpkin, launched from a slingshot at one end of a football field, could sail through the air to land on the other side?  Note that his story actually ends with the pumpkin falling through the sun roof of someone’s car – this outcome is, of course, highly implausible, and therefore casts a shadow of doubt upon the entire story.  While the sunroof claim would be difficult to verify, one can at least use some basic math and physics to test the plausibility of the first portion of the story.

We would like to be able to find a formula for the distance Cameron’s pumpkin should travel.  Key to our analysis is the conservation of energy principle, and Hooke’s Law.  In particular, we will assume that the slingshot behaves like a spring, i.e. the potential energy it stores is proportional to the square of the displacement (for example, stretching the slingshot two meters gives you four times the potential energy as stretching it one meter).  So, if Cameron and his friends stretched the slingshot a distance of x meters, the slingshot would then store a potential energy of \frac{1}{2}kx^{2}, where k is the spring constant and depends on the physical properties of the slingshot.

Now let us invoke the conservation of energy principle: when the slingshot is released, suppose all that stored potential energy will be converted into the kinetic energy of the pumpkin.  The formula for the kinetic energy of an object is \frac{1}{2}mv^{2}, where m is the object’s mass, and v is the object’s velocity.  So, when the pumpkin is released, by conservation of energy, this kinetic energy should be the same as the potential energy the system had before we chunked the pumpkin.  In other words,

\frac{1}{2}kx^{2} = \frac{1}{2}mv^{2},

which, with a bit of algebra, tells us that the initial velocity of the pumpkin when it comes out of the slingshot must be x\sqrt{\frac{k}{m}}.

 

These poor little guys have no idea what's in store for them.

So we have an equation for the velocity of the pumpkin in terms of the spring constant k, the distance x we pull the slingshot, and the mass m of the pumpkin.  Let’s not forget our main goal, though – what we’re ultimately interested in isn’t a formula for the initial velocity of the pumpkin, but rather the distance the pumpkin travels.  With a little more physics, it’s not hard to get from one of these pieces of information to the other.

More specifically, we have a very good understanding of projectile motion.  As I’ve discussed before, if one ignores air resistance (as we will do for now), all the equations of projectile motion can be derived from the fact that the acceleration due to gravity is a constant, g \approx 9.8 meters per second per second.

Using this fact, suppose you throw an object with an initial velocity v_{0} at an angle \theta to the horizontal.  Then if one sets the initial position of the object to have coordinates (0,0), the x-coordinate of the object at any time t will be given by tv_{0}\cos(\theta), and the y-coordinate of the object at any time t will be given by tv_{0}\sin(\theta) - \frac{1}{2}gt^{2}.  Using these formulas and a bit more algebra, one can determine that the distance d an object will travel in the x direction can be written in terms of the initial velocity, the angle \theta, and g, via the formula

d = \frac{v_{0}^{2}\sin(2\theta)}{g}.

 

Example trajectory of an object shot with an initial velocity v at an angle A. The distance the object travels in the x direction is given by the above formula.

To recap: we have the distance as a function of the initial velocity, the angle the pumpkin is shot from, and the acceleration due to gravity.  We also have the initial velocity in terms of the distance the slingshot is stretched, the mass of the pumpkin, and the spring constant.  Combining these two formulas, we find that

d = \frac{kx^{2}\sin(2\theta)}{mg},

and we now have the desired formula for the distance the pumpkin travels.

Let’s check Cameron’s story against this formula.  If the pumpkin really went from goal post to goal post, the distance it traveled in the x direction must have been at least 120 yards (100 yards for the field of play, plus 10 yards for each end zone).  This is roughly 109.7 meters.  Therefore, we must have d \geq 109.7.

On the right side of the equation, the term \sin(2\theta) is maximized when \theta equals 45°, and in this case \sin(90)=1.  So after making this simplification, we see that in order for Cameron’s story to be true, it must be the case that

\frac{kx^{2}}{mg} \geq 109.7.

The acceleration due to gravity is known, but we need to provide estimates for m, k, and x.  The mass m is the easiest to estimate; let’s say the pumpkin is around 10 pounds (roughly 4.5 kilograms).  To be generous, we’ll even round down to 4 kilograms.  What about the distance the slingshot is stretched?  Based on the slingshot used in the episode, it’s unlikely the slingshot in Cameron’s story would have been stretched more than 2 meters or so, but let’s again be generous and say it’s stretched 3 meters.  Plugging in these values, we would have:

k \geq 109.7 \cdot 4 \cdot 9.8/9 \approx 478,

where the units on k are Newtons per meter.  Since one pound is approximately 4.45 newtons, this is saying that the spring constant is about 107 pounds per meter – in other words, for each meter you stretch the slingshot, you need to exert 107 pounds of force.  To put it another way, to stretch the slingshot 3 meters or more, you’d need to exert 321 pounds of force.

This seems like quite a lot, though Cameron is a large fellow.  But recall we were being generous, both in our computation of the spring constant and in our estimate of the pumpkin size.  We also neglected air resistance in this model, but air resistance probably has a non-negligible impact here – not only will it slow down the pumpkin’s forward motion, but it also decreases the optimal angle from 45°.  So in a real world situation, I’d have to remain skeptical of Cameron’s story.  On the other hand, these calculations don’t necessarily rule it out entirely (though a more sophisticated analysis might).

For more on the physics of pumpkin chunkin’, here‘s an article from last year courtesy of Wired.  For related trajectory issues, Angry Birds also provides plenty of fodder.

The Calculus Diaries

As the holiday season begins, I recently felt compelled to read through a gift I received over the holidays last year, a book called The Calculus Diaries.  Written by English major Jennifer Oullette, who, by her own admission, had to overcome a not uncommon fear mathematics to write it, the book attempts to do what any reasonable Calculus course ought to do, but in front of a larger audience: convince the reader of the universal applicability and beauty of the subject.

Unlike most Calculus textbooks, however, Oullette’s book has an extra helping of sympathy for its audience.  Oullette’s goal is not necessarily to make her readers expert mathematics students; instead, she focuses on unifying seemingly disparate types of problems under the umbrella of Calculus.  Included amongst these examples are applications of Calculus to the equations of motion, thermodynamics, surfing, and the spread of disease.  The wheel is not being reinvented here – most of these examples (with the possible exception of what Calculus tells us about the optimal strategy in the event of a zombie outbreak) should be covered in a Calculus course.  But since Oullette’s goal is to appeal to the people who never took Calculus, this overlap is likely intentional.

Writing about mathematics for a general audience can be a difficult balancing act.  If the language is too technical, the average reader may become confused and frustrated; on the other hand, if the language isn’t technical enough, the reader may not learn much of anything, so what’s the point of writing in the first place?  Unfortunately, I found Oullette’s book too frequently to be weighted towards the latter of these two extremes.  Though the book has the word “Calculus” in the title, there’s nary an equation to be found until the appendix, where all the scary mathematics has been relegated.  While the main body of the text offers well-written explanations for the main ideas, ultimately the writing feels too broad because Oullette refuses to get into the nuts and bolts of Calculus even a little bit.  I’m not saying we need another Calculus book in the market, but ultimately this book is extremely limited in its ability to describe what Calculus is actually like, because the very language of Calculus is barely used.

I realize, of course, that I am probably not the target audience for a book like this, so I asked my wife to read through the prologue and give me her thoughts.  While she said she found the beginning of the book interesting, she didn’t really seem compelled to continue reading.  There isn’t much I can infer from a sample size of one, but it seems to me like reading this book to try and overcome a fear of Calculus is a bit like reading books about French cooking and Louis XIV to try and overcome a fear of learning a foreign language.  Useful applications are presented, but the nature of the beast itself is never really tackled.

Having said that, if you’ve never taken a Calculus course, or have no idea what the word “Calculus” really involves, this book may be a good starting point for you.  It certainly won’t make you an expert, or give you many problems to solve, but if you have a fear of mathematics, you can think of this as dipping your toe in the water.

11/11/11. Great.

To the question making the news circuit today (“Does today’s date have any special significance?”) I believe an article at Scientific American provides the most compelling answer: no.  Not only does the article brush aside suggestions that this day might have some deeper meaning, but it also spends some time discussing why such numerological curiosities capture our collective imagination to the extent that they do.  If you only read one article about 11/11/11 today (or two, I suppose, since you’re already reading this), let it be that one.

If you are a masochist like me, though, there are plenty of ridiculous articles floating around today to help you get your blood boiling.  One of my favorites comes from today‘s Philadelphia Inquirer.  It’s full of gems like:

  • One may be the loneliest number, [La Salle University math teacher Stephen] Andrilli said, but 11 ranks among the most odd – and not just because it isn’t even. He sees 11 as sort of a netherworld number – one more than the familiar 10, one less than an even dozen. Uhh, what?  What does any of this even mean?
  • In geometry, Andrilli said, an 11-sided polygon is called an “undecagon” – the shape of the one-dollar coin in Canada, whose people have a particular affinity for 11. Little known-fact: the Canadian people’s love for the number eleven has been the subject of intense research among anthropologists for centuries.  Oh wait – no, of course it hasn’t.  Because that would be stupid.
  • Weirdly, the sum of 1,111 multiplied by 1,111 is 1,234,321, another numerical palindrome. Do editors no longer know the difference between the words “sum” and “product”?  As written, this sentence also makes no sense.

To its credit, the article does state that all of the listed coincidences involving 11 only show “the human propensity for seeing patterns where none exist.”
Not all articles may take the day with a healthy grain of salt, though, so make sure not to get caught up in all the 11/11/11 hubbub.  It will be difficult, I know.

Math of Macarons

A few weeks ago, I was downtown with the missus when we stumbled upon the Bottega Louie Restaurant and Gourmet Market.  The window display was enticing, so we went inside and discovered, among other things, a bakery.  This one’s focus was the macaron, one of many sweets aiming to topple the cupcake as the trendiest dessert, and so for a town obsessed with the current trends, it is no surprise that Los Angeles is home to several similarly specialized patisseries.

Though smaller than the average cupcake, the macaron is also more labor-intensive, and is therefore frequently on the more expensive end of the confectionery spectrum.  The macarons at Bottega Louie, for example, will run you $1.75 each.

One of many delightful flavors

If you need a sweet fix, though, a single macaron may not be enough.  Anticipating such a first-world problem, Bottega Louie also offers boxes of macarons for purchase.  The boxes come in three sizes: the small holds five macarons, the medium holds thirteen, and for the true Francophiles, the largest box holds forty five.  If you buy a box, you can fill it with whatever flavors you like, and can then eat to your heart stomach’s content.

What does any of this have to do with mathematics?  As with so many things, a quantitative eye is useful when it comes time to look at the bottom line.  While the prices of most things decrease with scale – each donut in the purchase of a dozen is cheaper than the purchase of an individual donut, for example – in the case of these macarons, such scaling does not occur.

Let’s dig into some numbers.  The small box of macarons costs $10, or $2 per macaron.  This is more than a 10% increase in the price per macaroon; essentially, one is paying an extra $1.25 for a fancy little box.

What a tiny, fancy box.

Things are slightly better if you go bigger.  The medium box is $25, as compared to $22.75 for thirteen individual macarons.  That comes out to roughly $1.93 per macaroon, or a cost of $2.25 for the large box.  The largest box will run you $80, as compared to $78.75 for forty five individual macarons.  Equivalently, the cost is around $1.78 per macaron, and the additional cost of the box once again comes to $1.25.

In particular, it seems a little strange that the smallest and largest boxes both incur an additional $1.25 charge, while the one in the middle is an extra $2.25.  The mathematician in me would much rather see the box in the middle priced at $24, and the consumer in me would rather see all the boxes be cheaper per macaron than buying them individually.

Unfortunately, in the macaron game, this type of pricing is apparently not unheard of.  There is another small chain of macaron shops known as ‘lette, with several locations throughout the Los Angeles area.  I stopped in one this weekend and found the following prices displayed on the wall:

It’s not all bad news this time around.  While the smaller boxes cost more per macaron than buying individually ($2 each for the mini box, $1.75 for the box of six), the larger boxes are thankfully cheaper (around $1.63 each for the box of 12, around $1.58 for the box of 24).

In either case, though, the moral is the same: when it comes to macarons, make sure you do the math.  While we are all accustomed to the idea that larger purchases correspond to lower costs per unit, these examples show this is not necessarily the case.  If you’re only interested in stuffing your face, make sure to take a moment to crunch the numbers, as the best deal may not immediately present itself to you.

Math + Halloween, Part 4

It’s that time of year again.  If you are looking for some math-themed costume ideas, then look no further.  Though it gets harder to keep this tradition with each passing year, here are a few ideas is you’re looking to rock that mathematical look at whatever event you are planning to attend during this frightful Halloween season.  Ideas from previous years can be found here, here, and here.

Without further ado, let’s begin!

1. Tony Stark

Yes, yes, I know – since Iron Man hit the screens in the summer of 2008, the titular character has become a popular costume idea, joining the ranks of comic book icons like Superman and Spiderman.  I’m not talking about dressing up as Iron Man, though.  Instead, I am recommending a costume based on the man inside the suit – Tony Stark, playboy billionaire and (more importantly) mathematical wünderkind.  All you really need is some delicately coiffed facial hair and a glowing circle on your chest.  Aside from that, the world is really your oyster.  You could go as classy Tony stark, for example:Or, if you’re looking for a more rugged look, you could try prisoner of war Tony Stark:

As with many things in life, the only limit is really your imagination.

2. Rubik’s Cube

I know, this bears a striking similarity to Rubik’s cube head from one of my earlier posts – but this one is even better, because not only does it drape over your body, it also explicitly states you are a Rubik’s cube, for those guests at the event you attend who have been living in a cave for the past thirty years.

RetroCRUSH has the costume on a list of the worst Halloween costumes of all time, an honor with which I must respectfully disagree.  I will concede, though, that if you are looking to score some ladies (or fellas), this may not be your best option.

While we’re on the subject, though, I’d like to send a quick shout out to Parks and Recreation for featuring Rubik’s Cube Head as a costume in their recent Halloween episode.  Here’s a picture of that fantastic party attendee standing next to Rob Lowe, who is sporting a less exciting Sherlock Holmes costume.

Rob Lowe next to Rubik's Cube Head

3. Human Calculator

This one requires some work, but the payoff may be worth it.  First, one must decide what type of calculator to become.  Then one must decide on the size – should it be a full body costume, or centered only on the torso, for example?  No matter what path you choose, however, the most important thing is getting the details right.  Nobody likes a costume made by an inferior craftsman (or craftswoman, for that matter).

Here is an example of a calculator costume gone right.  Note the pride this individual takes in his work.  No doubt he secured many digits on Halloween.

Click to go to the source link.

No matter what you ultimately decide, I hope your Halloween is a good one.  See you next year!

A Mathematics Community

Whether knowingly or not, NBC Thursday night comedies have made occasional dalliances with mathematics.  For example, you can see here for a mathematical discussion inspired by The Office, and here for one inspired by Parks and Recreation.

Today I would like to add to this esteemed list the show Community, now in its third season on NBC’s Thursday block.  As the title indicates, the show centers around a group of friends who are students at the fictional Greendale Community College (how this formula will pan out if the show lasts more than four seasons is uncertain).

In a recent episode (titled Competitive Ecology), the gang divides themselves up into pairs of lab partners for Biology class, but they quickly discover their pairings are less than ideal – especially since, with an odd number in the central crew, one member must pair up with someone who is not in their clique.  Their first assignment is to build a terrarium, and with the deadline quickly approaching, they need to find away to shuffle around the pairings and get their assignment done on time.

Once they’ve decided to change partners, a debate ensues about the fairest way to switch up their initial pairings.  Finally, frequent ringleader Jeff Winger (played by Joel McHale) proposes the following solution (note that Abed is another member of the central study group, while Todd is the outsider who found a turtle for his terrarium earlier in the episode):

Ok, let’s make this simple, and do it like student housing.  Everyone write down their lab partner preferences from one to eight.  Abed, you’re a computer, you figure out a way to put us in our optimal pairings.  And before you all go putting Todd down last, don’t forget, he comes with a turtle – you’re halfway done.  How does that sound?

Indeed, Jeff – the problem is more closely related to student housing than you imagine.  Before spoiling the math connection, though, allow me to show you the following dialogue, which takes place once Abed has determined the new pairings.

Abed: Umm, all right.  Yep.  According to my system, Annie’s gonna be with Shirley, Pierce is with me, Troy’s with Britta, and Jeff is with Todd.

Annie: Okay, let’s get to work!

Jeff: Uhh, wait.  Umm, how did I end up with Todd?  No offense, but he wasn’t exactly at the top of my list.

Todd: None taken.

Abed: It’s what the algorithm dictated.

Jeff: And we’re just supposed to trust your algorithm?

Abed: Are you questioning my algorithm?

Jeff: Not necessarily – is your algorithm above questioning?

Abed: Not necessarily.

Jeff: Will you just tell us how you chose?

Abed: I used the ballots to rank everyone by popularity, and I put the most popular with the least popular.  I figured it would maximize each partnership’s audience appeal.

Jeff: Oh, I see. So I was number one, and he was obviously number eight, no offense Todd.

Abed: You and Todd were four and five.

Jeff: I was four?

Abed: Todd was four.

Jeff: I was five?

More significant than the dent to Jeff’s ego, however, should be the dent to Abed’s for his naïve approach to solving this problem.  Ironically, though he claims that Abed is a computer, it is Jeff’s remark that has the most prescience.  For indeed, this problem is well known as the stable roommates problem, and has already been studied quite a bit.

More important than “audience appeal” from a mathematical standpoint is the stability of the final pairing.  Roughly speaking, a collection of pairings is said to be stable if no two people from two separate pairs would rather be paired up with each other.  For example, in Abed’s final pairing, if Jeff prefers Annie to Todd and Annie prefers Jeff to Shirley, then Abed’s collection isn’t stable, because Annie and Jeff would both be happier if they swapped partners.

An algorithm to solve this problem was discovered in 1985.  The algorithm is explained in the Wikipedia link above, but let’s see an example of it in action using the Community cast as a starting point.  To keep things simple, let me suppose there are only four people instead of eight: say, Annie, Jeff, Troy, and Britta.

First, note that a stable solution to this problem is not always possible.  For example, suppose everyone grows weary of Jeff’s hubris, and so he ranks last in everyone’s list of preferences.  Then we may be given the following scenario:

NameFirst ChoiceSecond ChoiceThird Choice
AnnieBrittaTroyJeff
BrittaTroyAnnieJeff
JeffTroyAnnieBritta
TroyAnnieBrittaJeff

In this scenario, everyone aside from Jeff ranks Jeff last, and we also have a cycle (Annie is Troy’s first choice, Troy is Britta’s first choice, and Britta is Annie’s first choice).  In this case, there can be no stable solution.  For example, suppose Troy and Jeff are paired up, and Annie and Britta are paired up.  In this case, Troy would rather be with Britta, and vice versa.  Similarly, if Annie is stuck with Jeff, she would rather be with Troy, and vice versa, and if Britta is paired with Jeff, she would Annie, and vice versa.

Sometimes, however, solutions will exist.  Consider, for example, the following list of preferences:

NameFirst ChoiceSecond ChoiceThird Choice
AnnieBrittaJeffTroy
BrittaTroyJeffAnnie
JeffAnnieTroyBritta
TroyAnnieBrittaJeff

In this case, a stable solution is found in the following way: first, we go in order and list everyone’s first choice (this is the proposal round).  In the event that someone receives a second proposal, that person will reject the person who is lower on their preference list, and the rejected person will then ask the next person on their list.

Given the list above, here’s how things will go down: Annie will propose to Britta, Britta will propose to Troy, Jeff will propose to Annie, and Troy will propose to Annie.  Since Jeff is higher on Annie’s list than Troy, Annie will reject Troy, at which point Troy will propose to Britta.  Britta will then reject Annie’s proposal, and Annie will propose to Jeff.  This gives the pairing of Jeff with Annie and Britta with Troy, and this is stable.

For larger groups of people, the algorithm may need to go into a second stage after the proposal round.  Try a ranking with all eight zany characters and see what happens!

Note that this problem is closely related to the stable marriage problem, with one key difference – in the stable marriage problem, the group is always cut in half along gender lines (males and females), so each person only provides a ranking of the members of the opposite sex.  Interestingly, this problem always has a stable solution, and its application goes beyond sorting people into couples – it is used, for instance, in the pairing of medical students with hospitals for residency.

So, sorry Abed, but you are not a computer after all.  But perhaps after reading this, you will be one step closer to the cyborg in Kickpuncher who you idolize so dearly.

His cyberpunches have the power of kicks!

Playoff Probabilities

Continuing with last week’s theme, and since we are in the midst of playoffs, I’d like to take a moment now to discuss another link between baseball and mathematics.  This link is particularly timely since the scuttlebutt on the internet suggests that next year the playoff rules for baseball will be changed: the number of teams competing for the World Series will increase from 8 to 10, and because of that, another round of playoff games will be introduced.

Currently, the playoffs consist of three rounds.  The first round is the Division Series, in which eight teams compete in a best-of-five match-up (equivalently, a first-to-three match-up, i.e. the first team to win three games wins the series).  The second and third rounds, better known as the Championship Series and World Series, are composed of four and two teams, respectively, but are both best-of-seven (equivalently, first-to-four).  Because of these three rounds of several games each, the playoff season is already quite long; therefore, the new proposed playoff round, it has been suggested, would be composed of either a single game between competing teams, or a best-of-three (first-to-two) series between the two teams.

Many people take issue with such a short series on the grounds of fairness.  In a season where each team plays 162 games, they say, it’s not fair for a team’s World Series hopes to ride on a single game, or even a short series composed of at most three games.  There are even those who suggest that the Division Series is too short, and that all three of the current rounds should be a best-of-seven.  These are noble sentiments, but are they reasonable?  We can use mathematics to try and answer this question.

Suppose two teams are meeting for a playoff series, and the probability that one team (call it, I don’t know, the Giants) will win a single game is p (this model is fairly simple, and does not take into account advantages associated with the starting pitcher, for example, but let’s keep things basic for now).  Then the probability that this team will win a one game series is again p, since the series consists of a single game.

What if the series is three games long?  In this case, the Giants will win if they win the first two games, or split the first two games and win the third game.  So there are three outcomes: WW, WLW, or LWW.  The probability of the first event is p^2, while the probability of the second and third events are both p^2(1-p) (probability p of success is the same as probability 1-p of failure).  Adding these three probabilities gives the total probability that the team will win a best-of-three series:

p^2 + 2p^2(1-p) = p^2(3-2p).

In a best-of-five series, the Giants will win if they win three in a row, two of the first three and the fourth, or two of the first four and the fifth.  Using combinations to count the possibilities, we see that in this case, the probability of the Giants winning the series is equal to

p^3 + \binom{3}{2}p^3(1-p)+\binom{4}{2}p^3(1-p)^2

= p^3(10-15p+6p^2).

With the same type of argument you can calculate the probability that the Giants win a best-of-seven series.  I’ll spare you the details: the result is p^4(35-84p+70p^2-20p^3).

In each case, the probability of winning the series is a polynomial in p, the probability of winning a single game.  But how to these polynomials compare?  Let’s turn to technology to lead the way!

Probabilities for a one, three, five, and seven game series.

Above is a graph of these four functions – the x-axis represents the probability p, while the y-axis represents the probability of winning the series.  The dark blue graph is for a single-game series (the function is p), the light blue graph is for a three-game series (the function is p^2(3-2p), the light green graph is for a five-game series (the function is = p^3(1-15p+6p^2)), and the red graph is for a seven-game series (the function is p^4(35-84p+70p^2-20p^3)).  What can we deduce from the picture above?

First, note that a longer series benefits the stronger team more than the weaker team – this makes intuitive sense, if you think about it.  Also, for teams that are perfectly evenly matched (i.e. p = 0.5), the length of the series doesn’t affect the probability of winning the series, which is also 50% in each case.

But what about teams with a slight, moderate, or strong advantage over their competition?  How does the length of the series affect the probability of winning the series?  Let’s look at a small table of values, in the cases p = .55, p = .6, and p = .7.

pBest of One Odds of SuccessBest of Three Odds of SuccessBest of Five Odds of SuccessBest of Seven Odds of Success
.550.550.575.593.608
.600.600.648.683.710
.700.700.784.837.874

As you can see from the table (or the graph), the more evenly matched the teams, the less of a difference the length of the series makes.  If your team has a 55% chance of winning a given game, the advantage in a seven game series is increased by a little less than 6 percentage points.  With a 60% chance of winning a given game, the advantage in a seven game series is increased by 11 percentage points, and with a 70% chance of winning a given game, the advantage in a seven game series is increased by over 17 percentage points.

Not also that the change from a best-of-five series to a best-of-seven series isn’t really very large.  Even if your team is heavily favored (70% probability of winning each game), the change from a best-of-five series to a best-of-seven series is less than four points.  With more evenly matched teams, the difference is even smaller, suggesting that expansion of the Division Series from a maximum of five to a maximum of seven games isn’t necessarily a great idea.

On the other hand, the largest change in probabilities is between the jump from a best-of-one series to a best-of-three series.  While the change isn’t so significant for evenly matched teams (and more evenly matched teams would be most likely to play each other in this round under the suggested rule changes), for match-ups in which one team is heavily favored, the difference can be more significant.

Whether or not one wants longer series or shorter series depends, I suppose, on one’s baseball philosophy.  It certainly seems like having everything ride on a single game after a season of more than 150 games is a little unbalanced, but from a mathematical standpoint, the stronger team will most likely gain only a small advantage by moving to a three game series.  Of course, this simplified model can only tell us so much, and it’s possible that the advantages of a longer series are being underrepresented here.  To err on the side of caution, I’d be more inclined to support a best-of-three series, though whether or not this is possible without stretching the season too long is something that the folks who are paid better than me to think about these matters will have to decide.