Plausible phases

So why does that lunar phase method work anyway?

It’s mostly fairly obvious once you start thinking about it. For instance, suppose you know the age of the moon on a given day. Then its age a day later is, kind of obviously, one day more. Except when you hit new moon and it resets, every 29.53… days, and doing modulo 30 approximately accounts for that. So it makes sense for the formula to be something like (x+D) mod 30, where D is the day number and x doesn’t depend on the day (it’s approximately the age, minus 1, on the first of the month).

Now suppose you know the age of the moon on the first day of a given month. Then its age a month later is…? Well, in a 30 day month it’s about 0.47 days more, that is, 30–29.53; in a 31 day month it’s 1.47 days more. Or in an average month of about 365.25/12 = 30.52 days it’s very close to 1 day more. (Actually, since we’re working within the 2000 to 2018 Metonic cycle, the average year length that counts is 1/19 of five leap years and 14 normal years, which comes out to 365.263 days, not that the difference matters much.) If it weren’t for February it’d make sense for the formula to be something like (y+M+D) mod 30, where M is the month number and y doesn’t depend on the day or month (it’s the age at the start of the year, minus 2).

February’s short, though. How to deal with that? Hang on, we’ll get there.

Now suppose you know the age of the moon on the first day of a given year. Then its age a year later is… well, 365.25 days is 12.36 synodic months, so the age advance is 0.36 x 29.53 = 10.9 days. For a decent approximation, 11 days age advance per year, so a formula something like (z+(Y x 11)+M+D) mod 30, where Y is (last two digits of) the year number and z is a constant (the age on 1 Jan 2000, minus 2), would seem reasonable. If it weren’t for February.

It’s too bad February isn’t the last month of the year, then you wouldn’t have to deal with its shortness. Well, make it the last month of the year! Let’s pretend the year begins on March 1. Now within a month each day is a day greater age than the previous; within a (March-to-February) year each month is a day greater age than the previous; and each year is 11 days greater age than the previous. Looked at like this, we don’t have to worry especially about the age advance from February to March. So we could use a formula like the above, if we said March was month 1, April month 2, … January month 11, February month 12, and if we used the preceding year number in January and February. That is, for months March through December use

(z+(Y x 11)+(M–2)+D) mod 30

(here M is still 3 for March, et cetera) and for January and February use

(z+((Y–1) x 11)+(M+10)+D) mod 30 .

That gets a little complicated, though. But we haven’t defined z yet; we can absorb additive constants into it. That is, redefine z–2 as z so we have for March to December

(z+(Y x 11)+M+D) mod 30

and for January and February

(z+((Y–1) x 11)+M+12+D) mod 30 .

But now notice the latter is equal to

(z+(Y x 11)–11+M+12+D) mod 30

or

(z+(Y x 11)+M+1+D) mod 30

which means we don’t have to mess around with the year number or with month numbers like 13 and 14; just use the same formula for all months, except add 1 in January and February!

Nearly there. We just need to establish z. The age of the Moon at 00:00 UTC on 1 Jan 2000 was 23.882 days, so z is 20.882 or about 21. Or more conveniently, about 22, so we can replace z+(Y x 11) with ((Y+2)x 11), and that’s the formula. There are enough approximations here that one can justifiably worry about their accumulating to large errors, but in fact they tend to cancel out. (1 day per month is nearly exact, modulo 30 arithmetic gives you age increases that are too small, 11 days per year gives you age increases that are too large for non leap years and too small for leap years, z=22 means you start out the cycle with an age that’s too large. Sticking with z=21 would have made 1 Jan 2000 more accurate but would have led to too large errors later in the cycle.)

Advertisements

Depends on the phase of the moon

[Edited for corrections and updates]

What’s the phase of the moon on [insert date here]? Do it in your head.

This is something I found on the Internet once, don’t know where; I learned it but eventually forgot it. Having put it back together again I’m posting it here for future reference. It’s more or less similar to the method, attributed to John Conway, described at much greater length at http://gmmentalgym.blogspot.com/2013/01/moon-phase-for-any-date.html. The two are not mathematically equivalent, though, giving slightly different results for some dates. See below.

To start with, assume the required date is in the range from 1 Jan 2000 to 31 Dec 2018. Take the last two digits of the year, add 2, and multiply by 11.

(Good thing multiplying by 11 is easy. You just add the two digits to the same two digits shifted one place left: e.g. 17 x 11 = 17 + 170 = 187. Or another way to think of it: the last digit of the result is the same as the last digit of the original number, the first digit of the result is the same as the first digit of the original number, and the middle digit of the result is the sum of the two digits of the original number. Of course if that sum exceeds 9, you have to add 1 to the first digit of the result.)

Now add the number of the month — 1 for January, 2 for February, and so on, 12 for December. If the month is January or February, add another 1.

Now add the day of the month.

Now divide that number by 30 and take the remainder. The result is, approximately, the age of the moon — the number of days since the new moon. 0 or 29 would be new moon, 14 or 15 would be full moon, about 7 would be first quarter, about 21 would be third quarter. It might be off a day or so (again, see below), but close enough for mental calculation, right?

What about dates outside that range? The moon returns to the same phase every 19 years exactly — or almost exactly; actually more like 19 years plus 2 hours. This is called a Metonic cycle. So add or subtract a multiple of 19 years to get into the 2000–2018 range and then proceed as above. Obviously for dates far in the past or future this breaks down, but for dates in the past or future few decades it’s fine.

Example: July 20, 1969. This is outside our 2000–2018 range but if you add 2×19=38 years you have July 20, 2007. So: for year 2007, (7+2)x11 = 99; for month 7 add 99+7=106; for day 20 add 106+20=126. To get the remainder when divided by 30, subtract the multiple of 30: 126-120=6. Age of the moon is 6 days, corresponding to just about first quarter. Of course July 20, 1969 is the date of the Apollo 11 landing. If you do the same for the other moon landing dates you get ages in the range 5 to 9. For reasons having to do with the angle of the Sun, NASA chose to do all the moon landings at about first quarter.

Example: January 1, 2018. (18+2)x11 + (1+1) + 1 = 223; 223-210=13. The moon is (about) 13 days old on New Year’s Day, so is close to full. In fact full moon occurs at about 2:00 UTC on January 2, or evening of January 1 in the United States. We get two full moons in January and March, none in February!

How well does this work? It depends on how you define “how well”. You’re getting an integer estimate of the age of the moon, which you can compare to the actual age of the moon… when? At 00:00 UTC? Noon?

Choosing to compare to the age at 00:00 UTC, here’s a plot of the error in this calculation for the years 2000 to 2018. There are just two dates where it’s more than 1.6 days off and most dates — 6269 out of 6940 —are less than 1 day off.

For years outside this range but within the nearest 4 Metonic cycles each way (i.e. from 1 Jan 1924 to 31 Dec 2094) I find there are only two dates where the error is (slightly) larger than 2 days, and average errors in each cycle are under 0.35 days. Outside that 171 year range it gets worse.

And here’s a comparison to the results of the method from gmmentalgym. The blue line is the same as above and the red line is gmmentalgym; they coincide for the first 10 years so you see only the red there. After that they differ by 1 day.

You can see gmmentalgym is systematically high in the second half of the cycle, so does worse. Note, though, that if we compared to the age at noon UTC, it would shift this whole graph down by half a day and the red line would be better than the blue.

On the other hand, here’s the 1962–1980 cycle (comparing at 00:00):

Here it looks like the gmmentalgym method is a little better, but would be much worse if comparing at noon UTC. On balance, I wouldn’t say either method has the clear upper hand — they’re both decent approximations, easily done in one’s head.

Getting rid of triangles, and other ways to Euler

That proof that any convex polyhedron made of pentagons and hexagons must contain at least 12 pentagons rests on Euler’s polyhedron formula: If a convex polyhedron has V vertices, E edges, and F faces, then

V-E+F=2

So how is that proved? Lots of ways, some of which rely on the Jordan curve theorem, so then you need a proof of that. An outline of one that doesn’t use the Jordan curve theorem, Triangle Removal, is as follows.

First, transform the polyhedron into a planar graph. You can think of this as removing one face of the polyhedron, and then stretching the boundaries of that face and deforming the other edges until all the edges lie in a plane. Or you can think of it as putting a light source near one face and a plane on the opposite side: the shadow cast onto the plane is the planar graph. This graph has the same number of vertices and edges as the polyhedron, and apparently one fewer face — until you realize the entire plane exterior to the graph can be thought of as a face too.

Okay, we have our graph. Now do the following: Find any interior face that has more than three edges, and draw a diagonal through it from one vertex to another. Doing that increases the number of edges by 1, and divides one face into two, but leaves the vertices unchanged. That means V-E+F is unchanged. Repeat that until all the interior faces are triangles.

Now do this:

  1. Identify a triangle that has two edges on the border of the graph. If you can’t find one, go to step 2. If you can find one, remove those two edges. This eliminates two edges, one face, and one vertex, so again V-E+F is unchanged. Now repeat step 1.
  2. Identify a triangle that has one edge on the border of the graph. Remove that edge. This eliminates one edge, one face, and no vertices, so again V-E+F is unchanged. Now repeat step 1.

Keep repeating as long as you can. Here I get hand wavy, because I’m less than clear on the argument, but: You don’t want to do step 2 if you can do step 1, because that leads to dead ends — specifically, a graph broken up into two disconnected graphs. Always do step 1 if you can, step 2 only if you can’t do step 1, and the graph will stay connected.

For instance, starting from a (kinda irregular) square pyramid. Here it’s turned into a planar graph with one quadrilateral and three triangular faces (the fourth triangle mapping to the exterior of the graph). The quadrilateral is divided into two triangles, and then triangles are removed one at a time.

Since the graph stays connected, the process continues until there’s only one triangle left. At this point we stop and take a tally: There are 3 vertices, 3 edges, and 2 faces (the interior of the triangle, and the exterior). So V-E+F = 2, and since every step we took preserved the value of V-E+F, this proves V-E+F=2 for the original polyhedron.

Something about that proof appeals to me, even though there’s that one part I’m hazy on.

The Sum of Angles proof I find clearer, but less cute. Here again you turn the polyhedron into a planar graph with straight edges. Now add up the interior angles of all the faces (including the exterior face). For face i, which has k_i edges, the sum of the interior angles is (k_i-2)\pi. Summing over all the faces,

\Sigma_{i=1}^F(k_i-2)\pi = \left(\Sigma_{i=1}^Fk_i-\Sigma_{i=1}^F2\right) = (2E-2F)\pi

But we get the same result if we sum the angles meeting at each vertex. For each interior vertex, the sum is 2\pi, adding up to 2\pi(V-k) where k is the number of vertices on the border. For the vertices on the border, it’s 2(\pi-\theta_i) where \theta_i is the exterior angle at the ith vertex of the exterior polygon, and the 2 is because we include the (equal) contributions of the internal and external polygons. But the sum of the exterior angles of a polygon is 2\pi, so the exterior vertices contribute a total of 2\pi k-4\pi. Altogether, then, the sum is 2\pi V-4\pi.

So (2E-2F)\pi = 2\pi V-4\pi, or E-F = V-2,

Either way, no Jordan curve theorem required! Yay.

Hexagonal filth

I was amused by this report of a petition to change the representation of soccer balls on UK signs. At present the image is of a ball divided into brown and white hexagons. At least on one side.

The problem is, if it’s hexagons all the way around, it’s a geometric impossibility. You can’t have a convex polyhedron consisting solely of hexagons, regular or otherwise. In fact: If a convex polyhedron has only hexagons and/or pentagons as faces, then there must be at least 12 pentagons.

The proof is based on Euler’s polyhedron formula: If a convex polyhedron has V vertices, E edges, and F faces, then

V-E+F=2.

For our hex-and-pent-agon polyhedron, consisting of h hexagons and p pentagons, F = p+h, of course. What’s E? Well, each hexagon has 6 edges and each pentagon has 5, but that counts each edge twice since each edge belongs to two faces. So E = (5p+6h)/2.

Now, at each vertex, at least 3 edges meet. If you add up the number of edges at each vertex over all vertices you get at least 3V; but since each edge contributes 2 to that total, 3V \le 2E.

But from Euler’s formula,

3V = 6+3E-3F \le 2E

or

6-3F \le -E

and substituting our formulas for F and E,

6-3p-3h \le -(5p+6h)/2

or

12-6p-6h \le -5p-6h

or

12-p \le 0

or

p \ge 12.

QED.

(The equality holds if every vertex has 3 edges — or equivalently, 3 faces. In particular, if you’re using only regular hexagons and pentagons, then there isn’t room at a vertex for more than 3 faces to meet there. So for a polyhedron made of regular hexagons and pentagons, or any polyhedron with exactly three hexagons and/or pentagons meeting at each vertex, p = 12.)

Hence the government must be petitioned. As The Aperiodical says, “Ban this hexagonal filth!”

My brother the chimp

I’ve written about this before, over on my genealogy blog, but it’s only tangentially related to genealogy. It’s not really recreational mathematics, either, but I want to expand on it somewhere, and since it involves a logical proof, this seems like the least silly place to choose.

So: All humans descend from a common ancestor. Or so many people believe. Literalist believers in the Old Testament would say Adam and Eve are common ancestors of us all. Believers in evolution go further and believe all life on Earth descends from a common ancestor. I’m in the latter group.

When did the most recent common ancestor (MRCA) of all humans live? Simulations suggest it was more recently than you might expect: 2000 to 5000 years ago. (It’s been argued that all persons of European descent share a common ancestor only about 1000 years ago, and genetic analysis [paperFAQ] seems to support that.) Furthermore, going only a few thousand more years back, you arrive at a time when literally every person then alive fell into one of two categories: Those who are ancestors of no one alive today, and those who are ancestors of everyone alive today. I don’t know if there’s a term for that state, so I’ll make one up: Universal common ancestry (UCA). Understand these are probabilistic claims; it would certainly be possible that 20,000 years ago there were people whose living descendants are some but not all of us. But the probability of such a thing is so small it is almost indistinguishable from zero: Something that improbable really cannot be expected to happen even once in the history of the universe. And even if it did, another few thousand years back a non-UCA state would be even more unlikely than that. The probability of UCA back then, and any time previous to that, is absolute certainty for all practical purposes.

Of course this doesn’t just apply to humans: We can talk about the MRCA of all chimpanzees alive today, or all hominins (humans and chimpanzees), or all ruby throated hummingbirds, or whatever.

Now, here’s the weird thing: Long ago, 5 million years or more, amongst members of the species Nakalipithecus or something like it, there lived an individual (call them Nico) who had (at least) two offspring, Chris and Harley. They were Nakalipithecus (or whatever) too, of course, and they mated with other Nakalipithecus and had Nakalipithecus children, who had more Nakalipithecus children, who had … well, you get it. But here’s the thing: All of Chris’s living descendants are chimpanzees. All of Harley’s are human.

That might surprise you. And think how surprised Chris and Harley would be.

But it’s true, and it’s provable (in, again, a certain-for-all-practical-purposes sense).

Nico, you see, was the MRCA of all living hominins. Nico has all living humans and all living chimps as their descendants, and being they’re the most recent common ancestor, no one in subsequent generations can make the same claim.

Now of course much more recent individuals are common ancestors of all living humans (and no chimps), or of all living chimps (and no humans). How about ancestors of all living humans and some living chimps? Or vice versa? But no. We have UCA for humans anytime before several thousand years ago, and I’m sure chimp UCA must be even more recent than that. More than a few thousand years ago, let alone a few million, anyone who was an ancestor of some living chimps was an ancestor of all living chimps. And likewise humans, so any individual with any living humans and any living chimps in their descendants would have to be a common ancestor to all hominins. And Nico was the MRCA, so anyone born after Nico would have to have no living descendants, or humans but no chimps, or chimps but no humans.

We know Nico must have had two or more offspring. If they had only one, then it would have been a common ancestor of all hominins and Nico would not be the MRCA. One of them was Chris, and the other was Harley… and they were born after Nico (duh). The argument above applies to anyone born after Nico, and that includes Chris and Harley. One had to be an ancestor of all living chimps (but no living humans) — that’s Chris — and the other the ancestor of all living humans (but no living chimps) — that’s Harley.

A scenario in which that makes sense is one like this. Seven million years ago, a group of Nakalipithecus woke up one morning, checked Facebook, went to work, or went out to play, or whatever, not realizing that fifty miles away there was a great huge lake held back by a natural dam which had been slowly eroding. That day the dam broke. There was an enormous flood, many of the Nakalipithecus died, and the ones that survived found themselves on two sides of a new, permanent body of water. And the topography was such that none of them were able to cross the water or go around it, so the survivors on one side never again encountered the survivors on the other.

All right, this is not a particularly likely scenario, but it’s a thought experiment, okay?

Nico, alas, died in the flood, but not before saving the life of Chris. Harley, meanwhile, was swept off and ended up on the other side of the water. Within a few thousand years all the Nakalipithecus on one side were descendants of Chris (but not Harley) and all on the other side were descendants of Harley (but not Chris). The two groups evolved apart and eventually gave rise to chimps on one side, humans on the other.

Granted, speciation doesn’t usually work like that. Much of the time geographical separation is a factor in speciation, but not necessarily all the time, and in any case the geographic separation usually isn’t instantaneous. Mountains rise slowly, rivers change course over centuries, and so on.

But it doesn’t matter whether the two groups are sundered in hours or eons. Or even if they are geographically sundered at all. The point is, for whatever reason, two groups evolve away from one another. At the start they are one species and they interbreed frequently, but the frequency of that decreases more and more. And it may decrease over a very long time period, but: There’s a single, momentary last time. A last time a member of one of the groups breeds with a member of the other group. And not long before that, a last time one individual breeds with a member of one group while their sibling breeds with a member of the other, and they have fertile offspring leading to descendants alive today. Their parent is our common ancestor, and the common ancestor of all chimps too. Their children, though, may be your ancestor, may have been Washoe’s, but are not both.

 

Why an almost integer?

Over on https://mathlesstraveled.com there’s a series of posts going on having to do with this:

\displaystyle \begin{array}{cc} n & (1 + \sqrt 2)^n \\ \hline 1 & 2.414213562373095 \\ 2 & 5.82842712474619 \\ 3 & 14.071067811865474 \\ 4 & 33.970562748477136 \\ 5 & 82.01219330881975 \\ 6 & 197.99494936611663 \\ 7 & 478.002092041053 \\ 8 & 1153.9991334482227 \\ 9 & 2786.0003589374983 \\ 10 & 6725.9998513232185 \end{array}

See that? As n increases, (1+\sqrt 2)^n approaches integer values. Odd, huh? Why does it do that?

Despite what should have been a dead giveaway hint, I didn’t figure out the approach revealed in this post. Embarrassing. But having failed on the insight front, what can I do on the obvious generalization front?

Let’s think about quantities of the form

\displaystyle (j+k^{l/m})^n

where j, k, l, m, and n are nonzero integers; l/m is in lowest terms and l>0, m>1, and n>0. For now let’s also restrict m to primes.

To investigate that we’ll consider

\displaystyle \sum_{p=0}^{m-1} (j+e^{i2\pi p/m}k^{l/m})^n

The complex quantities e^{i2\pi p/m} lie on the unit circle in the complex plane and are the vertices of an m-gon. Using the binomial expansion, the sum is

\displaystyle \sum_{p=0}^{m-1} \sum_{q=0}^{n} \binom{n}{q} j^{n-q} \left (e^{i2\pi p/m}k^{l/m} \right)^q

or

\displaystyle \sum_{q=0}^{n} \binom{n}{q} j^{n-q} \left (\sum_{p=0}^{m-1} e^{i2\pi pq/m}\right) k^{lq/m}

Now, for the terms where q is a multiple of m, e^{i2\pi pq/m} is equal to 1 and the sum over p equals m.

Otherwise, we’re summing over the points on the unit circle:

\displaystyle \sum_{p=0}^{m-1} e^{i2\pi p/m}

which is the sum of a geometric series so

\displaystyle = \frac{1-e^{i2\pi}}{1-e^{i2\pi/m}} = 0

For instance, when m=2, the sum is e^0+e^{i\pi} = 1 - 1 = 0. When m = 3, it’s e^0 + e^{2i\pi/3} + e^{4i\pi/3} = 1 - \frac{1}{2} - \frac{1}{2} = 0.

All right then. This means we keep only the terms where q is a multiple of m:

\displaystyle \sum_{q=\textrm{multiple of }m}^n \binom{n}{q} j^{n-q} m k^{lq/m}

which is an integer. Call it I. Then

\displaystyle \sum_{p=0}^{m-1} (j+e^{i2\pi p/m}k^{l/m})^n = (j+k^{l/m})^n + \sum_{p=1}^{m-1} (j+e^{i2\pi p/m}k^{l/m})^n = I

or

\displaystyle (j+k^{l/m})^n= I - \sum_{p=1}^{m-1} (j+e^{i2\pi p/m}k^{l/m})^n

So for large n(j+k^{l/m})^n approaches an integer if and only if the magnitudes of all the m-1 quantities j+e^{i2\pi p/m}k^{l/m} have magnitude <1.

For instance: Let j = 1, l = 1. Then

\displaystyle (1+k^{1/m})^n= I - \sum_{p=1}^{m-1} (1+e^{i2\pi p/m}k^{1/m})^n

Now in the case m = 2,

\displaystyle (1+k^{1/2})^n= I -  (1+e^{i\pi}k^{1/2})^n = I - (1-k^{1/2})^n

The magnitude of 1-k^{1/2}<1 for k<4. In fact it’s zero for k=1, but then 1^{1/2} is an integer anyway; point is, k = 2 or 3 works: (1+\sqrt 2)^n and (1+\sqrt 3)^n both approach integers (the former much more quickly than the latter).

How about m = 3? Then

\displaystyle (1+k^{1/3})^n= I - (1+e^{i2\pi/3}k^{1/3})^n - (1+e^{i4\pi/3}k^{1/3})^n

By symmetry the magnitudes of the two complex numbers are the same, so what we need is

\displaystyle |1+e^{i2\pi/3}k^{1/3}|<1

\displaystyle 1 + k^{2/3} -k^{1/3}<1

or

\displaystyle k < 1

So there are no integer values of k that give convergence to an integer for (1+k^{1/3})^n. It seems evident the same is true for all m>2.

 

An honor just to be nominated

Rich’s p16 came in at 11th place in the 2016 Pattern of the Year awards. First place was never even a remote possibility, not in a year that produced the Caterloopillar and the Copperhead. (I actually thought the latter would win handily, but I guess that’s just my relative lack of interest in engineered spaceships showing.)