Math

They See Me Rollin’

Whenever I talk about math in this blog, you know it’s going to be something that is simultaneously incredibly important and incredibly useless.  Today is no exception — I want to tackle one of the most important (but no worries, also useless) examples of polar coordinates and path-length integrals around, even if you don’t realize it yet:

When you have a roll of stuff — think paper towels, aluminum foil, Saran wrap, use your imagination — how much of that stuff is left, based on the diameter of the roll?  How many more chicken dinners can you cover and stick in the fridge?  How many more spilled beers can you wipe off of the table?

(This question, for the record, came up at work, albeit with some industrial polymer examples instead of household chores.  The times I do real math as a mechanical engineer are surprisingly few and far between, so apologies if I come off as over-excited.)

On one level, this question isn’t that tricky. Your roll of stuff — I’ll stick with aluminum foil in these examples — is wound around a core, and you can measure the core diameter, measure the roll diameter, measure the thickness of the foil and chug-chug-chug along until a number comes out.

Which is, of course, exactly what we’re going to do first.  (Spoiler alert: there’s a massive shortcut and a cool arithmetic trick at the end, but we’re going to slog through some calculus because I learned all this shit and never get to use it, goddammit.)

The foil is wound around the core in a spiral — an Archimedean spiral, to be precise.  Each layer sits directly on top of the last layer, around and around and around, until it reaches the point you pull.

In polar coordinates, the equation for an Archimedean spiral is r = cθ.  (Polar coordinate recap: angle, θ, and distance from the origin, r, are just as valid a way to define a point’s location as x and y, and the bears are white instead of brown.)  The constant c defines how much space is between each turn of the spiral; in our case this is directly related to the thickness of the foil, which I’ll call t.  Every winding around the core, a distance of 2π radians, increase the roll’s radius by t, so we have:

c = t / (2π)

Therefore the equation of our aluminum foil spiral is:

r = tθ / (2π)

Without deriving it here (I let Stephen derive it here instead), the length of a curve — any curve — in polar coordinates is given by:

Screen Shot 2015-01-29 at 9.12.38 PM

Our starting and ending coordinates, θ0 and θ1, are given by the radius of the core the foil is wound around (r0) and the outer radius of the roll (r1), as well as our Archimedean spiral equation.  We get:

θ0 = 2πr0 / t

θ1 = 2πr1 / t

Putting this all together, we get:

Screen Shot 2015-01-29 at 9.13.56 PM

This is, uh, not a nice integral to solve.  But we’re really good at calculus (and by “we” I mean “Wolfram|Alpha”), and so we know this evaluates to:

Screen Shot 2015-01-29 at 9.15.15 PM

Holy dammit Christmas, we’ve gone hyperbolic.  If it makes you feel better, we can write the inverse sinh function as a logarithm, and so this soup of advanced math classes reduces down to:

Screen Shot 2015-01-29 at 9.15.58 PM

Okay, fine, it’s still not pretty.  But it is precise.

Standard household aluminum foil is about 0.016 mm thick.  If it’s wrapped around a 12 mm radius core to a final outer radius of 16 mm, this formula tells us that it should have a total overall length of 21.99 m — enough for a whole lot of Chipotle burrito swaddling, and just about exactly what we’d expect.  Two points calculus.

•    •  • • •  •    •

The engineer-graduate-degree half of my brain is done at this point (we have, after all, the most exact answer possible, though it took a decent amount of computation to get there).  But the undergraduate-physics-degree half of my brain, which was at one point instructed that pi is “approximately 1” and prides itself on Fermi estimation, doesn’t love all the work we had to go through to pull it off.  I mean — path integrals?  Hyperbolic trig functions?  Really?

What if we assume the foil is wound in concentric circles instead of a spiral?  This way simpler geometrically (ignore the fact that it’s physically impossible, please — this is a physics approximation after all), and since aluminum foil or paper towels or whatever are so thin the answer should be very similar.  In this case, the radius of each subsequent winding increases by exactly the thickness of the foil.

So if we add up the circumferences of all the concentric circles from the first to the Nth, we get the overall length of the foil:

s = 2πr0 + 2π(r0 + t) + 2π(r0 + 2t) + 2π(r0 + 3t) + … + 2π(r0 + (N – 1)t)

Or, rearranging:

s = 2π(r0 + r0 + tr0 + 2t + r0 + 3t + … + r0 + (N – 1)t)
s = 2π(Nr0 + (1 + 2 + 3 + … + (N – 1))t)

Lurking in here is a really neat arithmetic identity — the sum of every number between 1 and x (here, x is played by N – 1).  There’s an apocryphal story about a young Carl Friedrich Gauss, whose 18th century elementary school teacher tasked his class with summing every number from 1 to 100 — presumably to shut the little bastards up while the teacher nursed a massive Oktoberfest hangover.  While every other student began to assiduously add numbers up, our wunderkind Gauss thought about it and came up with a much more elegant solution: each pair of numbers — 1 and 100, 2 and 99, 3 and 98, etc. adds up to exactly the same value, and there are exactly 100/2 = 50 of those pairs.  Therefore the sum of all numbers from 1 to 100 is:

(100 / 2)(1 + 100) = 5050

That Gauss guy was a smart dude.  There’s a reason literally everything in mathematics is named after him (well, him and Euler).  In algebraic form, the sum of all numbers from 1 to x is:

(x / 2)(1 + x)

And for us, where x = N – 1:

(1 + 2 + 3 + … + (N – 1)) = ((N – 1)/2)(1 + (N – 1)) = (N2N) / 2

So that means the length of our roll is approximately:

s = 2π(Nr0 + ((N2 – N) / 2)t) = πN(2r0 + (N – 1)t)

We still need to figure out how many turns are in our foil coil, but that’s just based on the inner and outer radius:

N = (r1 – r0) / t

Putting everything together, we have:

s = π((r1 – r0) / t) (2r0 + (((r1 – r0) / t) – 1)t)

s = (π / t)(r12 – r02r0t – r1t)

Somehow this just looks much nicer than the solution with a hyperbolic trig function in it.  And when you plug the same numbers in, you get — wait for it — 21.98 m.  That’s a 0.01 m difference over more than 20 m of length… or a discrepancy of less than 0.05%.

So yeah, I’ll stick with Gauss on this one.  You can call it intelligence or you can call it indolence, but either way I know how many dinners I can wrap up and shove in the fridge.

Stamped On

I’ve had a bit of a rough week.  My job has been stressful, my relationship imploded, and my bracket‘s final four is completely busted.  It was one of those weeks that makes me want to abandon work, romance, and armchair basketball commentary all at once and abscond into the hills, to make a living carving small bear totems out of pine trees felled by lightning.

Those weeks (and, yes, this one included) are generally ended by the realization that WiFi is pretty hard to come by in the wilderness.  And that I really don’t have any woodworking skills beyond third grade summer camp.  But what really kept me going this week — what really allowed me to block out everything else that was going on — was a simple friend, who’s always been there and never really changes that much, no matter what’s going on in my life.  Who’s always right.  Who’s always logical.

I’m talking, of course, about math.  (Har har har, I know.)  Like any good week where I’m feeling stamped on, I found a great math problem at work to distract me.

Without getting into specifics that could, in turn, get me into hot water, I’ll summarize the problem by saying this: I needed to be able to make a lot of differently sized… things.  Let’s call them Lego castles.  But I only could pick from one or two different Lego bricks.  Obviously, if I used bigger bricks I’d be able to build bigger castles faster and more efficiently.  So which (suitably large enough) bricks would let me build the widest range of castles?

Wikipedia calls this the coin problem, but since American numismatics has way too many common factors — and, of course, for the linguistic congruity with my emotions — I prefer to call it the stamp problem.  Of course, I didn’t know this when I started thinking about it, so I had a lot of trouble googling a solution.  “Two integers make lots of bigger integers” doesn’t return very many solid results.

Anyway, the stamp problem goes something like this:

Imagine you have two big piles of stamps.  One pile is made up of stamps worth 3¢ each, while the other pile consists entirely of 5¢ stamps.  This year, postage is 8¢ — but the postal service has decreed that postage will increase by 1¢ each year for the rest of time (thanks, Obama), and you must pay the exact price.  So next year, postage will be 9¢, the year after that 10¢, then 11¢, and so on.  Since you only have 3¢ and 5¢ stamps, what years won’t you be able to send letters because you can’t hit the exact cost of postage?

The answer is never.  You will never be unable to send a letter, because any positive integer greater than 7 can be formed with some combination of 3s and 5s:

8 = 3 + 5
9 = 3 × 3
10 = 5 × 2
11 = 5 + 3 × 2
1,236 = 5 × 246 + 3 × 2
etc.

This is a ridiculously cool phenomena associated with coprime numbers — numbers whose only common divisor is one.  Two coprime numbers a and b can combine to form any positive integer whose value is greater than ab – (a+b).  Combinations of 3 and 5 can make any number greater than 7; 2 and 7 can make any number greater than 5; 73 and 182 can make any number greater than 13,031; and so on.

Mind = blown

There’s a beauty here, lurking behind the guise of ordinary numbers.  If you’ll let me step away from the main point of this post (MATH IS COOL) to the ancillary topics I’ve raised (EMOTIONS ARE TERRIBLE WHY DO I FEEL THEM), I think this is why I like math, and why I find it comforting in some weird, all-too-stereotypical way: it always makes sense.  There’s a reason to it, a structure — even times when I can’t see that structure at first, as was the case of the stamp problem, I know that the underlying architecture is beautiful.  I’m harder pressed to believe that about the other things in my life.

Most of the time, I enjoy the lack of structure.  I wouldn’t want to know what’s about to happen to me, and certainly am not insane (and/or religious) enough to think there’s an overriding reason behind everything that happens to me.  The fact that there’s no underlying architecture means I’m free to build my own structures and connections, free to construct my own edifice.  But when I feel stamped on (promise, last time I’ll use that idiom), when the weight of all the chaos frothing around me gets too heavy to bear, when the people that I care about are suddenly confusing and nauseatingly painful and impossibly distant — well, it’s nice to know that at least something in this universe still makes sense.

Even if that something is just addition.

Billionaire Bracketology

If you haven’t heard, Quicken Loans and Yahoo! Sports (with a hefty helping of Warren Buffet) have teamed up to run a March Madness bracket where anyone who picks all 63 games correctly wins — I shit you not — ONE BILLION DOLLARS.

Or, fine, a nuclear warhead from Kerplakistan, whatever.

Or, fine, a nuclear warhead from Kerplakistan, whatever.

This is an astronomical sum of money to be bet on a sporting event — imagine going to Vegas and slamming down the GDP of the Solomon Islands on black.  To be fair, though, Warren’s hedging his bets by spreading the bet over every game in the NCAA basketball tournament.  All sixty-three games of it.

Let’s assume everyone who enters the tournament chooses the winner of each game blindly.  Quicken Loans is limiting the number of entrants to 15 million, so the chance of anyone at all winning by blind luck is a 0.5063 × 15,000,000 = 0.00000000016% chance.

Ah, but we have more information than luck!  Every team in each of the four sections of the tournament is seeded 1 through 16.  If we assume this alone gives us enough information to pick every game with at least 2/3 probability, then the chance of someone — anyone — wins the billion-dollar bucket is a whopping 0.6763 × 15,000,000 = 0.016%.

So it’s unlikely any average person wins this.  Ever.  But!  Let’s assume (for sake of argument) that I am smarter than the average person.  Well then:

The contest is free to enter, so just by filling out a bracket and picking teams by, I don’t know, jersey color and degree of mascot alliteration (i.e. randomly) I can expect to win 0.5063 × $1,000,000,000 = $0.0000000001.  If I can use the seeds of teams to increase my odds to 2/3, then I’d expect to win 0.6763 × $1,000,000,000 = $0.01!

The kicker, of course, is that as a veteran bracketologist (second place in my pool to a girl who actually did choose by color last year, what what), I can safely assume I’ll be able to pick games correctly 75% of the time.  I’m that good, obviously.  I don’t even have to watch any college basketball this season, such is my mastery of sabremetrics and theorycrafting (full disclosure: I did, once this season, listen to another man watch a North Carolina game).  And with my superior March Madness skill set, fueled by in-depth statistical analysis and this one blog I read on Grantland, I can already expect to win 0.7563 × $1,000,000,000 = $13.45, thereby offsetting (a fraction of) the beer I’ll need to sit through any of the actual tournament games themselves while I wait for college football season to roll around again.

I’ll take my check by direct deposit, please, Warren.

Sidebar: this is why it’s so hard to ever go undefeated in sports. Imagine the shortest season — college football, twelve games — and a team that’s a huge favorite in all of them. If that team is given 90% odds of winning every single game, its odds of going are undefeated are still only 0.9012 = 28%.  What I’m trying to say here is it’s okay, Nick Saban.  Even your dark magic is no match for the power of exponents.

Whiskey Physics

When I ordered a scotch on the rocks in Korea, I was given this:

Image

That, as you’re probably wondering, is a single spherical ice cube.  A scotch on the rock.  Now, perfectly spherical ice cube molds are probably much harder to make and handle than an ice tray, so why go to the trouble?  Aesthetics?

Well, no.  (Though the sphere was almost the same diameter as the glass, which was pretty cool.)  The answer, of course, is science.

Let’s talk about ice: ice cools your drink.  How exactly does it do that?  At the most basic level, it’s because the universe really likes things to be the same — nature abhors a vacuum and all that.  In terms of temperature, which can be loosely defined as a measure of the speed of the atoms in an object, this manifests in what we call “heat transfer,” the transfer of kinetic energy from a collection of fast-moving particles (a hot thing) to a collection of slower-moving particles (a less hot thing) until the two objects have roughly the same internal kinetic energy (or, in other words, are about the same temperature).  In my drink example, the part of the slow-moving collection of particles is played by Mr. Ice Sphere, while the role of the fast particles is tonight filled by Mr. Been Sitting on a Shelf Room Temperature Scotch Whisky.

When you place the ice sphere in the glass and poor the scotch over it, heat transfer occurs — it’s not that the ice cools the scotch off, but rather that the ice and the scotch try to get to a common temperature that’s somewhere between the ice’s starting temperature and the scotch’s.  This is an exponential process governed by Fourier’s law, which you need a course in vector calculus to fully appreciate but generally states that the flow of heat between two objects is proportional to the difference in temperature between them and the surface area the heat flows through:

Image

Initially, the ice is quite cold but the scotch, which has been sitting on a shelf in South Korea in the summertime, is quite tepid — so that temperature difference is very large and dominates the system’s behavior, which tends to cool your drink off very quickly.  Because the equilibrium temperature is much closer to the ice’s starting temperature than the scotch’s and since this step happens relatively rapidly, very little of the ice melts, regardless of the ice’s shape.

But — after the ice has sat in the scotch for a few seconds, that temperature difference is very small, and so heat transfer tends to happen much more slowly.  This is where surface area and the geometry of a sphere come in to play — ideally, no ice would melt while you drink your scotch, keeping all that woody, smokey flavor cold without watering it down, but since the liquid and ice are in contact with the outside air that’s impossible in practice.  Instead, barkeepers can only try to keep the ice intact as long as possible, and that means they must minimize the only thing in Fourier’s law they have any control over: the ice’s surface area.

You’ve probably guessed at this point what shape minimizes surface area for a given volume — the humble sphere.*

It’s exactly that property that makes spherical ice cubes cool (pun most definitely intended).  Since they have a smaller surface area than an equivalent volume of normal ice cubes, they can keep your drink just as cold, but will melt more slowly, letting you savor your scotch and escape the sweltering South Korean summer that much longer.

________________________________

* I tried to think of a rigorous proof of this, but couldn’t come up with one… Math-inclined readers, suggestions welcome.  I can only offer the fact that the surface area to volume ratio monotonically decreases for Platonic solids with increasing numbers of faces, and logically it makes sense that a sphere would continue this trend.  Proof by hand-waving.**

** Which is better than the math professor I had who taught me about the Platonic solids and occasionally invoked “proof by intimidation.”

The Birthday Problem

Cool little bit of probability that would be fun to pull out at parties, if you go to the right kind of parties — or wrong kind of parties, probably (get it? probably? eh? ehhh?):

In a room full of fifty people, what is the chance that two people have the same birthday?

Think about it for a second.  There are 365 days in the year (this is an idealized mathematical world, so leap years don’t exist), and only fifty people in the room — not nearly enough to ensure that every day is covered, right?

Well, right, but that’s not what the question is asking.  We want to know whether two people share a birthday, not whether two people are born on a certain day.  Assuming a uniform distribution of birthdays over the year (which isn’t really totally true, but whatever), let’s find the chance that two people in the room don’t share a birthday.  To do that, we start with the second person in the room.  The chance that the second person shares a birthday with the first person in the room is one out of 365 — but the chance they don’t share a birthday is 364/365.  The chance the third person does not share a birthday with the first or the second person is 363/365.  The fourth person has a 362/365 chance of not sharing a birthday, and so on, until you’ve gotten to the fiftieth person, who has a 316/365 chance of being born on a unique day.

Since everyone’s birthdate is independent of one another’s (for simplicity we’re assuming no weird parental pregnancy pacts between the parents of people in the room), to find the total probability that two people don’t share a birthday we have to multiply all these individual probabilities together.  Imagine flipping a coin, which is the archetypal independent event — the chance of getting heads is 1/2, but the chance of getting two heads in a row is 1/2 x 1/2 = 1/4, and so on.  That means we have:

Or, using the factorial operator and rearranging:

Since probabilities always have to add up to 100%, the probability that at least two people share a birthday is one minus this result — which works out to 97% (!).  That means that, in a random assortment of just fifty people, having two people share a birthday is almost a certainty.

In fact, at only 23 people in a room, there’s over a 50% chance that two of them will share birthdays.  Math!

Unfortunately, applying probability formulas to poker is less surprising.