The vis-viva equation

The vis-viva equation greatly simplifies some calculations in orbital mechanics. It is reminiscent of how conservation of energy can sometimes trivialize what appears to be a complicated problem. In fact, the vis-viva equation is derived from conservation of energy, but the derivation is not trivial. Which is good: the effort required in the of the derivation implies the equation is a shortcut to a place that might take longer to arrive at starting from first principles.

The term vis viva is Latin for “life force” and was applied to mechanics by Liebnitz around 350 years ago. The vis-viva equation is also known as the vis-viva law or the vis-viva integral.

The vis-viva equation says that for an object orbiting another object in a Keplerian orbit

v^2 = \mu\left(\frac{2}{r} - \frac{1}{a}\right)

Here v is the relative velocity of the two bodies, r is the distance between their centers of mass, and a is the semi-major axis of the orbit. The constant μ is the standard gravitational parameter. It equals the product of the gravitational constant G and the combined mass M of the two bodies.

In practice it is often accurate enough to let M be the mass of the larger object; this works for GPS satellites circling the earth but would not be adequate to describe Charon orbiting Pluto.

For a circular orbit, r = a and so v² = μ/r. Then r is constant and v is constant.

More generally a is constant but r is continually changing, and the vis-viva equation says how r and v relate at any given instant. This shows, for example, that velocity is smallest when distance is greatest.

For an object to escape the orbit of another, the ellipse of its orbit has to become infinitely large, i.e. a → ∞. This says that if v is escape velocity, v² = 2μ/r. For a rocket on the surface of a planet, r is the radius of the planet. But for an object already in a high orbit, escape velocity is less because r is larger.

Related posts

Efficiently transferring to a much higher orbit

The most efficient maneuver for transferring from one circular orbit to another circular orbit of roughly the same size is the Hohmann transfer orbit. It requires two burns: one to leave the initial circular orbit into an elliptical orbit, and another to leave the elliptic orbit for the new circular orbit.

If the new orbit is much larger than the original, it can be more efficient to do three burns, inserting two elliptical orbits between the two circular orbits.

In the graph below, the Hohmann transfer orbit moves a satellite from the blue circle to the green circle via the orange ellipse. The orange ellipse fits inside the green circle. The bi-elliptic transfer maneuver replaces the orange ellipse with two half ellipses, both of which extend far beyond the green circle [1].

Hohmann transfer orbit

The dashed curve completes the ellipse but isn’t part of the orbit.

Below is a graph of a bi-elliptic transfer orbit where the radius of the outer circle is 13 times larger than the inner circle and the distance from the furthest point on the ellipse to the center of the circles is 50 times the radius of the inner circle. This is the orbit described in footnote [1].

The meaning of the dotted orange curve is different in this plot. Now it is part of the orbit.

The abrupt change in curvature is at the furthest point of the elliptical orbits is striking, but I believe the graph is correct.

I tried to compare the plot above with other sources. None of my reference books include a plot. When I searched online, I found examples where the two circular orbits are roughly the same size, which defeats the point of the bi-elliptic transfer orbit. Perhaps this was done for aesthetic reasons, but it is not realistic.

Related posts

[1] How far is “far” is a matter of efficiency. A bi-elliptic transfer orbit could extend slightly outside the target circular orbit, but in this case the maneuver would be less efficient than the Hohmann transfer. To move from one circular orbit to another with a radius 13 times greater, the apogee of the transfer ellipses would have to be about 50 times larger than the radius of the inner circular orbit.

The bi-elliptical transfer orbit need not extend past the outer circle at all. It could just kiss the target circular orbit, in which case it reduces to the Hohmann transfer orbit, i.e. the Hohmann transfer orbit is a special case of the bi-elliptic transfer orbit.

Rotating MacBook keys

Shortly after I started using a MacBook I remapped the keys so that they function the same way on Mac OS, Windows, and Linux. The key in the lower left corner, for example, behaves the same way across operating systems, as does the key to the left of the space bar.

Note that I’m going by key behavior and not key name. I go into more detail in my post on cross-platform muscle memory.

It’s been two and a half years since I remapped the keys, and it works well for me. The same keystrokes do the same thing whether I’m on my MacBook laptop or my Linux desktop.

The only drawback is that I’m confused when read documentation telling me how to do something on a Mac. When I see something using the key, I have to ask myself which key that corresponds to on my machine. I’m writing this post in hopes that it will help me memorize how my mappings relate to the original keys.

Here’s a diagram of how I have rotated my keys.

command to fn to option to command

So, for example, if I want to make text bold, I hold down the key in the lower left corner and type b. On my MacBook that key is labeled with a globe and on my Linux box it is labeled Ctrl. But I don’t look at the keys and don’t care what they’re labeled.

I also swapped the Caps Lock and what Mac calls the control key , but I mostly use the big control key only in Emacs. As I noted in the earlier article, Mac essentially has one Windows-like control key (labeled ) and one Emacs-like control key (labeled control).

 

 

Asymmetric generation / verification costs

We tend to think that the effort required to generate a solution and verify a solution are roughly equal, assuming that you need to retrace the generation steps to verify that they are correct. But sometimes verification can be far easier than generation [1].

Factoring

For example, suppose I generate two 1000-digit prime numbers, multiply them together, and ask you to recover the two primes by factoring. It takes a split second to verify whether you’ve found the solution, but finding the solution is practically impossible. The security of the internet depends on this fact. (See posts on RSA encryption here.)

Generative AI

Generative AI is notoriously unreliable. But if it’s far easier to verify a solution than to generate it, it’s OK if an AI solution is unreliable. We’ve had several consulting projects lately that amount to evaluating how well an LLM did what it was supposed to do. The LLMs aren’t perfect—no one expected that they would be—but the tasks is to estimate whether the error rate is acceptable.

Differential equations

George Pólya once said “In order to solve a differential equation you look at it till a solution occurs to you.” He was only half joking. Differential equations courses present solution techniques without justification [2], but the solutions can be justified even if they techniques cannot: stick the solution in to the equation and see whether it works.

Finding primes

For the last 70 years, the largest known prime has been a Mersenne prime, with one exception [3]. This is because there is a way to test whether Mersenne numbers are prime that is more efficient than general numbers.

It takes a lot of computation to prove that a large number is prime, but it is possible to produce a certificate of primality that can be quickly verified. One form of primality certificate is Pratt certificates and another kind is elliptic curve primality certificates.

Optimization

Some optimization problems, such as linear programming or more generally convex optimization, produce certificates that verify that a solution is optimal. Maybe the solution was found on a beefy computer but could be verified on a phone.

Lack of solution

It’s typically easier to prove a solution exists than to prove a solution does not exist. You can prove a solution exists by finding one. This may not be easy to do but easy to verify. Certifying that a problem as no solution is more difficult—how do you know whether you’ve looked hard enough?—but sometimes you can produce a certificate of infeasibility.

Footnotes

[1] The question of whether P = NP asks whether in some sense it is possible to efficiently compute solutions to a large class of problems whose solutions can be verified efficiently [4].

[2] The solution techniques can be justified, though not at the level of mathematics students have when taking an introductory differential equations course.

[3] In 1989 the largest known prime was 391581 × 2216193 − 1.

[4] Can a footnote have a footnote? Sure, why not. The P = NP problem asks whether a problem that can be verified in polynomial time can be solved in polynomial time. But if you didn’t already know this, you probably won’t find this description satisfying. It’s kinda subtle, and I won’t add a footnote to a footnote of a footnote.

Dogecoin anthem

Rocket with Dogecoin mascot

Someone sent me an AI-generated Dogecoin anthem: To Da Moon.

Here’s the audio.

 

And here are the lyrics:

Yo, it started as a joke, now we in the game,
Dogecoin rocket, yeah, remember the name.
Crypto vibes, makin’ history soon,
Strapped to the rocket, we’re goin’ to the moon.

Elon on the tweets, got the memes in check,
Shiba Inu power, cashin’ every check.
From the hodlers to the dreamers, we makin’ it right,
Dogecoin anthem, light up the night.

(Chorus)
Doge to da moon, ya, Doge to da moon
To da moooooooooon
Diamond hands brotha
All aboard the rocket, Doge to da moon!

(Verse 2)
Started at a penny, now it’s hittin’ big heights,
Laughin’ to the bank while we flexin’ the lights.
They said it was a phase, but we changin’ the game,
Shoutout to the legends who believed in the name.

Blockchain movin’, decentralize the power,
Crypto revolution, it’s our finest hour.
From the traders to the hodlers, shout it real loud,
Doge Army strong, and we bringin’ the crowd.

(Chorus)
Doge to da moon, ya, Doge to da moon
To da moooooooooon
Diamond hands brotha
All aboard the rocket, Doge to da moon!
All aboard the rocket, Doge to the moon.

[instrumental]

[vocoder]

The Department of Government Efficiency
is coming for your bureaucracy,
No more waste don’t ya see?

(Bridge)
It’s not just a coin, it’s a vibe, it’s a culture,
Crypto rebel spirit, yeah, we ridin’ like vultures.
From the charts to the memes, we hittin’ the tune,
Dogecoin anthem, it’s our lunar commune.

(Chorus)
Doge to da moon, ya, Doge to da moon
To da moooooooooon
Diamond hands brotha
All aboard the rocket, Doge to da moon!

(Outro)
Moonshot dreams, yeah, the future is bright,
Crypto revolution, takin’ flight tonight.
Dogecoin forever, yeah, we’ll never be through,
42 42 42 42 42 42 forty-twooooooo

Blogging pace

When I started this blog, almost 17 years ago, I posted nearly every day. The first time I went a couple days without posting I got a message from someone asking if everything was OK.

I’ve slowed down since then, and even more lately. Last week I was busy with professional work, and this week I’ve been busy with personal work.

I’ve never had a schedule for this blog: I write when I feel like writing, which usually means several times a week. I’ve averaged 3 posts every 4 days since I started writing here. Presumably I’ll pick back up next week. We’ll see.

If you’d like to be notified when I write something here, you have several options. You could subscribe via RSS to hear of every post as soon as it is published. If you’d rather get a notification of a few posts at a time, along with a little introduction to each, you could subscribe to my newsletter.

You can also follow me on social media, primarily X but also Mastodon and Bluesky.

Confidential OCR

A client emailed me a screenshot of a table rather than pasting the table as text into an email.

I thought about using an LLM to convert it to text, but the table is confidential client information and so I shouldn’t upload it anywhere.

I searched for a command line utility to do OCR and found tesseract. I installed it with

    sudo apt install tesseract-ocr libtesseract-dev tesseract-ocr-eng

and ran it with the default settings

    tesseract screenshot.png textfile

It worked remarkably well. I had to change a C to a U, but otherwise I didn’t have to add or change any text, but I did have to delete a few extraneous parentheses generated by the software.

I work locally in part out of habit; it was the only way to work when I started using a computer. It has numerous advantages, such as being able to keep working when a hurricane knocks out my internet connection, but above all it is private.

I pay more attention to privacy than is convenient because I work in data privacy. And aside from my privacy, I have to protect our clients’ privacy.

Update: According to the comments, ChatGPT uses tesseract. Assuming that’s true, using tesseract directly is better than ChatGPT because it does exactly what you want. No ambiguity as far as what expected. No potential for tinkering with your results before you see them.

Related posts

Perfect numbers

A perfect number is a positive integer equal to the sum of its proper divisors, all divisors less than itself. The first three examples are as follows.

6 = 1 + 2 + 3
28 = 1 + 2 + 4 + 7 + 14
496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248

Even and odd perfect numbers

Every known perfect number is even. No one has proved that odd perfect numbers don’t exist, but people keep proving properties than an odd perfect number must have, and maybe some day this list of properties will contain a contradiction, proving that such numbers don’t exist. For example, an odd perfect number, if it exists, must have over 1,500 digits.

Mersenne primes

A Mersenne prime is a prime number of the form 2p− 1. Euclid proved that if M is a Mersenne prime, then M(M + 1)/2 is an even perfect number [1]. Leonhard Euler proved the converse of Euclid’s theorem two millennia later: all even perfect numbers have the form M(M + 1)/2 where M is a Mersenne prime.

There are currently 52 known Mersenne primes. The number of Mersenne primes is conjectured to be infinite, and the Mersenne primes discovered so far have roughly fit the projected distribution of such primes, so there is reason to suspect that there are infinitely many perfect numbers. There are at least 52.

Triangular numbers

By Euler’s theorem, all even perfect numbers have the form M(M + 1)/2 , and so all even perfect numbers are triangular numbers.

P = 1 + 2 + 3 + … + M

Binary numbers

Even perfect numbers have the form 2p−1(2p − 1), and so this means all perfect numbers when written in binary consist of p ones followed by p − 1 zeros.

For example,

496 = 31 × 32 / 2 = 24(25 − 1)

and 496 = 111110000two, five ones followed by four zeros.

Related posts

[1] Euclid didn’t use the term “Mersenne prime” because he lived 17 centuries before Marin Mersenne, but he did prove that if 2p − 1 is prime, then 2p−1(2p − 1) is perfect.

Food and Grace

RKF Jr eating fast food

I stumbled on a post on X this morning, a commentary on the photo of RFK eating food from McDonalds that has been making the rounds.

This photo divides Puritans from Southerners.

Puritans think because RFK Jr is on the side of health food he can never commit such a “sin.”

Southerners think a rare treat is fine & it’s more important to be gracious in a gathering than to be a stickler.

I can’t read minds, and so I don’t know what RFK’s motives were, but I do believe the post is right about Southern graciousness. Of course this disposition is not limited to the South, nor does everyone in the South live this way.

A puritanical mindset, more typical of metaphorical Puritans than literal Puritans, is flat: all virtues are equally important. A gracious mindset is hierarchical: some virtues take precedent over others. And in a traditional Southern mindset, not offending hosts or guests has high priority.

Bluesky account

Bluesky logo

I’ve had a Bluesky account for over a year, but never posted much on it. Recently I noticed I’d gotten more followers on Bluesky and thought I might try posting there more often.

I am not moving to Bluesky. I have orders of magnitude more followers on X than on Bluesky and so I will focus my effort on X. But I expect to post on Bluesky occasionally.

I learned this morning that there is a bridge that will automatically post your Mastodon content to Bluesky. You should be able to follow

johndcook.mathstodon.xyz.ap.brid.gy

on Bluesky to see the content that I post on my Mastodon account at

johndcook.mathstodon.xyz

Note the server is mathstodon, not mastodon.

It may take some time before the bridge works. I suppose information needs to be propagated analogous to how DNS works. At the time of writing, I can see the bridge account by going to the Bluesky page for the bridge, but I’ve not yet been able to pull up the account in the Bluesky app.

Update: The bridge account is working from the Bluesky app. I’ve posted two articles to Mastodon and verified that they appear in the bridge account.

Just to be clear, we’re talking about two separate Bluesky accounts. My Bluesky account is

johndcook.bsky.social

but my Mastodon posts will be automatically posted to a separate account,

johndcook.mathstodon.xyz.ap.brid.gy.