Gravitational potential energy

One of the things I planned to do upon retirement was study topics that I had missed, or nearly missed, in school. Some of these would be things that were barely touched on in class; some would be material that was in the textbook but not covered in class; and some would be topics that were adjacent to the classes I took. When I was just out of school, I thought I’d be able to start following up on these topics pretty much right away. And if you allow for an elastic definition of “pretty much right away,” I’m on schedule.

My first topic is orbital mechanics, and the textbook I’ve chosen is Victor Szebehely’s Adventures in Celestial Mechanics, published in 1989 by the University of Texas Press.

Adventures in Celestial Mechanics

As textbooks go, it’s fairly thin at 175 pages, and the math is pretty elementary—a good book to start with, I think. I’m seven chapters in and taking a little break to review what I’ve learned so far. I’m treating this as if I were in class and Szebehely was using the text as his lecture notes. In other words, I’m not just reading the book; I’m going through all the derivations and solving all the problems. If I wanted a shallow understanding, I’d just watch a few Neil deGrasse Tyson videos on YouTube and call it a day.1

One of the things I found odd about Szebehely’s approach is that he never derives—or even presents—the expression for gravitational potential energy. I decided to do it myself and then write it out here, so I could find it easily.

In outline, the derivation works this way:

The force of gravity between two bodies is

F=Gm 1m 2r 2

where m 1 and m 2 are the masses of the two bodies, r is the distance between their mass centers, and G is the universal gravitational constant,

G=6.674×10 11m 3kgs 2

This force acts on each body in the direction of the other body, so the work done by gravity as the distance between the bodies changes from r 1 to r 2 is2

W=∫ r 1 r 2Fdr=∫ r 1 r 2Gm 1m 2r 2dr

The minus sign is there because the force acts in the opposite direction of the distance increment, dr.

Carrying out the integration, we get

W=Gm 1m 2r 2Gm 1m 2r 1

The work and energy principle says

W=ΔU

where ΔU is the change in potential energy, i.e.,

ΔU=U(r 2)U(r 1)

The negative sign in the work-energy equation comes from what potential energy is all about: the potential to do work. If a force does positive work, its potential to do further work has decreased.

Putting this together, we get

ΔU=U(r 2)U(r 1)=W=(Gm 1m 2r 2Gm 1m 2r 1)

Sorting out the negative signs, we see that

U(r 2)=Gm 1m 2r 2

and

U(r 1)=Gm 1m 2r 1

so our expression for gravitational potential energy at any distance, r, is

U=Gm 1m 2r

If you’re worried about the negative sign in this expression, don’t be. Recall from your first course in physics that it’s the change in potential energy that matters, not the value at any given position. The key thing to note about this expression is that U increases as r increases, which is how it should be.


Well, that didn’t take too long. Let’s expand on this solution. You might also remember from physics class that the potential energy of a body of mass m near the surface of the Earth is

U=mgh

where h is the elevation of the body and g is the acceleration due to gravity. How does this expression compare to what we just derived?

First, let’s rewrite our expression for U to specialize it for a body near the surface of the Earth:

U=Gm Emr

where m E is the mass of the Earth.

Because the body is close to the surface of the Earth, we’ll expand our expression for U in a Taylor series about r E, the radius of the Earth. That will be

U(r)=U(r E)+U (r E)(rr E)+12!U (r E)(rr E) 2+

The further terms in the expansion will have higher derivatives of U, higher powers of rr E, and be divided by higher factorials.

Since

U (r)=Gm Emr 2 U (r)=2Gm Emr 3 U (r)=6Gm Emr 4

and so on, the expansion works out to

U(r)=Gm Emr E+Gm Emr E 2(rr E)Gm Emr E 3(rr E) 2+

where the further terms will be multiplied by higher powers of rr E and divided by higher powers of r E. Note that the factorials get canceled by the coefficients of the derivatives. Also, we get alternating signs because of the alternating signs of the derivatives.

At this point, we recognize that rr E is the distance above the Earth’s surface, which is h. And because we care only about the change in potential energy with changes in h, we can drop the constant initial term. So if we collect the common terms, we get

U=Gm Emr E 2h(1hr E+(hr E) 2)

Since h≪r E, the term in parentheses is approximately one, and

U=Gm Emr E 2h=m(Gm Er E 2)h

Is the term in the parentheses equal to g? According to NASA

m E=5.9722×10 24kg

and

r E=6.371×10 6m

Plugging in those values and the value of G we saw earlier, we get

Gm Er E 2=9.82m/s 2

which is pretty close to the textbook value for the acceleration due to gravity, g=9.81m/s 2.

But shouldn’t it be closer? We have enough digits in our values for G, m E, and r E that we shouldn’t be off in the third digit of g. What are we missing? Mainly that the Earth is spinning. The centrifugal effect on the surface of the Earth is small, but it’s the primary reason for the difference between Gm E/r E 2 and g.


  1. There’s a place for Neil deGrasse Tyson videos, but that’s not where I want to go. 

  2. Strictly speaking, the integrand of the work expression is the dot product of the force vector and the distance increment vector, but for gravity those two vectors are parallel, so we can get by with scalar terms. 


A tardy assessment of the Apple Sports app

I tried the Apple Sports app when it came out in February and abandoned it almost immediately. Lots was written about Sports in its first couple of weeks, but I was on a blogging hiatus back then. I’ve recently looked at it again to see if I was too hasty or if its failings had been fixed (no to both), so I figured I’d write up my thoughts.

I won’t be saying anything about how Sports fits into the Apple sports universe; go to Jason Snell for that. And I won’t be talking about how its design may be a harbinger of iOS 18; that’s Lickability’s baliwick. But I do want to talk about its design as a sports app.

You may recall that the main selling point of Sports was its ability to give you up-to-date scores. Eddy Cue said, “I just want to get the damn score of the game.” That’s Apple marketing at its best: it’s short, pithy, and it directs you to the app’s best feature, the presentation of today’s scores.

It’s easy to set up Sports to follow your favorite leagues/conferences and teams, and once that’s done the presentation of scores is logical. Games being played in your chosen leagues are displayed generally in chronological order, but the games with your favorite teams are floated to the top. That’s the right way to do it.

But scores are only part of what a good sports app is about. Sports apps are used not only when you can’t watch a game and want to be kept plugged in, they’re also used—even more often used, I think—to give you background information on the game you’re currently watching. Announcements during a broadcast are ephemeral, but a sports app can tell you how many fouls Nikola Jokić has at any time.1 And this is where Sports falls down.

In basketball, for example, the box score statistics are thin. There’s no info on free throws, steals, blocks, turnovers, or personal fouls. League standings are missing common stats like the home/away record, record over the last 10 games, and win/loss streaks, These are things fans want and that other sports apps provide. No amount of beautiful presentation is going to make up for missing data.

And, weirdly for an Apple app, the presentation isn’t beautiful—it’s actually awful. Here’s a screenshot of the box score from last night’s Chicago Bulls/Detroit Pistons game:

Chicago Bulls box score from Sports app

Like many sports apps, Sports splits the box score into starters and bench players (during a game, the players on the court have marks next to their names). Apple’s designers decided to put the headers only at the top of the Starters portion of the table, which I would applaud if they’d aligned the columns of the Bench portion of the table with the columns of the Starters portion. But they didn’t. Bench rebounds, for example, are more or less under the PTS header. This is not how you present a table of numbers, and it’s inconceivable to me that anyone would look at this mess and give it a pass.

The programming problem here is obvious. Although the use of a single header suggests this is meant to be seen as a single table, inside the app the Starters and Bench parts are two separate tables. The column spacing of the Starters table is based on widths that include the headers (several of which are wider than the data below them), and the column spacing of the Bench table is based on widths of the data alone. Instead of looking at both tables, getting the maximum width of each column, and applying that to both tables, the programmers simply allowed the tables to be formatted separately, thus saving themselves at least five lines of code.

Again, did nobody at Apple look at this before putting it in the App Store? And has nobody looked at it in the seven weeks since?

I admit I may be unduly irritated by this because I spent a lot of my career making tables of figures and doing my best to make them easy to read. But before you dismiss me as a crank, look at what happens when you swipe on the tables left and right to see the additional stats. They get even further misaligned because the two tables don’t scroll together.

When you use a single header, you’re telling the reader that they’re looking at a single table. But this design cheats the reader.

I’ve used several sports apps over the years. Many of them are crappy and fill your small screen with ads. A good Apple Sports app would fill a real need. But I can’t use it until it stops offending me.


  1. My examples are going to be about basketball because that’s the sport I care about the most. 


Counting poker hands

In this morning’s blog post, John D. Cook talks about poker hands and their probabilities. In particular, he says

For a five-card hand, the probabilities of 0, 1, or 2 pair are 0.5012, 0.4226, and 0.0475 respectively.

Upon reading this, I assumed there’d be an explanation of how these probabilities were calculated. But no, he just leaves us hanging. So I sat down and worked them out.

The probabilities are going to be calculated by dividing the number of ways we can get a certain type of hand by the total number of possible hands. So let’s start by working out the denominator. There are 52 cards, so if we deal out 5 cards, there are

(525)=2,598,960

possible ways to do it. The symbol that looks sort of like a fraction without the dividing line represents the binomial coefficient,

(nk)=n!k!(nk)!

This is not only the coefficient of binomial expansions, it’s also the number of ways we can choose k items out of n without regard to order, also referred to as the number of combinations.

To figure out the number of one-pair hands, imagine the deck laid out in 13 piles: a pile of aces, a pile of kings, a pile of queens, and so on. We then do the following:

  1. Pick one of the piles. There are 13 ways to do this.
  2. From that pile, choose 2 cards. There are

    (42)=6

    ways to do this.

  3. Pick three other piles. There are

    (123)=220

    ways to do this.

  4. Pick one card from each of these three piles. Since there are 4 cards in each pile, there are 4 3=64 ways to do this.

So the total number of one-pair hands is

13×6×220×64=1,098,240

and the probability of getting a one-pair hand is

1,098,2402,598,960=0.42257

Moving on to two-pair hands, we start with the same 13 piles we had before. We then do the following:

  1. Pick two of the piles:

    (132)=78
  2. Pick two cards from each of these piles:

    (42)×(42)=6×6=36
  3. At this point, any of the remaining 44 cards will give us a two-pair hand.

Therefore, the total is

78×36×44=123,552

and the probability of drawing a two-pair hand is

123,5522,598,960=0.04754

Counting the number of no-pair hands is a little trickier because we have to make sure we don’t mistakenly count better hands, i.e., straights and flushes. Starting again with our 13 piles, we do the following:

  1. Pick 5 piles

    (135)=1,287
  2. Eliminate all the straights from this number. The number of straights is most easily done through simple enumeration:

    A–5, 2–6, 3–7, 4–8, 5–9, 6–10, 7–J, 8–Q, 9–K, 10–A

    So 10 of our 1,287 possible pile selections will give us a straight. That leaves 1,277 non-straight possibilities.

  3. Pick one card from each of the selected piles. That gives 4 5=1,024 possibilities.
  4. Eliminate the flushes from this set of possibilites. There are 4 flushes, leaving 1,020 possibilities.

These steps give us

1,277×1,020=1,302,540

hands that are worse than one-pair. The probability of getting such a hand is

1,302,5402,598,960=0.50118

I kept one more digit in my answers than John did, but they all match.


My 2024 Eclipse

I drove down to Vincennes, Indiana, yesterday to see the eclipse, and everything was just about perfect—some through planning and some through serendipity. Here’s a brief review.

Vincennes was not my first choice. Using the eclipse path map at Time and Date, I looked for the shortest distance from Naperville, Illinois, to the path and figured I’d shoot for a rural area near Indianapolis.

Eclipse path map showing Illinois and Indiana

As Eclipse Day got closer, I began to have second thoughts. Two reasons:

  1. Traffic before and after the 2017 eclipse—which I saw with my wife and sons in southern Illinois—was a nightmare. Going near a decent-sized city ringed by a set of interstate highways seemed like a bad idea.
  2. Weather reports for the Indianapolis area were a little sketchy. Apple’s Weather app said it would be cloudy in the morning turning to partly cloudy by the time of the eclipse. “Partly cloudy” covers a wide range of cloud cover. Various weather websites also predicted partly cloudy skies, with less cloud cover as you moved southeast along the eclipse path.

So I started looking into Vincennes. It’s about an hour farther than Indianapolis under normal driving conditions, but I could get there via state and US highways instead of interstates, so I figured it was unlikely to attract as many people as the Indianapolis area. And it was supposedly less likely to have clouds.

Ultimately, it was a game-day decision. When I woke up on Monday morning and looked at the forecasts for Indianapolis and Vincennes, Vincennes seemed like it would have slightly better weather. And when I left, sometime between 5:30 and 6:00 in the morning, my route to Vincennes showed no delays. I didn’t truly trust the traffic because I wouldn’t expect people to be crowding the roads until I was two or three hours into my trip.

The drive went very well. I worked my way south and east to US 41 in Indiana (it became an hour later when I crossed the state line) and headed south. As I headed down through the land of windmills, Trump signs, and dollar stores, the traffic was light and the sun was bright. Somewhere—I think it was a bit north of Terre Haute—there was a billboard encouraging everyone to go to Vincennes for the eclipse, but there didn’t seem to be that many people following its directions.

I rolled into Vincennes around 11:30, desperate to use a bathroom. I stopped at a McDonalds and then felt obligated to eat there after using the facilities. Here’s where the serendipity struck. As I was eating (worst fries I’ve ever had at a McDonalds—remind me to tell you about the glorious fries I once had at Hamburger University), I started looking on my iPhone for a park nearby where I could kill some time before the eclipse, which wouldn’t get started for over two hours.

A website describing Kimmel Park on the north side of town, right along the Wabash River, said it had 1.8 miles of walkways. This appealed to me, as I’d missed my morning walk. For no particular reason, I opened the eclipse path page at Time and Date and zoomed in as far as I could. The centerline of the path went right through Kimmel Park.

Eclipse path detail in Vincennes

You see, I had not been planning to stay in Vincennes for the eclipse. It had looked to me as though the path went north of town (which it kind of does), so I was going to find a spot alongside a county road north and east of town, between Vincennes and Bruceville, for watching the eclipse. But now I had a better place, assuming the park wasn’t overrun with visitors.

It wasn’t. There were well-marked lots with free parking and mostly empty spots near the park. And while the park was far from empty, it wasn’t hard to find a place to settle in after I’d walked around it once. (While I’m sure the “1.8 miles of walkway” is accurate, that must be if you take every last branch, possibly doubling back on yourself.)

Here’s where I parked and where I sat for the eclipse.

Kimmell Park in Vincennes, Indiana

I used the location data for a photo I took to mark the exact location.

My postion in Kimmell Park

Honestly, I think I was at the next tree north and east of where my photo said I was, but I don’t want to argue with GPS.

How does this compare with the centerline of the eclipse path? This morning, I opened Mathematica and used its new SolarEclipse function to mark the path on map that’s more zoomed-in than I could get with Time and Date:

eclipse = SolarEclipse[DateObject[{2024, 4, 8}]];

GeoGraphics[{Red,
    SolarEclipse[eclipse, "ShadowAxisLine"],}, 
  GeoCenter -> GeoPosition[{38.69715, -87.51673}], 
  GeoRange -> Quantity[250, "Meters"], GeoScaleBar -> "Feet", 
  ImageSize -> Large]

Eclipse path through Kimmell Park

Apparently, the park district has changed the routing of the paved areas, but you can see that I was no more that 300–400 feet from the centerline. Recent rains had left the ground and some of the pavement wet by the peak of the triangle, and the shady areas near the treeline due north of me was already occupied. So I was satisfied with my spot.

There were some thin, wispy clouds, but it was obvious well before the eclipse started that the view would be fantastic. And it was. During the last 10–15 minutes or so before totality, I did nothing but look at the sun (through the glasses I’d kept from 2017), watching as the thin arc of sun got shorter until it disappeared entirely. I pulled off my glasses as a cheer went up and looked into the deep black of the moon surrounded by the white corona.

I did take a quick iPhone photo during totality, more as a reminder than anything else.

My iPhone photo of the eclipse

Patrick MaCarron—who was also in Vincennes, but I don’t know where—took a great photo of the eclipse, and you should follow the link to see it. It shows two red prominences: a large one near the bottom and a smaller one along the right edge. I saw the one near the bottom with my naked eye; it was a sharp red dot at the bottom of the black circle. I was unsure if I’d really seen it until I saw Patrick’s photo later on Mastodon.

I also found Jupiter (to the right) and Venus (to the left). I didn’t see Mars, Mercury, or that comet that was supposed to be at the edge of unaided visibility. This, I think, is where those wispy clouds came into play. I could see them around Jupiter, sort of how you see clouds on a moonlit night.

I hung around for a while after totality, but watching the Moon retreat isn’t as fun as watching it advance. As I walked back to the park entrance, I stopped to take photos of my shadow on the sidewalk. I made a sort of pinhole by squeezing tight an OK sign. You’ll have to zoom in to see the crescent coming through the small aperture.

Crescent seen between fingers

Google Maps routed me through Champaign, Illinois, on my way home, so I ordered a Papa Del’s pizza when I was about an hour away and took it home for a late dinner. I got home just as the Men’s National Championship game was starting. I watched it while eating pizza—the perfect end to a perfect day.