Chemical element abbreviation patterns

I’ve wondered occasionally about the patterns in how chemical elements are abbreviated. If you don’t know the abbreviation for an element, is there a simple algorithm that would let you narrow the range of possibilities or improve your odds at guessing?

Here’s a survey of how the elements are abbreviated.

Latin and German

The elements that have been known the longest often have abbreviations that are mnemonic in Latin.

  • Iron (Fe)
  • Sodium (Na)
  • Silver (Ag)
  • Tin (Sn)
  • Antimony (Sb)
  • Tungsten (W)
  • Gold (Au)
  • Mercury (Hg)
  • Lead (Pb)
  • Potassium (K)
  • Copper (Cu)

I included Tungsten in this section because it also has an abbreviation that is mnemonic in another language, in this case German.

Initial letter

The easiest abbreviations to remember are simply the first letters of the element names (in English).

  • Boron (B)
  • Carbon (C)
  • Fluorine (F)
  • Hydrogen (H)
  • Iodine (I)
  • Nitrogen (N)
  • Oxygen (O)
  • Phosphorus (P)
  • Sulfur (S)
  • Uranium (U)
  • Vanadium (V)
  • Yttrium (Y)

First two letters

The largest group of elements are those abbreviated by the first two letters of their name. When in doubt, guess the first two letters.

  • Actinium (Ac)
  • Aluminum (Al)
  • Americium (Am)
  • Argon (Ar)
  • Barium (Ba)
  • Beryllium (Be)
  • Bismuth (Bi)
  • Bromine (Br)
  • Calcium (Ca)
  • Cerium (Ce)
  • Chlorine (Cl)
  • Cobalt (Co)
  • Dysprosium (Dy)
  • Erbium (Er)
  • Europium (Eu)
  • Flerovium (Fl)
  • Francium (Fr)
  • Gallium (Ga)
  • Germanium (Ge)
  • Helium (He)
  • Holmium (Ho)
  • Indium (In)
  • Iridium (Ir)
  • Krypton (Kr)
  • Lanthanum (La)
  • Lithium (Li)
  • Lutetium (Lu)
  • Molybdenum (Mo)
  • Neon (Ne)
  • Nickel (Ni)
  • Nobelium (No)
  • Osmium (Os)
  • Polonium (Po)
  • Praseodymium (Pr)
  • Radium (Ra)
  • Rhodium (Rh)
  • Ruthenium (Ru)
  • Scandium (Sc)
  • Selenium (Se)
  • Silicon (Si)
  • Tantalum (Ta)
  • Tellurium (Te)
  • Thorium (Th)
  • Titanium (Ti)
  • Xenon (Xe)

Many of these elements use the first two letters to avoid a conflict with the first letter. For example, helium uses He because hydrogen already took H.

There are several elements that start with the same letter, and no element uses just the first letter. For example: actinium, aluminum, americium, and argon.

Xenon could have been X, or dysprosium could have been just D, but that’s not how it was done.

First letter and next consonant

The next largest group of elements are abbreviated by their first letter and the next consonant, skipping over a vowel.

  • Bohrium (Bh)
  • Cadmium (Cd)
  • Cesium (Cs)
  • Dubnium (Db)
  • Gadolinium (Gd)
  • Hafnium (Hf)
  • Hassium (Hs)
  • Livermorium (Lv)
  • Magnesium (Mg)
  • Manganese (Mn)
  • Meitnerium (Mt)
  • Neodymium (Nd)
  • Neptunium (Np)
  • Nihonium (Nh)
  • Niobium (Nb)
  • Oganesson (Og)
  • Promethium (Pm)
  • Rubidium (Rb)
  • Samarium (Sm)
  • Technetium (Tc)
  • Zinc (Zn)
  • Zirconium (Zr)

Many of these elements would cause a conflict if they had been abbreviated using one of the above rules. For example, cadmium could not be C because that’s carbon, and it could not be Ca because that’s calcium.

Initials of first two syllables

  • Astatine (At)
  • Berkelium (Bk)
  • Darmstadtium (Ds)
  • Einsteinium (Es)
  • Fermium (Fm)
  • Lawrencium (Lr)
  • Mendelevium (Md)
  • Moscovium (Mc)
  • Platinum (Pt)
  • Roentgenium (Rg)
  • Terbium (Tb)
  • Thallium (Tl)

Initials of first and third syllable

  • Californium (Cf)
  • Copernicium (Cn)
  • Palladium (Pd)
  • Rutherfordium (Rf)
  • Seaborgium (Sg)
  • Tennessine (Ts)
  • Ytterbium (Yb)

First and last letter

  • Curium (Cm)
  • Radon (Rn)
  • Thulium (Tm)

Miscellaneous

  • Arsenic (As)
  • Chromium (Cr)
  • Plutonium (Pu)
  • Protactinium (Pa)
  • Rhenium (Re)
  • Strontium (Sr)

Related posts

Mental hash function

A few years ago I wrote about Manual Blum’s proposed method for mentally computing a secure hash function. He proposed using this method as a password manager, using the hash of a web site’s name as the password for the site.

I first wrote about Blum’s method on the Heidelberg Laureate Forum blog, then wrote some footnotes to the post here.

NB: This method is insecure for reasons Rob Shearer describes in the comments.

Algorithm

Blum’s algorithm requires creating and memorizing two things: a random map from letters to digits, and a random permutation of digits.

Let f be a function that maps the set {A, B, C, …, Z} to the set {0, 1, 2, …, 9} created by a random number generator, and let g be a random permutation of {0, 1, 2, …, 9}.

Start with the text you want to hash. Then use f to convert the text to a sequence of digits, replacing each character c with f(c). Label this sequence of digits

a0 a1 a2an.

To create the first digit of your hash value, add the first and last digits of your sequence of digits, take the last digit of the sum, and apply the permutation g to it. In symbols, the first digit of the output, b0, is given by

b0 = g( (a0 + an) % 10 )

where a % 10 is the remainder when a is divided by 10.

For the rest of the digits, add the previous output to the current input, take the last digit, and apply the permutation. That is, for k > 0,

bk = g( (bk-1 + ak) % 10 ).

A few years ago Blum recommended using at least 12 characters.

Python code

Here’s some Python code to implement the method above and make all the details explicit.

    from numpy.random import default_rng
    
    rng = default_rng(20220516)
    
    fdata = rng.integers(10, size=26)
    def f(ch):
        ch = ch.lower()
        return fdata[ord(ch) - ord('a')]
    
    gdata = rng.permutation(10)
    def g(n):
        i = list(gdata).index(n)
        return gdata[(i+1) % 10]
    def hash(text):
        digits = [f(c) for c in text]
        N = len(text)
        out = [0] * N
        out[0] = g((digits[0] + digits[-1]) % 10)
        for i in range(1, N):
            out[i] = g((out[i-1] + digits[i]) % 10)
        return "".join(str(d) for d in out)
    
    print(hash("hello"))

This prints 26752.

Is mental cryptography hopeless?

It’s been eight years since I talked to Manuel Blum. Perhaps he realized years ago that this system is flawed. But I still find his initial question interesting: are there encryption algorithms that humans can execute mentally that cannot be easily broken by computers?

It would be interesting if such an algorithm could at least put up a good fight. Cryptographic algorithms are considered broken if they can be compromised given a few weeks of computing. Could a mental hashing algorithm at least withstand an hour of computer attack?

Sampling with replacement until you’ve seen everything

Suppose you have a standard deck of 52 cards. You pull out a card, put it back in the deck, shuffle, and pull out another card. How long would you expect to do this until you’ve seen every card?

Here’s a variation on the same problem. Suppose you’re a park ranger keeping data on tagged wolves in a national park. Each day you catch a wolf at random, collect some data, and release it. If there are 100 wolves in the park, how long until you’ve seen every wolf at least once?

We’ll solve this problem via simulation, then exactly.

Simulation

The Python code to solve the problem via simulation is straight forward. Here we’ll simulate our ranger catching and releasing one of 100 wolves. We’ll repeat our simulation five times to get an idea how much the results vary.

    import numpy as np
    from numpy.random import default_rng

    rng = default_rng()
    num_runs = 5
    N = 100 # number of unique items

    for run in range(num_runs):
        tally = np.zeros(N,dtype=int)
        trials = 0
        while min(tally) == 0:
            tally[rng.integers(N)] += 1
            trials += 1
        print(trials)

When I ran this, I got 846, 842, 676, 398, and 420.

Exact solution

Suppose we have a desk of N cards, and we sample the deck with replacement M times. We can select the first card N ways. Ditto for the second, third, and all the rest of the cards. so there are NM possible sequences of card draws.

How many of these sequences include each card at least once? To answer the question, we look at Richard Stanley’s twelvefold way. We’re looking for the number of ways to allocate M balls into N urns such that each urn contains at least one ball. The answer is

N! S(M, N)

where S(M, N) is the Stirling number of the second kind with parameters M and N [1].

So the probability of having seen each card at least once after selecting M cards randomly with replacement is

N! S(M, N) / NM.

Computing Stirling numbers

We’ve reduced our problem to the problem of computing Stirling numbers (of the second kind), so how do we do that?

We can compute Stirling numbers in terms of binomial coefficients as follows.

S(n,k) = \frac{1}{k!}\sum_{i = 0}^k (-1)^i {k \choose i} (k-i)^n

Now we have a practical problem if we want to use this formula for larger values of n and k. If we work with floating point numbers, we’re likely to run into overflow. This is the perennial with probability calculations. You may need to compute a moderate-sized number as the ratio of two enormous numbers. Even though the final result is between 0 and 1, the intermediate results may be too large to store in a floating point number. And even if we don’t overflow, we may lose precision because we’re working with an alternating sum.

The usual way to deal with overflow is to work on a log scale. But that won’t work for Stirling numbers because we’re adding terms together, not multiplying them.

One way to solve our problem—not the most efficient way but a way that will work—is to work with integers. This is easy in Python because integers by default can be arbitrarily large.

There are two ways to compute binomial coefficients in Python: scipy.special.binom and math.comb. The former uses floating point operations and the latter uses integers, so we need to use the latter.

We can compute the numerator of our probability with

    from math import comb
    def k_factorial_stirling(n, k):
        return sum((-1)**i * comb(k, i)*(k-i)**n for i in range(k+1))    

Then our probability is

    k_factorial_stirling(M, N) / N**M

If we compute the probability that our ranger has seen all 100 wolves after catching and releasing 500 times, we get 0.5116. So the median number of catch and release cycles is somewhere around 500, which is consistent with our simulation above.

Note that the numerator and denominator in our calculation are both on the order of 101000 while the largest floating point number is on the order of 10308, so we would have overflowed if we’d used binom instead of comb.

Related posts

[1] It’s unfortunate that these were called the “second kind” because they’re the kind that come up most often in application.

Image: “Fastening a Collar” by USFWS Mountain Prairie is licensed under CC BY 2.0 .

Tool recursion

“Literature about Lisp rarely resists that narcissistic pleasure of describing Lisp in Lisp.” — Christian Queinnec, Lisp in Small Pieces

 

Applying software development tools to themselves has a dark side and a light side.

There’s a danger of becoming obsessed with one’s tools and never getting around to using them. If it’s your job to cut down a tree, there’s some benefit to sharpening your ax, but you can’t only sharpen your ax. At some point you hit diminishing return and it’s time to start chopping.

But there are benefits to self-referential systems, such as macros that use Lisp to generate Lisp, or writing a C compiler in C, or using Emacs to tweak Emacs. There’s a kind of consistency that results, and there can be a compound return on effort. But as with writing a recursive procedure, there has to be a base case, a point at which you stop recursing. Otherwise you go down the black hole of becoming absorbed in your tool and never using it for work.

Even though I’ve used Emacs for a long time, I’ve never understood the recursive fascination some people have with it. For example, part of the elevator pitch for Emacs is that it’s self-documenting. You can pull up help on Emacs from inside Emacs. But you can also type your questions into a search engine without having to learn an arcane help API. What’s the advantage to the former?

For one thing, using Emacs help inside Emacs works without a network connection. For another, you avoid the risk of being distracted by something you see when you’re using your web browser. But the most subtle benefit is the compound effect of self-reference. You can use the same navigation commands in the help system that you can when editing text, you can execute code snippets in place, etc.

When I hear “Isn’t it cool that you can do X in X?” my first thought is “Yeah, that sounds cool” but my second thought is “But why would you want to do that? Sounds like it could be really hard.” I’m starting to appreciate that there are sometimes long-term benefits to these sort of recursive tool uses even if they’re not optimal in the short run.

New Twitter account: ElementFact

I started a new Twitter account this morning: @ElementFact. I’m thinking the account will post things like scientific facts about each element but also some history around how the element was discovered and named and other lore associated with the element.

@ElementFact icon

We’ll see how this goes. I’ve started many Twitter accounts over the years. Some have taken off and some have not.

Six months ago I started @TensorFact as an experiment to see what would happen with a narrowly focused account. It did moderately well, but I ran out of ideas for content. This will be the last week for that account.

You can see a list of my current Twitter accounts here.

Approximating a golden spiral with circular arcs

The previous post included this image of a logarithm spiral passing through the corners of squares in a sequence of golden rectangles.

The portion of the spiral in each square looks like a quarter of a circle. How well would circular arcs approximate the spiral?

Very well. Here’s a plot.

The circular arc inside the blue square is plotted in blue, the arc inside the green box in green, etc. The logarithmic spiral is plotted on top with a dashed black line. You have to zoom in closely to see any difference between the logarithmic spiral and its circular approximations.

For aesthetic applications, circular arcs are good enough and probably easier to work with. For a sort of three-dimensional analog of this approximation, see this post on the geometry of the Sydney Opera House.

Sometimes discontinuities in first or second derivatives are visually noticeable, but here they’re not. The approximation of the logarithmic spiral by a sequence of quarter circles has a jumps in curvature, which is roughly a second derivative. I suppose it’s more noticeable when curvature jumps from positive to zero or from positive to negative. Here it’s jumping from one positive value (the reciprocal of the circle radius) to another positive value (the reciprocal of a smaller radius).

Related posts

Logarithmic spiral

I’ve seen an image similar to the following many times, but I don’t recall any source going into detail regarding how the spiral is constructed. This post will do just that.

The previous post constructed iterated golden rectangles. We start with a golden rectangle and imagine chopping of first the blue, then the green, then the orange, and then the red square. We could continue this process on the inner most rectangle, over and over.

At this point, many sources would say “Hey look! We can draw a spiral that goes through two corners of each square” without explicitly stating an equation for the spiral. We’ll find spiral, making everything explicit.

In the previous post we showed how to find the limit of the iterative process at the intersection of the two diagonal lines below.

We showed that the intersection is at

x0 = (2φ + 1)/(φ + 2)

and

y0 = 1/(φ + 2).

Logarithmic spirals

A logarithmic spiral centered at the origin has the polar equation

r(θ) = a exp(kθ)

for some constants a and k. Our spiral will be such a spiral shifted to center at (x0y0).

Imagine a spiral going from the lower left to the top left of the blue square, then to the top left of the green square, then to the top right of the orange square etc., passing through two corners of every square. Every time θ goes through a quarter turn, i.e. π/2 radians, our rectangles get smaller by a factor of φ. We can use this to solve for k because

a exp(k(θ + π/2)) = φ a exp()

and so

exp(kπ/2) = φ

and

k = 2log(φ) / π.

To summarize what we know so far, if we shift our spiral to the origin, it has equation in polar form

r(θ) = a exp(kθ)

where we now know k but don’t yet know a.

Finding θ and a

To get our actual spiral, we have to shift the origin to (x0, y0) which we have calculated above. Converting from polar to rectangular coordinates so we can do the shift, we have

x(θ) = x0 + a exp(kθ) cos(θ)

y(θ) = y0 + a exp(kθ) sin(θ)

We can find the parameter a by knowing that our spiral passes through the origin, the bottom left corner in the plots above. At what value of θ does the curve go through the origin? We have a choice; values of θ that differ by multiples of 2π will give different values of a.

The angle θ is the angle made by the line connecting (0, 0) to (x0, y0). We can find θ via

θ0 = atan2(-y0, –x0).

Here’s Python code to find θ0:

    import numpy as np

    phi = (1 + 5**0.5)/2
    y0 = 1/(2+phi)
    x0 = (2*phi + 1)*y0
    theta0 = np.arctan2(-y0, -x0)

Then we solve for a from the equation x0) = 0.

    k = 2*np.log(phi)/np.pi
    a = -x0 / (np.exp(k*theta0)*np.cos(theta0)))

Plots

Now we have all the parameters we need to define our logarithmic spiral. The following code draws our logarithmic spiral on top of the plot of the rectangles.

    t = np.linspace(-20, theta0, 1000)
    def x(t): return x0 + a*np.exp(k*t)*np.cos(t)
    def y(t): return y0 + a*np.exp(k*t)*np.sin(t)
    plt.plot(x(t), y(t), "k-")

The result is the image at the top of the post.

Iterated golden rectangles in detail

I’ve seen the illustration of nesting golden rectangles many times, but I’ve never seen a presentation go into much detail. This post will go into more detail than usual, including Python code.

Start with a golden rectangle in landscape mode. We’ll plot our rectangle with the lower left corner at the origin and the upper right corner at (φ, 1) where φ is the golden ratio. No imaging cutting off the largest square you can on the left side, shown in blue.

Next, focus on the remaining rectangle and imagine cutting off the square on top, shown in green.

Now focus on the remaining rectangle and imagine cutting off the square on the right, shown in orange.

Finally, focus on the remaining rectangle and imagine cutting off the square on bottom, shown in red.

So we’ve cut off left, top, right, and bottom. We’re left with a rectangle with one side of each color above. We could repeat the process above on this rectangle, cutting off left, top, right, and bottom, and so on ad infinitum.

Where does this process end in the limit? Draw two diagonal lines as shown below.

Note that these diagonals cut the innermost rectangle in the same way as the outermost rectangle. So every time we repeat the four steps above, we will always have two diagonals that intersect in the same place. So the limit of the process converges on the point that is the intersection of the two diagonal lines.

The two diagonals lines have equations

y = -(1/φ)x + 1

and

y = φx – φ

and so we can calculate their intersection to be at

x0 = (2φ + 1)/(φ + 2)

and

y0 = 1/(φ + 2).

So the construction process, in the limit, converges to the point (x0, y0) where the diagonals cross.

Here’s Python code to product the final plot above.

    import numpy as np
    import matplotlib.pyplot as plt
    
    phi = (1 + 5**0.5)/2
    
    def plotrect(lowerleft, upperright, color):
        x0, y0 = lowerleft
        x1, y1 = upperright
        plt.plot([x0, x1], [y0, y0], c=color)
        plt.plot([x0, x1], [y1, y1], c=color)
        plt.plot([x0, x0], [y0, y1], c=color)
        plt.plot([x1, x1], [y0, y1], c=color)
    
    plt.gca().set_aspect("equal")   
 
    plotrect((0, 0), (phi, 1), "black")
    plotrect((0, 0), (1, 1), "blue")
    plotrect((1, 2-phi), (phi, 1), "green")
    plotrect((2*phi - 2,0), (phi, 2-phi), "orange")
    plotrect((1,0), (2*phi-2,2*phi-3), "red")
    plt.plot([0, phi], [1, 0], "--", color="gray")
    plt.plot([1, phi], [0, 1], "--", color="gray")
    plt.savefig("golden_rect5.png")

I intend to find the equation of the spiral that touches two corners of each square in the next post.

Mentally calculating the day of the week

In my previous post I mentioned John Conway’s Doomsday rule for calculating the day of the week for any date. This method starts off very simple, but gets more complicated when you actually use it.

This post will present an alternative method that’s easier to use in practice and can be described more succinctly.

Here’s the algorithm.

  1. Take the last two digits of the year and add the number of times 4 divides that number.
  2. Add a constant corresponding to the month.
  3. Add the day of the month.
  4. Subtract 1 for January or February of a leap year for .
  5. Take the remainder by 7.

The result is a number that tell you the day of the week.

To be even more succinct, let y be the number formed by the last two digits of the date. Let d be the day of the month. Let L equal 1 if the year is a leap year and the date is in January or February and 0 otherwise. Then the algorithm above can be written as

(y + ⌊y/4⌋ + dL + month constant) % 7.

Here ⌊x⌋ is the floor of x, the greatest integer no greater than x, and x % 7 is the remainder when x is divided by 7.

I’ve deliberately left out a couple details above. What are these month constants, and how does the number at the end give you a day of the week?

Customizing for the 21st century

I learned the method above in the 20th century, and the rule was optimized for the 20th century. You had to subtract 1 for dates in the 21st century.

Also, when I learned the method, it numbered the days of the week with Sunday = 1, Monday = 2, etc. Now I would find it easier to start with Sunday = 0.

Here’s an updated table of month constants that eliminates the need to adjust for dates in the 20th century, and numbers the days of the week from 0.

    | January | 6 | February | 2 | March     | 2 |
    | April   | 5 | May      | 0 | June      | 3 |
    | July    | 5 | August   | 1 | September | 4 |
    | October | 6 | November | 2 | December  | 4 |

If you’d like to number Sunday as 1 rather than 0, add 1 to all the numbers above.

The article I learned this method from came with suggested mnemonics for remembering the month constants. But when you change the constants like I’ve done here, you have to come up with new mnemonics.

Examples

I’m writing this post on Saturday, May 7, 2022. Let’s verify that the method gives the correct day of the week today.

Start with 22, and add 5 because ⌊22/4⌋ = 5. The number for May is 0, so there’s nothing to add for the month. We add 7 because today’s the 7th. This gives us

22 + 5 + 7 = 34

which gives a remainder of 6 mod 7, so this is day 6. Since we started with 0 for Sunday, 6 is Saturday.

Next, let’s do January 15, 2036. We get

36 + 9 + 6 + 15 – 1 = 65

which is 2 mod 7. so January 15 will fall on a Tuesday in 2036. Note that we subtracted 1 because 2036 will be a leap year and our date is in January.

If we want to look at Christmas 2036, we have

36 + 9 + 4 + 25 = 74

which is 4 mod 7, so December 25 will fall on a Thursday in 2036. We didn’t subtract 1 because although 2036 is a leap year, we’re looking at a date after February.

Other centuries

For dates in the 20th century, add 1.

For dates in the 22nd century, subtract 1.

If by some reason you’re reading this article in the 22nd century, make your own table of month constants by subtracting 1 from the numbers in the table above.

More details

When I was at University of Texas, humanities majors had to take a class we called “math for poets.” The class was a hodgepodge of various topics, and the most popular topic when I taught the class was this method. Here’s a handout I gave the class.

That handout is a little slower paced than this blog post, and goes into some explanation for why the method works. (The method was meant to motivate modular arithmetic, one of the topics on the syllabus, so explaining why the method works was secretly the whole point of teaching it.)

The handout is still valid. You can follow it verbatim, or you can replace the table of month constants with the one above and ignore the 21st century correction step.

Related posts

John Conway and mental exercise rituals

Drawing of John Conway with horned sphere

John Horton Conway (1937–2020) came up with an algorithm in 1973 for mentally calculating what day of the week a date falls on. His method, which he called the “Doomsday rule” starts from the observation that every year, the dates 4/4. 6/6, 8/8, 10/10, 12/12, 5/9, 9/5, 7/11, and 11/7 fall on the same day of the week [1], what Conway called the “doomsday” of that year. That’s Monday this year.

Once you know the doomsday for a year you can bootstrap your way to finding the day of the week for any date that year. Finding the doomsday is a little complicated.

Conway had his computer set up so that it would quiz him with random dates every time he logged in.

Mental exercises

Recently I’ve been thinking about mental exercise rituals, similar to Conway having his computer quiz him on dates. Some people play video games or solve Rubik’s cubes or recite poetry.

Curiously, what some people do for a mental warm-up others do for a mental cool-down, such as mentally reviewing something they’ve memorized as a way to fall asleep.

What are some mental exercise rituals that you’ve done or heard of other people doing? Please leave examples in the comments.

More on Conway

The drawing at the top of the page is a sketch of Conway by Simon Frazer. The strange thing coming out of Conway’s head in the sketch is Alexander’s horned sphere, a famous example from topology. Despite appearances, the boundary of Alexander’s horned sphere is topologically equivalent to a sphere.

Conway was a free-range mathematician, working in a wide variety of areas, ranging from the classification of finite simple groups to his popular Game of Life. Of the 26 sporadic groups, three are named after Conway.

Here are some more posts where I’ve written about John Conway or cited something he wrote.

[1] Because this list of dates is symmetric in month and day, the rule works on both sides of the Atlantic.