Numeronymize
July 5, 2024 at 5:07 PM by Dr. Drang
Anil Dash quotetweeted this post from Ian Brown on Mastodon this morning:
I was so excited to learn that abbreviations like “a11y” or “c14n” are called “numeronyms” that I wrote an #Emacs^H^H^H^H^H^H #E3s extension to make it easier to use them.
The tweet^{1} links to this GitHub page. First I thought it was funny to see a link to an Emacs Lisp script the day after I posted about my dateconvert
script. Then I thought “I want to be able to do that, but not in Emacs.” So I built this Keyboard Maestro macro, which I also called Numeronymize:
If you download and install it, it will appear in your Global Macro Group.
Here’s how to use it: Type the word you want to numeronymize in any editable text field. For example,
accessibility
With the cursor blinking at the end of the word, type ⌃⌥⌘3 (on standard American keyboards, the number symbol, #, is on the 3 key). The word before the cursor will be selected and shortened to its numeronym,
a11y
Honestly, I don’t think I’ll be using this macro very much, but it was fun and easy to write. The key is the Perl oneliner in the third step:
/usr/bin/perl C pe 's/(.)(.+)(.)/$1 . length($2) . $3/e'
I have more than one Perl executable on my computer, so I’m being explicit here about calling the one in /usr/bin
that comes with macOS. The C
switch tells Perl to treat the input and output as UTF8 (more on this below); the p
switch tells it to loop through the input, apply the code to it, and print out the result; and the e
switch tells it to treat the following string as the code to execute:
s/(.)(.+)(.)/$1 . length($2) . $3/e
This is the cool part, because Perl’s substitute command has an e
option that means “evaluate.” It treats the replacement as a chunk of Perl code, evaluates it, and returns the result. Here, it concatenates the first letter, the length of the middle string of characters, and the final letter. When I saw what Brown’s numeronymize extension did, I immediately thought of this feature of Perl and knew I could do it in a oneliner.
The C
switch isn’t needed if all we care about are words made of ASCII characters. But what if we want to shorten this?
streichholzschächtelchen
Without the C
, we’d get
s23n
because the length
function normally returns the length in bytes, and the ä
takes up two bytes. But with the C
, length
understands that we want characters, not bytes, so the macro returns
s22n
which is what we want.
A couple of other notes:
 The macro starts out by simulating the ⌥⇧← keyboard combination to select the word to the left of the cursor. My thinking was that I’d most often use this macro right after typing or pasting a long word. So it made sense to have the macro do the word selection this way. If you think it would be better to do the selection yourself, delete this first step.
 Because I use the clipboard to copy the long word and to hold the shortened numeronym before pasting, two items are added to Keyboard Maestro’s clipboard history. But because they’re just temporary items, I don’t think they belong in the history, so the last two steps in the macro delete the most recent two items in the clipboard history.
Thanks to Ian Brown for making the Emacs extension and to Anil Dash for bringing it to wide attention. Dash says his favorite numeronym is “e13n,” but I think he’s leaving out one of the T’s.

Yes, I’m using “tweet” and “retweet” to refer to posts on Mastodon. Since Twitter has given up its name, I feel these words are now fair game for any Twitterlike service. After all, they were invented by the Twitter users, not the company. ↩
Happy 2,460,496!
July 4, 2024 at 2:42 PM by Dr. Drang
I was thinking about calendar conversions the other day and remembered that it had been years since I used my dateconvert
script. I wondered if it would still run. It didn’t, but it was easy to fix.
The first problem was the shebang line. dateconvert
is written in Emacs Lisp, and the first line used to be
#!/usr/bin/emacs script
Because Apple no longer includes Emacs as part of macOS, there’s no executable with that name at that location anymore. The Emacs on my computer now was installed via Homebrew and is where all the other Homebrew executables are. So I changed the shebang line to
#!/opt/homebrew/bin/emacs script
That made it run fine if called with no arguments, but it failed if run with arguments, i.e.,
$ dateconvert 7 4 1776
Error: voidfunction (stringtoint)
[many lines of error messages]
Symbol’s function definition is void: stringtoint
I looked up the Emacs Lisp string conversion functions and found that stringtoint
had been replaced with stringtonumber
.^{1} So I changed that function call and everything was hunkydory.
For reasons lost in the mists of time, I originally had one of the conversions be to the Mayan calendar. Maybe that’s because there was a lot of silly talk back then about the Mayan calendar predicting the end of the world. Whatever the reason, I didn’t care about that conversion anymore, so I dropped it.
I then added the Julian Day Number, which seemed like it could conceivably be useful if I ever need to look up some astronomical observation from back when Western calendars were in flux. OK, that’s pretty unlikely, but it’s more likely than needing the Mayan calendar. I labeled the JDN “Astro” in the script’s output.
So the source code for dateconvert
is now this:
#!/opt/homebrew/bin/emacs script
(require 'calendar)
; Use current date if no date is given on the command line
(if (= 3 (length commandlineargsleft))
(setq mydate (mapcar 'stringtonumber commandlineargsleft))
(setq mydate (calendarcurrentdate)))
; Make the conversions and print the results
(princ
(concat
"Gregorian: " (calendardatestring mydate) "\n"
" ISO: " (calendarisodatestring mydate) "\n"
" Astro: " (calendarastrodatestring mydate) "\n"
" Julian: " (calendarjuliandatestring mydate) "\n"
" Hebrew: " (calendarhebrewdatestring mydate) "\n"
" Islamic: " (calendarislamicdatestring mydate) "\n"
" Chinese: " (calendarchinesedatestring mydate) "\n" ))
It works like this. With no arguments, it converts today:
$ dateconvert
Gregorian: Thursday, July 4, 2024
ISO: Day 4 of week 27 of 2024
Astro: 2460496
Julian: June 21, 2024
Hebrew: Sivan 28, 5784
Islamic: Dhu alHijjah 27, 1445
Chinese: Cycle 78, year 41 (JiaChen), month 5 (GengWu), day 29 (JiSi)
With three arguments (in the American ordering of month, day, year) it converts the given day:
$ dateconvert 7 4 1776
Gregorian: Thursday, July 4, 1776
ISO: Day 4 of week 27 of 1776
Astro: 2369916
Julian: June 23, 1776
Hebrew: Tammuz 17, 5536
Islamic: Jumada I 17, 1190
Chinese: Cycle 74, year 33 (BingShen), month 5 (JiaWu), day 19 (JiChou)
So it’s been 90,580 days since the signing of the Declaration of Independence. If you’re wondering when we’ll hit the 100,000day mark, that’ll be on JDN 2,469,916, or April 19, 2050. I’m hoping to still be around then, and I hope the country is, too.

The documentation makes it sound as if both functions existed simultaneously and
stringtoint
was dropped as an unnecessary redundancy. I don’t feel like digging through change logs to get the full story. ↩
Column buckling analysis
July 3, 2024 at 2:04 PM by Dr. Drang
Last time, we looked at the solutions for six elementary column buckling problems. In this post, we’ll outline the method for getting those solutions and give a couple of detailed examples.
In all of these problems, the column is assumed to be straight and prismatic, which means that the crosssection doesn’t change along its length. The minimum moment of inertia of the crosssection is $I$, and the column buckles in the direction associated with $I$.^{1} The column has a compressive load $P$ acting at either end, and the load is aligned with the centerline of the column. The material is linearly elastic with a Young’s modulus of $E$, and there is no yielding of the material at any point.
With these assumptions the governing differential equation of the column is
$$EI\phantom{\rule{thinmathspace}{0ex}}\frac{{d}^{4}y}{d{x}^{4}}+P\phantom{\rule{thinmathspace}{0ex}}\frac{{d}^{2}y}{d{x}^{2}}=0$$where $x$ is the coordinate along the centerline of the column and $y$ is the (small) lateral deflection of the column when it buckles. This is a fourthorder linear differential equation with constant coefficients, which is great for us because it’s one of the few types of differential equation that can be solved analytically.
Here’s the general form of the solution,
$$y=A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda x+B\phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\lambda x+C\phantom{\rule{thinmathspace}{0ex}}x+D$$where $\lambda $ is a constant that combines the coefficients,
$$\lambda =\sqrt{\frac{P}{EI}}$$and $A$, $B$, $C$, and $D$ are the four constants of integration that appear when solving a fourthorder differential equation. We’ll use the boundary conditions (how the column is supported at either end) to solve for these.
Simplesimple
The column with simple supports at either end is the fundamental problem of column buckling, and it’s pretty easy to work out its solution.
(I’m showing the column horizontally to take up less room on the screen. Because we’re not considering the weight of the column itself, the orientation doesn’t matter.)
We’ll start with the conditions at $x=0$. Here, the column is prevented from moving laterally, so
$$y(0)=B+D=0$$or
$$D=B$$The column is free to rotate at this end, which means there’s no bending moment. Since the bending moment is proportional to the second derivative of the deflection,
$${y}^{{\textstyle \prime}{\textstyle \prime}}(0)={\lambda}^{2}B=0$$where I’m using the prime notation for derivatives. This means $B=0$ and therefore $D=0$, which simplifies things nicely.
Now we look at the other end, $x=L$, where again the lateral defection is zero,
$$y(L)=A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda L+C\phantom{\rule{thinmathspace}{0ex}}L=0$$and the bending moment is zero,
$${y}^{{\textstyle \prime}{\textstyle \prime}}(L)=A\phantom{\rule{thinmathspace}{0ex}}{\lambda}^{2}\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda L=0$$Since $\lambda $ isn’t zero, the second equation means
$$A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda L=0$$and combining that with the first equation tells us that $C=0$.
So we’ve eliminated all the constants of integration except $A$. The equation above means either
$$A=0$$or
$$\mathrm{sin}\lambda L=0$$The first of these is the solution when the column is straight and $y=0$ throughout its length. It is a solution, but it’s trivial—we know the column can be straight if the load is small.^{2} We’re interested in the nontrivial solution for which the column isn’t straight. That’s the buckling solution.
So when does $\mathrm{sin}\lambda L=0$? When $\lambda L=n\pi $, for any integer $n$. The buckling load will be when $P$ is the smallest positive value that satisfies this equation. In other words,
$$(\lambda L{)}_{\mathrm{cr}}=\sqrt{\frac{{P}_{\mathrm{cr}}}{EI}}\phantom{\rule{thinmathspace}{0ex}}L=\pi $$or
$${P}_{\mathrm{cr}}=\frac{{\pi}^{2}\phantom{\rule{thinmathspace}{0ex}}EI}{{L}^{2}}$$which is the answer we saw in the last post for the simplesimple column.
What about $A$? Well, $A$ is undetermined. Remember at the top of the post where I snuck the parenthetical “(small)” into the description of $y$ and didn’t explain it? Here’s where that comes in. Buckling deflections really aren’t small, and to solve for them properly we’d have to start with a nonlinear differential equation. But that doesn’t mean what we’ve done is useless. The value of ${P}_{\mathrm{cr}}$ is correct, and what we’ve done tells us that the deflected shape of the buckled column,
$$y=A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda x=A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\frac{\pi \phantom{\rule{thinmathspace}{0ex}}x}{L}$$is onehalf of a sine wave. This is useful because it helps us visualize the buckling.
Fixedsimple
This is the problem that inspired the previous post. It won’t take as long because we can use some of the simplesimple results to speed things up.
Again, we start with the general solution,
$$y=A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda x+B\phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\lambda x+C\phantom{\rule{thinmathspace}{0ex}}x+D$$The boundary conditions at $x=0$ are the same as before,^{3} so we know that
$$B=D=0$$The boundary conditions at $x=L$ are partly the same and partly different. The deflection is zero,
$$y(L)=A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda L+C\phantom{\rule{thinmathspace}{0ex}}L=0$$and the slope is zero,
$${y}^{{\textstyle \prime}}(L)=A\phantom{\rule{thinmathspace}{0ex}}\lambda \phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\lambda L+C=0$$The slope condition means
$$C=A\phantom{\rule{thinmathspace}{0ex}}\lambda \phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\lambda L$$Substituting this into the deflection boundary condition gives
$$A\phantom{\rule{thinmathspace}{0ex}}\mathrm{sin}\lambda LA\phantom{\rule{thinmathspace}{0ex}}\lambda L\phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\lambda L=0$$or
$$A\phantom{\rule{thinmathspace}{0ex}}(\mathrm{sin}\lambda L\lambda L\phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\lambda L)=0$$Once again, there’s the trivial solution, $A=0$, and the nontrivial solution,
$$\mathrm{sin}\lambda L\lambda L\phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\lambda L=0$$Divide this through by $\mathrm{cos}\lambda L$ and move one term to the other side of the equation to get
$$\mathrm{tan}\lambda L=\lambda L$$As we saw in the previous post, the smallest positive solution is
$$\lambda L=4.4934\dots $$and therefore
$${P}_{\mathrm{cr}}=\frac{{4.4934}^{2}\phantom{\rule{thinmathspace}{0ex}}EI}{{L}^{2}}=\frac{20.19\phantom{\rule{thinmathspace}{0ex}}EI}{{L}^{2}}$$Once again, we can’t solve for $A$, but we can see that the buckled shape is
$$y=A\phantom{\rule{thinmathspace}{0ex}}(\mathrm{sin}\frac{4.49\phantom{\rule{thinmathspace}{0ex}}x}{L}\frac{4.49\phantom{\rule{thinmathspace}{0ex}}x}{L}\phantom{\rule{thinmathspace}{0ex}}\mathrm{cos}\frac{4.49\phantom{\rule{thinmathspace}{0ex}}x}{L})$$which isn’t any sort of standard trig function, but it is what I plotted for the fourth column in this image:
All the other column problems in the image above can be solved the same way. The boundary conditions are different, but the solution process is the same. Notice that all the columns other than the fixedsimple buckle into shapes that are portions of sine waves. As we showed above, the simplesimple column is half of a sine wave. As for the others:
 The fixedfree column is a quarter of a sine wave.
 The fixedfixed column is a full sine wave.
 The fixedguided column is half of a sine wave.
 The simpleguided column is a quarter of a sine wave.
The effective length is based on the number of half sine waves the buckled shape has.
This simple visualization of the buckled shapes allows you to work out the buckling loads for all four of these columns based on the simplesimple column. The only other thing you have to remember is 4.49.
Tangents and columns
July 1, 2024 at 2:35 PM by Dr. Drang
Continuing with John D. Cook posts, I should write up a little thing that I meant to post about a month ago. It was in response to this post of Cook’s in which he considers solutions to the equation
$$\mathrm{tan}x=x$$Cook talks about the solution in terms of the sinc function and Bessel functions, but my immediate response upon seeing that equation was a single number: 4.49. I first saw this equation over 40 years ago and the solution—or at least one of the solutions—has been stuck in my head ever since.
As Cook shows in his post, the best way to think about solutions to this equation is to consider two separate equations,
$$y=\mathrm{tan}x$$ $$y=x$$and plot them both on the same graph. Wherever we see intersections will be solutions to $\mathrm{tan}x=x$.
As you can see, there are an infinite number of solutions. The obvious one, which you probably didn’t need the graph to figure out, is $x=0$. After that are solutions that are relatively close to the asymptotes of the tangent function at the odd multiples of $\pi /2$ (excluding $\±\pi /2$).
While the graph helps you figure out where the solutions are, you’ll still have to use some numerical technique to get the value. You might think that direct iteration,
$${x}_{n}=\mathrm{tan}{x}_{n1}$$would work, but if you try it, you’ll soon find yourself diverging instead of converging. The reasons are given in this blog post from a few years ago. A direct iteration formula that will converge is
$${x}_{n}={\mathrm{tan}}^{1}{x}_{n1}+\pi $$where the added $\pi $ term accounts for the fact that the inverse tangent function returns values between $\pi /2$ and $\pi /2$. If you start with a number just under $3\pi /2$, this formula will quickly converge to the solution that’s circled in the graph.
The circled intersection is the lowest postive solution. That’s 4.4934094579…, or just 4.49 for short, which is the solution that matters in one of the standard problems of column buckling and is the reason I’ve remembered it all these years.
Column buckling is governed primarily by the restraints, if any, at the column ends. Four types of ends are considered standard:
 A simplysupported end is prevented from moving laterally but has no restrictions on rotation.
 A fixed end is prevented from both lateral movement and rotation.
 A free end has no restrictions on either lateral movement or rotation.
 A guided end is prevented from rotating but has no restrictions on lateral movement.
The six standard column types come from combinations of these four end conditions. Here’s a graphical representation of the columns and the shapes they take on when they buckle. Sorry about the size of the formulas—you can zoom in to get a better view.
From left to right, they are
 Simplesimple
 Fixedfree
 Fixedfixed
 Fixedsimple
 Fixedguided
 Simpleguided
Under each column is its elastic buckling load, denoted as ${P}_{\mathrm{cr}}$, where $E$ is the elastic modulus of the material, $I$ is the moment of inertia of the crosssection, and $L$ is the length. The simplesimple column is considered the most fundamental, probably because it has the least complicated and easiest to remember formula. The other column types are related to the simplesimple column through the concept of effective length, ${L}_{\mathrm{eff}}$. If you take the effective length of any of the other columns and plug it into
$$\frac{{\pi}^{2}EI}{{L}_{\mathrm{eff}}^{2}}$$you’ll get the buckling load for that type of column.
So where does 4.49 come into this? Well, in solving for the buckling load of the fixedsimple column, you run into the equation
$$\mathrm{tan}\lambda L=\lambda L$$where
$$\lambda =\sqrt{\frac{P}{EI}}$$The buckling load is the lowest nonzero value of $P$ that satisfies this equation.
$$\lambda L=\sqrt{\frac{{P}_{\mathrm{cr}}}{EI}}\phantom{\rule{thinmathspace}{0ex}}L=4.4934\dots $$ $$\frac{{P}_{\mathrm{cr}}{L}^{2}}{EI}={4.4934}^{2}$$ $${P}_{\mathrm{cr}}=\frac{20.19\phantom{\rule{thinmathspace}{0ex}}EI}{{L}^{2}}$$And if we put this in the form
$${P}_{\mathrm{cr}}=\frac{{\pi}^{2}EI}{{L}_{\mathrm{eff}}^{2}}$$we get ${L}_{\mathrm{eff}}=0.699\phantom{\rule{thinmathspace}{0ex}}L$, which we can round to ${L}_{\mathrm{eff}}=0.7\phantom{\rule{thinmathspace}{0ex}}L$ with little error.
Variations on the image above are found in many structural engineering books. For example, here’s the table of basic columns from Johnson, Lin, and Galambos’s Basic Steel Design, the textbook used in my first steel design class.
The authors have ordered the columns in this table according to their effective length. I put the columns in the order they’re typically taught.
I took my first steel design class my senior year, so that’s when I learned that the effective length of a fixedsimple column is $0.7\phantom{\rule{thinmathspace}{0ex}}L$. But I didn’t learn how to derive that solution until I was in grad school the next year. It’s pretty simple, which should give you a hint about the next blog post.