Planetary orbital foci

Planetary orbits are not perfectly circular; in fact, they are ellipses. An ellipse is a mathematical shape approximately equivalent to what is typically called an oval. An ellipse, though, meets some very specific criteria. One is that, unlike a circle, it has two foci instead of a single center. Where a circle is defined as the set of points whose distance to the center are some constant distance (the radius), an ellipse is the set of points whose distances to the two foci add to a constant. This allows you to construct an ellipse with some pins, some string, and a pencil.

So what are the two foci of planetary orbits? Well, one is the Sun. The other one? Just some random spot in space. And because each planet has a different size orbit with a different eccentricity (a measurement of how non-circular the orbit is), each planet has a non-Sun focus in a different place. Here is a Google doc spreadsheet with information on each planet’s orbit. A visualization after the jump.

Venus and Earth have very round orbits. Mercury’s is surprisingly un-round – nearly as eccentric as (although much smaller than) Pluto’s.


Choosing random keys

Say you had code that generated random keys. These random keys were 6 letters long, all caps, with no duplicates. Here’s a few, as an example:

NTCYARDHIEWMINBVTXIOELUC
RKNBJXGKRANBDRYVQUYIFKTS
VAUPSGALWPOSCERSUYWAHJVM
MTXJSZRNLFXZVFIEXTVEOKIH

What are the chances that the key that you generate will be in alphabetical order? For instance, above, there’s only one in alphabetical order (CERSUY, in bold) And then, if you think you have that, generalize: For any string of length k distinct characters chosen from a set of n, what are the chances that they will be in order? My answer after the break.

I spent several minutes trying to solve this the straightforward way. You only have 21 choices for the first letter, because if it’s anything after U, there’s no way to have five more letters that come after it. Then for the second letter, you have 22-a1 (where a1 is the index of the first letter) choices. For instance, if the first letter was E, you have only 22-5, or 17 choices – namely anything between F and V. After going through all six letters, you end up with this ungainly thing:

[21 (22-a_{1}) (23-a_{2}) (24-a_{3}) (25-a_{4}) (26-a_{5})]/n!

It’s probably possible to simplify that somewhat by looking at reductive cases – you can model a two-letter key as a grid of allowed possibilities, but even that would get pretty challenging pretty quickly. If you look at it from another direction, however, things get much easier. Consider a single key, let’s say “NTCYAR” (the first in the table above). How many possible permutations of that key are there? Simple: 65432*1, or 6!. Of those, how many of them are in alphabetical order? Even simpler: 1 (ACNRTY). In fact, this is true for any set of six letters you choose – you could have picked those same letters in any of 6! possible orderings, and only one is in alphabetical order. So there you go. Your answer is:

1/6! = 1/720 = 0.138%

The interesting thing? The probability doesn’t depend on the length of your alphabet, only on the length of the key. The generalized probability is simply:

1/k!

Idea: OEIS blog

Someone should make a blog based on the Online Encyclopedia of Integer Sequences. Each week (or twice a week, or daily, or something), there’d be a post which would discuss a single sequence. It’d give some glance at the theory and some history behind the concepts, be they Turing machines, prime numbers, set theory, or bi-directional graphs.

I’m adding this to my “to do when I retire” list.


The Feynman point

Famed Physicist Richard Feynman once joked that he wanted to memorize π up to the 762nd digit. Why? Because that’s where pareidolia kicks in, and the digits appear to briefly coalesce into rationality:

3.1415926535 8979323846 … [727 digits] … 9605187072 1134999999 …

He would end a hypothetical recitation at that point, the implication being that from there on the decimal repeats. Virtually everyone, obviously including Feynman, knows π is both irrational and transcendental, and thus such a fact is impossible. The so-called “Feynman Point” is the first incidence of six consecutive identical digits in π and it also happens to be the first incidence of four and five consecutive digits.

Happy Pi Day.


Melting down pennies

Not many people know that there is very little copper in modern pennies. In 1982, they were changed from 95% copper to simply copper-plated zinc. If you cut open a penny made after that date, you’d see the grey-colored metal on the inside. In fact, in 1981, pennies of both recipes were made, and collectors have to listen to the sound they make when they bounce to tell the difference. Do it yourself with a penny from the 70s and one from the 90s; the difference will be obvious.

The price of copper closed last night at $3.48 a pound. That means that a 3.1 gram penny has about 2.26 cents of copper in it. Melt down a big wad of those, and you can make yourself a tidy profit. The price of zinc has been escalating in the last few months, too, so it might not be long until it’s worthwhile to melt down new pennies, too.


Pi Day is a sham

Pi Day is a sham. So-called Pi Approximation Day (July 22, or 22/7 in European date style) is closer to the true value of π.

22/7 = 3.142857142… abs( 22/7 - π ) = 0.001264489… abs( 3.14 - π ) = 0.001592653…

What a shame.


When is Powerball worth it?

Every time the Powerball Lottery breaks two-hundred million or so, people at work start talking about it and emailing appeals for joining a lotto pool. After I got sick of shaking my head at these people, I realized that it could possibly be worth it to buy a ticket. Since the ticket price stays the same even as the jackpot grows, there’s got to be a tipping point, beyond which the payoff from the average ticket is greater than one dollar. But what is that point? Should I be queuing up at the gas station right now? Or should I wait until it hits ten digits?

Powerball tells you that the odds of getting the grand prize are 1 in 146,107,962. This gives us a good starting point. In a universe without taxes, annuties or interest, a rational person wouldn’t want to purchase a ticket until the jackpot was $146 million. But we don’t live in that universe, nor do I believe we’ll be travelling to it to play the lottery.

To figure out the answer for us, we’ll need to start by answering one quite difficult question: When they say “estimated jackpot of” whatever, how much of that is going to end up directly in your pocket? The Powerball FAQ talks a bit about how the payoff works (towards the bottom). The advertised estimated jackpot is the annuity, and it’s usually about double the actual cash they have on-hand. If you go for the lump-sum choice, you get that amount of cash (this week, about $150 million). Interestingly, if you choose the annuity, they put that same pile of money into government bonds, and they pay you in 30 yearly installments, funded entirely from that investment.

This detail is important for two reasons. First, even if you buy the same bonds the Powerball folks would have (which you can’t, since you’re a nobody schlub who thought the lottery was a decent investment decision), you end up with a lot less money by picking the lump sum. They’re able to buy the bonds without paying income taxes — which means far more interest. Since it’s income for you even before you can buy anything with it, you aren’t so lucky. Second, they don’t say “estimated jackpot” because they’re lazy; they say it because it’s impossible for anyone to say how bonds are going to behave for the next 30 years. They couldn’t tell you how much money you’ll end up getting if they wanted to. Which they probably don’t.

Unfortunately, this also makes things impossible for us to calculate accurately. So we’re going to have to be estimated it about it as well. So let’s say their double-the-lump-sum (L = J/2) guess is accurate. Accepting the annuity, you end up with J/30 per year. This is (obviously) going to put you in the top tax bracket: 35%. Which means that only about (1 - 0.35) * (J/30) is yours, per year. A little simple arithmetic brings us to the conclusion that J must be at least $224 million.

But what have I forgotten? I’ll give you a moment to consider what I’ve looked at so far. Hundreds of millions of dollars. Decades of interest. A dope with a little slip of paper and Hurley’s numbers. Got it, yet? It’s Carter’s Bane, better known as inflation. The Department of Labor follows inflation using the Consumer Price Index, a complicated formula of a whole bunch of items that pretty much everyone pays for: food, gas, housing, clothes, silly hats, medical care, etc. Looking at a summary table of CPI indexes, the average inflation rate for the past decade has been just over 2.5% year to year.

What does this mean? It means that in 2036, when you’re getting your very last annuity, although it’s (more or less) exactly the same number of dollars, it’ll be worth less than half as much as your first one ((1-2.5%)^29 = 0.48). And your total? Knowing that we want $146 million at the end, we can calculate for J in Σ(n=[0,29]) of ((1-2.5%)^n)((1 - 0.35)(J/30)), and we get a final answer of $316,822,280.

Don’t run out to buy any tickets right now. But if no one wins tonight, you might want to get some for next Saturday’s drawing.

Update, 16 Feb: Last night, mulling this over, I decided that the probabilities of winning non-jackpot prizes were significant enough to consider. Also, I decided that I was calculating from the wrong direction. Knowing (almost) all of the outcome values and probabilities, it should be easy to setup an equation for the value of the average ticket and solve for when that value equals one dollar. It was easy:

So when the pocket value of the jackpot is over $117 million, a ticket is worth more than it costs. The pocket value is equal to the inflation-corrected post-taxes estimate we made above (about 46.117% of the advertised estimation). An estimated jackpot of about $254 million would satisfy these conditions. No one won last night, and they're advertising above $360 million for Saturday.


Divisibility

I love math. Not just complex math, but arithmetic, too. I simply adore mathematical shortcuts. That’s why I spent the last couple of days finding shortcuts for divisibility tests:

  • 3 - Sum of digits is divisible by 3.
  • 4 - If the last two digits (tens and ones places) are divisible by 4. You can simplify this test by subtracting multiples of 2 from the tens place.
  • 7 - Remove the digit in the ones place. Double it, and subtract that from the remaining number. Repeat until you have a one-digit number. If that number is 7, 0, or -7, the original number is divisible by 7.
  • 8 - If the last three digits are divisible by 8. You can simplify this test by subtracting multiples of 2 from the hundreds place, and multiples of 4 from the tens place.
  • 9 - Sum of digits is divisible by 9.
  • 11 - If the alternating sum of the digits (first digit, minus second digit, plus third digit, etc) is divisible by 11.
  • 13 - Remove the digit in the ones place. Multiply that digit by 4, and add that to the remaining number. Repeat until you have a number less than 40. If that number is 13, 26, or 39, the original number is divisible by 13.

The rules for 7 and 13 can easily be extended to just about any number under 100 (and, in fact, the rules listed here for 3, 9, and 11 are simple variants). As long as you understand how those ones work, you don’t even really need to memorize anything.


Carrying change

Nomad refuses to carry coinage. I recall one time (likely apocryphal) he purchased a soda for $1.25 at a train station, and then put his change (all seventy-five cents) on top of a garbage can and left it. I can’t remember if I did the sterotypical thing and picked it up, but I’m sure I called it foolish.

But it got me thinking; is carrying change a waste of energy? If you carried a pocket-full of coins all day, could you purchase more calories of food than you burned carrying it? I thought about it for a while, and I couldn’t reason it out, so I decided to calculate it. The answer somewhat surprised me.

Coins are quite light. The U.S. Mint says that a penny weighs 2.5 grams, a nickel 5g, a dime 2.268g, and a quarter 5.67g. Figuring out how much walking “all day” is was difficult. I got numbers (for an average American adult) that varied from a quarter-mile to five miles. I decided to go with a middle-ground number, 2.7 miles. Looking at some numbers for calorie consumption during walking, I estimated that a person burns one calorie per pound of weight per hour of walking at 2mph. Once I had all of my data, the calculations were pretty easy.

The energy used carrying a penny around

Essentially what that means is that if you carried a whole dollar of pennies around for a day, you would burn almost three-quarters of an additional calorie. Even the least calorie-dense foods (like, say, Pepsi One) are enough to make it worth it, and some of the most calorie-dense foods (like the Big Mac) provide you with several hundred calories per dollar.

(Pennies require the most energy-per-dollar to carry. A nickel would cost 0.297 calories per dollar, and dimes and quarters both run a measly 0.068.)


Trig challenge

A new trigonometry challenge: Given a hexagon inscribed in a square as shown below, what is the ratio of relationship between the length of segment a and segment b? Assume the hexagon’s sides are all of equal length.

Update Feb 26: The solution, props to Brian.


Paper models of Polyhedra

An offhand reference in The Golden Ratio led me to research Archimedean solids, which led me to a page with Paper Models of Polyhedra. Fun!


Ponder This

IBM’s monthly teaser, Ponder This, seems like fun. Part 1 of November’s only took me about 5 minutes and 66 characters of Perl. Part 2 is a little more analytical. I’ll work on it at lunch.


Paper sizes

American paper sizes, like all other Imperial forms of measurement, are so arbitrary. It’s quite a breath of fresh air – a veritable gale of freshness, in fact – to read about the mathematically sound basis of the rest of the world’s paper sizes. Bone up on your geometric averages and square roots, and jump into the wonderful world of the international standard paper sizes.


What's Special About This Number?

Lots of numbers are special. 2 is the only even prime. 28 is perfect. And if you’re patient and know a lot of esoteric mathematics, you can find something special about every number.


Monty Hall redux

The Monty Hall problem is hard enough to confound lots of smart people and lots of professional mathematicians and probability experts. Now imagine two corollary problems. My initial reaction is to say that neither will affect the optimal action. But if the Monty Hall problem has tought us anything, it’s that intuition is usually wrong, and rational thought is almost always more wrong.


Google math problem

You’d think this would be easy. Sadly, 10-digit numbers don’t fit in 32 bits. I’ll let you know when I’ve solved it.


Trigonomery refresher: Solved!

Trigonomery refresher: Solved!


Trigonometry refresher

Trigonometry refresher:

You are at the top of Castle Craig in Meriden, CT, 1002 feet above sea level. Given an impossibly clear day, is it possible to see Mount Washington in North Conway, NH, 6,288 feet above sea level, and 311 km away? Hint: You must know the radius of the earth.