## Tuesday, August 15, 2017

### Projectile Doodle

I hope you like this doodle! It is a sad face that becomes happy.

The motion in the image is projectile motion. There are 500 small particles, each following its own trajectory under the influence of gravity—as if you threw a great handful of pebbles in the air. I chose the particles' initial positions, initial speeds, and initial launch angles so that they would form a happy face at the beginning and a happy face at the end.

Here is a version without color, so you can see the physics a little better.

1) Import a raster image of a happy face and a raster image of a sad face.

2) Simplify the image so that every pixel is either black or white.

3) Select a random sample of 500 black pixels from the happy face and 500 black pixels from the sad face.

4) Use a linear mapping to convert pixel row/column locations into spatial xy-locations. This gives 500 initial pebble locations and 500 final pebble locations. I randomly mapped initial locations to final locations.

5) For each initial/final location pair $(x_0, y_0)$ and $(x_1, y_1)$, there is one projectile-motion trajectory that occupies point $(x_0, y_0)$ at time $t = 0$ and occupies point $(x_1, y_1)$ at time $t = T$. This trajectory has equations of motion

$x = v_0\cos\theta\, t$

$y = v_0\sin\theta\, t - \frac{1}{2}g t^2$

where

$x = x_1 - x_0$

$y = y_1 - y_0$,

$\theta = \cos^{-1}\left(1+\left(\frac{y+\frac{1}{2}gT^2}{x}\right)^2\right)^{-\frac{1}{2}}$

and

$v_0 = \frac{x}{T}\left(1+\left(\frac{y+\frac{1}{2}gT^2}{x}\right)^2\right)^{\frac{1}{2}}$

Now all you have to do is animate the 500 pebbles as they follow the specified trajectories from their initial locations to their final locations. The reason the happy face assembles itself is that the value of $T$ is the same for all of the pebbles. In the animation, the time starts a little before zero and ends a little after $T$.

My family and I are headed West to see the eclipse. If you're near the path of totality, here's hoping you have clear weather!

## Monday, August 14, 2017

### Catching Up With HD 101584

Occasionally I like to see what's going on with HD 101584, a supergiant star several thousand light-years away. He's visible from Earth perhaps, on the darkest of nights, although I haven't looked for him. I know that he shines through an exhaled cloud, and that he wobbles in time to the movements of an invisible companion. We met a long time ago—he's like a friend who lives across the country, one I never visit yet think of with pleasure.

I was introduced to HD 101584 one winter almost thirty years ago, when I spent a month in Ohio apprenticing to Nancy D. Morrison, an astronomer at the University of Toledo. It wasn't known then that the star was part of a binary system, and in fact it counted as scientific progress when Dr. Morrison and I determined that the shell of gas around the star was expanding at a speed of approximately 48 kilometers per second. Our calculation was based on spectroscopic data that Dr. Morrison had collected in Cerro Tololo, Chile, the site of a large international observatory. Chile has many good places to build a telescope—elevated regions with clear nights and good seeing conditions. Some weather stations in the Atacama Desert, north of Cerro Tololo, have yet to record a single rainfall in their entire time of operation.

The University of Toledo campus is located in an attractive part of Toledo, far from the dystopic Straßenbauprojekte-Welt that drivers experience while skirting the city on I-280. I arrived for work in January of 1989 and was surprised to remember that I'd visited the campus once before. In my junior or senior year of high school, the university had brought me down from Michigan as part of a program to recruit talented science students. The professors and the facilities had looked solid, and there would clearly be generous financial aid, but I didn't end up applying to the school, and it seems I forgot the entire episode until I set foot there again.

Dr. Morrison spent a lot of time in the beginning showing me how to use the software we'd be using, and she taught me the stellar physics I would need to understand in order to work on the project. I found her to be a kind, supportive, and somewhat formal person who treated scholarship and scientific accuracy with the gravity they deserve. Her example influenced my developing scientific and scholarly attitudes. Neither of us drew out the other very much, although I felt I could glimpse a little of Nancy the person in the car she drove (a vintage Volvo station wagon) and in the adventurous tastes in food that she revealed when we ate together. She was, I believe, the first woman ever to receive a Ph.D. from the eminent astronomy department of the University of Hawaii. Today Dr. Morrison holds many titles, including former Director of the Ritter Observatory, Fellow of the American Association for the Advancement of Science, and member of the Executive Committee of the American Astronomical Society.

If you read far enough down the list of refereed publications in Dr. Morrison's curriculum vitae, you'll eventually come to "Unexpected Effects of a Trap in CCD Echelle Spectra of B-Type Stars," which appeared in Publications of the Astronomical Society of the Pacific in 1990. I helped with the research for that article during a return visit to Toledo over the summer that followed the original HD 101584 project. That summer, my commute from Michigan to Toledo was 62 miles each way; to make it possible, my dad gave me the use of his 1974 Corolla Deluxe station wagon, a workhorse with a quarter-million miles on the odometer. The wagon format made the car an excellent mobile locker-room. In those days I could play basketball, especially street ball, and if ever I drove past a playground and saw a good pickup-game happening, I'd pull over, change clothes in the car, and get on a team. In Toledo the car sat in a sunny parking lot all day, and its plasticky heat felt good to me after eight hours of reducing data in an air-conditioned room—we used mainframes back then!

In the years that followed my visits to Toledo, physics and mathematics rather than astronomy increasingly consumed my energy, and Nancy and I fell out of touch. She probably doesn't know how often I think about her and that time of my life. I'll let her know.

The basic data for HD 101584 can be seen here or in this database; some recent findings about the object are here: 1, 2.

## Sunday, August 13, 2017

### To My Republican Friends

I never expected you to vote for Hillary Clinton, and I appreciated when you didn't vote for Donald Trump either. I don't expect you to agree with me about taxes, health care, the Supreme Court, or foreign policy. After all, someday I could change my own mind about those things—I don't need my friends to reflect my own views back at me, and I learn from discussion and debate.

And I know that the political news offers you plenty of fat targets to criticize, like identity politics and political correctness. I don't think you're wrong to criticize those things.

But as your friend, I want you to know that I'm starting to blame you for Donald Trump.

I'd been feeling this way more and more, but the tragic weekend in Charlottesville has called the question.

I hope not, because there are things that only a Republican can do.

First, a small thing: build a movement among conservative legislators to require President Trump to release his tax returns. I'm not a conspiracy theorist and don't have particular ideas about what might be found in the returns, but Trump's refusal to release them was a thumb in the eye of our politics. It was a signal that Trump wasn't going to submit to oversight of any kind. Your party let him get away with it. Correct your mistake now.

Second, start laying groundwork for a presidential primary challenge in 2020. Encourage a great Republican candidate to run; donate early; join the team as an advisor. (Let me know who you're backing, and I'll donate too.) A primary challenger would likely lose, but a primary challenger would also give a voice to true Republicanism while Trump is destroying it. Yes, a primary increases the chances that a Democrat will win the general election; but it's a mistake to see a second Trump administration as a victory for Republicans. It's the opposite—a point of no return for the party.

Maybe there are other things you can do—maybe there are things you're already doing to put your house in order. I hope so, because the time of choosing is here. You can't sit this one out.

## Saturday, August 12, 2017

### In Case These Things Need To Be Said, And In Case All Of Us Need To Speak Up Today.

Nobody who venerates a Confederate flag is an American patriot. The Confederates of the 1860s were traitors against the United States of America. A patriot doesn't wave the flag of an enemy nation.

Making war in defense of slavery was a sin in the eyes of a just God. That sin still haunts the South.

All men are created equal. The descendants of the enslaved are Americans in the fullest sense. Statues to Confederate generals are an affront to the descendants of the enslaved. Tear all the statues down—or leave them be as a reminder; but if a town government has made a decision that the statues will go, then have the decency to stay home and reflect, rather than marching to defend the indefensible.

Neo-Nazis who stage a rally should be protested—vigorously, and non-violently. Punching a neo-Nazi is neither morally defensible nor politically wise. "All men are created equal" also applies to neo-Nazis. Mock them, outflank them, neutralize them, defeat them in this decade and the next. Fantasies about eradicating them forever are just that, fantasies—and disturbing ones at that.

Above all: vote.

## Thursday, August 10, 2017

### 3 Times 3 = 9 Word Game

In each puzzle below, nine letters are provided. Use the nine letters to form three words of exactly three letters each. (Use all nine letters, and don't use any of the nine letters more than once.)

1.     H P D L M Y J A I

2.     U O Z M P E J G I

3.     N F I W X Y U H M

4.     I Y O J T V X P U

5.     A U N V K H T M E

6.     B K P O T J C I U

Extra challenge: in each puzzle below, use the twelve letters provided to form four words of exactly three letters each. (Use all twelve letters, and don't use any of the twelve letters more than once.)

7.     Y S I A M N F D G O J L

8.     K W Z I Y O E B M F C N

## Sunday, August 6, 2017

### Writing Word Problems

On Reddit there was an AMA request asking to hear from people who write word problems. I'm not on Reddit and couldn't participate in the discussion, but a friend forwarded me the link, so I thought I'd take up the questions here.

Although the AMA was about word problems, there is at least as much to say about writing "bare calculation" practice problems—see for example the carefully designed worksheet in this article—and about writing good conceptual questions, such as Phil Daro's eye-opening grade 3 problem of using a number line to show why 4/5 is closer to 1 than 5/4. Maybe procedural problems and conceptual problems could be topics for later posts. For now, let's talk word problems! The person making the AMA request asked some good questions.

1. How did you get into the profession?

I guess I've been doing this for a long time. As part of tutoring you have to make up problems, and I started tutoring my friends when I was in grade school. My first job writing problems per se was when I was a physics Ph.D. student, and I was tasked with designing a curriculum for introductory physics; this was part of an effort by UC Berkeley to expand on the success of Uri Treisman's groundbreaking work in Calculus. I believed then, and believe still, that problem quality is essential to the success of a curriculum. In 1992 Treisman wrote of his original project,
Most visitors to the program thought that the heart of our project was group learning. They were impressed by the enthusiasm of the students and the intensity of their interactions as they collectively attacked challenging problems. But the real core was the problem sets which drove the group interaction. One of the greatest challenges that we faced and still face today was figuring out suitable mathematical tasks for the students that not only would help them to crystallize their emerging understanding of the calculus, but that would also show them the beauty of the subject.

After graduate school I became a professor, and when you're a professor you have to make up tons of problems for your students. I collected my best problems about force and motion and included them in my physics textbook. Some of the puzzles I post on this blog could potentially be word problems in school (this one, say); others, not so much. Some of my Saturday School posts have word problems in them too.

Sometimes my job involves writing math word problems at the K–12 level. Often the point of these problems isn't necessarily to be copied down and given to students, but rather to be discussed by educators; I want to stimulate conversation about the nature of the curriculum itself. One valuable resource for that conversation has been www.illustrativemathematics.org. Another has been the material on www.achievethecore.org, and yet another has been Table 2 in this document, which describes the fifteen different kinds of basic addition and subtraction word problems. (Fifteen!)

At higher grade levels, here is a word problem that I recently included in a presentation:

In algebra, you often have to rewrite expressions in different forms. The point of this problem is to suggest that algebra teachers might try to include some problems in which rewriting a given expression has a rationale, however slight, within the context of the problem. My CPU problem isn't the best possible example…what I'm trying to do is encourage the field at large to work on creating more and better problems that serve the purpose. The inspiration for the CPU problem was a time last year when I was trying to speed up a loop in one of my own programs, and factoring an expression did the trick. (Math: it works!)

Writing word problems is rewarding, but I also like to find great word problems from the past and keep them alive. See my previous posts about Newton's problem of the oxen and Wells's Academic Algebra textbook from the 19th Century.

Here is a fascinating problem that was a favorite of Leo Tolstoy's:
A team of haymakers was assigned the task of scything two meadows, one twice the size of the other. The team worked half a day on the larger meadow. Then it split into two equal groups. The first group remained in the larger meadow and finished it by evening. The second group scythed the smaller meadow, but by evening there still remained a portion to do. This portion was scythed the next day by one haymaker in a single day’s work. How many haymakers were there in the team?
The Tolstoy problem isn't easy. Yet elegant shouldn't have to mean difficult. Sometimes, a simple word problem can be almost poetic in its spareness.

Here is an elegant short problem in mathematician Roger Howe's essay "From Arithmetic to Algebra":

A last brief example is this penetrating and original problem about algebraic structure, from Illustrative Mathematics:

It might be the case that in recent decades, the best minds in math education have spent too much time injecting lengthy problems into the grades K–8 curriculum, and not enough time transforming and elevating the teaching and learning of simple problems.

I wouldn't hazard quite the same generalization about high school, because the high school curriculum probably needs more high-quality application problems, which tend to be lengthy. Here is a high school application problem I wrote once:

The next was adapted from a problem developed by COMAP.

(This problem should really be formulated using a google doc or Excel spreadsheet, not a printed page. I think spreadsheets are used too seldom in high school.)

2. It's assumed that you write questions below your skill level. Do you write questions at your skill level?

Not so much anymore, but "writing questions at your skill level" is a pretty good thumbnail description of doing research—so when I was a researcher, I did this all the time. See any of my peer-reviewed publications for examples.

The saga of the points in a circle problem on this blog was another example of a problem I made up that was at my own skill level; solving it took me a considerable amount of effort, and I had to create arguments of a kind I'd never made or seen before. It might not be a research-level problem, but I think it did attract some interest from a few mathematicians out there.

Sometimes I'll write a problem that isn't research-level, yet still is "at my level" in a sense, because it solves a problem that I legitimately wanted to solve. Here was one such problem; I wrote it after stepping in a pothole full of slush.

3. Have you ever written a question that you thought would be simpler than it was?

In physics, you often try to give your students a nicely bounded task, but then you realize that you made some inappropriate assumptions, and the problem can't be made as simple as you were trying to make it. I think it happened more than once that I jotted down a problem on my way to class and then was unable to solve it in front of my students! Whoops. Bad lesson planning.

Sometimes a word problem is just what you meant it to be, but then the students have a hard time with it, and it surprises you. Moments like that are valuable opportunities for me to adjust my own understanding of my students' brain-state. These moments also expose weaknesses of my curriculum up to that point, which I can try to correct the next time around. I wrote about an experience like that, describing a time when I gave one of my kids a word problem she hadn't been well prepared for. You can't smooth every transition in learning, but most transitions could be smoother than they are today.

4. How do you decide whether to write about trains, apples and oranges, candy bars, etc.?

In the best word problems, the math is just right and the context fits beautifully. Writing those problems is harder than it looks. A while ago I wrote this task to illustrate a geometry standard, and it's OK—it stars a ladybug—but a colleague later told me that her word problem about that standard had starred pirates and treasure. That's way better! Not because treasure is more exciting, but because the mathematical issue at hand was about pinning down a location, which is an important goal for treasure-hunters not ladybugs. The situation matches the math.

If I'm writing a word problem about, say, speed, then sometimes I'll have the numbers in hand and go looking for a context to put them in. So for example if it's a speed of around 8 mph, then I'll spend some time thinking about what sorts of things actually move at around 8 miles per hour. I think about what sorts of things from everyday life plausibly move at a pretty constant speed for an extended period of time. Working that way takes a lot of effort, but it tends to yield better problems.

Editorially, there tend to be a lot of constraints on the contexts you can use. Often there are rules like "No candy bars"—I guess parents don't like junk food in the curriculum. Also, no military applications. Sometimes these rules seem a little silly to me, and I wonder if they contribute to students' feeling that math is useless. But the rules are usually there for a reason.

5. What's the process for writing a really good problem?

Sometimes I think we should all spend less time writing problems, and more time curating excellent problems from every century and nation. In any case, I doubt there's a reliable process, or else there would be more good problems out there. Different people also have different views about what a good problem is—sometimes incompatible views. I'm eclectic and appreciate a well made problem in any genre, just as I like many genres of art.

In one mode of writing problems, you know what math you're trying to get at, and you choose a context to match. In another mode, you start with an interesting scenario, and then the math in the problem is whatever it needs to be to shed light on the scenario. Any mode has its pitfalls. When you're hunting for a context to match some specified piece of mathematics, it's possible to end up with junk like "At the store, Mary bought 78,123 cantaloupes and 831 fewer raisins…." On the other hand, when you're starting with the context, it's possible to overshoot the expertise of the audience ("How can this airline schedule its flights so that…"), or else fail to do justice to the context ("Treating the horse as a perfect sphere…").

Matching math to context sometimes sends me to the Internet to do research on different topics. What is a realistic weight for a songbird? Could there be a county in the U.S. that's roughly triangular? In order to create the problem about oil spills shown above, I studied the body of law that establishes penalties for chemical spills in the Columbia River Estuary (see WAC 173-183-840, Calculation of damages for spills into the Columbia River estuary). Once, I called a company historian at a vehicle manufacturer to make sure that a vehicle I was writing about could go as fast as I was saying it could go. This marvelous ratio/proportional relationship problem by Richard Stanley probably has some research behind it:
Tree-measuring tape. There is a special tape measure used in measuring trees; when wrapped around a tree, it gives as its reading the diameter of the tree. Describe how the special tape measure differs from a standard tape measure. Make a diagram to scale showing the marks on the first part of the special tape measure.

The first draft of a word problem is usually too long. The language needs to be condensed. It's possible to pare down the language too much, sacrificing authenticity, but usually the reverse happens, with unnecessary language demands getting between the student and the math. This is especially important because many students in the U.S. are learning English while they're learning math. The first version of the chemical spill problem had many more words than the version shown here; experts in bilingual math education helped me reduce the language a great deal.

When I'm writing a word problem, my brain is totally engaged in the math, so in that moment I can't afford to worry about whether the person shopping for cantaloupes is going to be named Jason or something else. So, when I write a problem, I just write A, B, and C for the names. As soon as the problem is finished, I open up a spreadsheet that I downloaded a couple years ago from the New York City Department of Health, which lists the most popular baby names given out in New York. In my copy of the spreadsheet, I've added a random generator that selects one of the names every time I open the file. Whatever name comes up, I use that name. Over time, the Law of Large Numbers pretty much guarantees that my word problems will avoid bias in the names of the characters. Just now, I opened the spreadsheet and it gave me "Mya." I never would have thought of that name myself.

Part of the process of developing a problem should be testing it with students, then revising it. Some of the problems I see in textbooks don't look to me as though they had been honed to perfection over time. More generally, I fear that something in the economics of the market fails to reward excellence in math problems. What too few can see, too few will pay for. There is also a tradition in math education of using problems without attribution. The rules of scholarship don't seem apply to math problems, and the status of copyright law is unclear. I should say that the problem Tolstoy loved, the problem about the haymakers, was written by a student named Petrov. He died young, of tuberculosis.

## Saturday, August 5, 2017

### Sending A Signal Faster Than Light - Solution

My patent on a yarn-and-laser system for faster-than-light signalling isn't going to get approved, because it has a fatal flaw. The thing that burns the yarn is photons, and they stream out of the laser at precisely the speed of light. So you won't be able to burn yarn arbitrarily far away in an arbitrarily short time.

Each photon emerging from the laser follows a straight-line path, maintaining the direction in which it was first launched. It isn't as if the beam keeps the photons rotating…so the analogy to the rotating line fails altogether. The laser situation is more like this:

It's a "pew-pew" thing, like the old Asteroids video game.

I derived a relationship between the horizontal progress a of the signal, and the time t since the laser began rotating:

$t = \sqrt{\tau_1^2 + \frac{a^2}{c^2}} + \tau_2 \tan^{-1}\frac{a}{L}$

Here L is the vertical distance from the laser to the horizontal line, c is the speed of light, and τ1, 2 are the two timescales in the problem, τ1L/c  and τ2 = 1/ω, where ω is the angular rotation rate of the laser. The expression has the limiting behavior one expects—specifically, when a >> L, we have

ac(tπ/).

This is what it ought to look like, since the photons striking the yarn very far away are those that have traveled approximately distance a after leaving the laser at approximately the end of its rotation period.

Once when I was in college—I think I was a freshman—I asked my physics professor, William Wootters, a question about faster-than-light signaling. I said, "If you and I hold onto either end of a broomstick, and I jerk my end of the broomstick, then haven't I signaled to you just as fast as we please?" At that time, I didn't have the understanding of solid objects that I would eventually gain during the physics major—that a broomstick isn't an undifferentiated chunk of stuff, but is well thought of for these purposes as an atomic slinky made of balls and springs. If you push one end of the broomstick, you set up a compression wave in the slinky (a sound wave), which travels through the broomstick with a speed determined by its material properties. Key to those material properties are the electromagnetic forces that play the role of the "springs" in the slinky analogy. And so there's no obvious mechanism to achieve faster-than-light signaling with a broomstick because disturbances in electromagnetic fields propagate with—you guessed it—the speed of light.

I believe Bill answered my broomstick question by saying that relativity would seem to rule out the existence of a perfectly rigid body. That makes sense, otherwise the rotating line analogy could be made real by swinging a broomstick. Given things as they are, if you try to swing a rod so fast that its tip moves faster than light, you will find yourself limited by the finite propagation speed within the material. Parts of the rod near the distant end will take some time to "find out" that they ought to be moving, because of the finite speed of the "signal" that your wrists are transmitting. In simple terms, the rod will bend. Or break. And if you could somehow make the rod more and more rigid by improving its material properties, then at some point maybe you will have created such a stress-energy field that the rod would turn into a singularity.

Well maybe that's not right, and anyway I certainly haven't proved that faster-than-light signalling is impossible. Nor have I studied professionally the arguments of those who believe they have done that. Probably everything is settled and airtight…however, like John Bell, whose work I once read carefully, I tend in general to "suspect that what is proved by impossibility proofs is lack of imagination."

## Wednesday, August 2, 2017

### Sending A Signal Faster Than Light

A bit of a brain-teaser for physics-major types, and anyone else who's interested in Einstein-type thought experiments.

When a line rotates, its point of intersection with with another line can move with great speed—in fact, unbounded speed.

What if we replace the rotating line with a real laser beam, and we replace the stationary line with something like a long, straight piece of flammable string—could we then transmit a faster-than-light signal by burning the string?

## Sunday, July 23, 2017

### Gary Cipolloni's Clock Puzzle

Gary Cipolloni, my computing teacher in eleventh or twelfth grade, was charismatic, and subtly counter-cultural. Equally comfortable in leather motorcycle gear or the polyester professional-wear of the time, Mr. C. would flit around the lab telling jokes and shelling pistachios, the snack he never stopped eating. The story people told was that in his student days, he'd broken new administrative ground at the University of Michigan's Dearborn campus by using FORTRAN to fulfill the foreign language requirement. (I doubt it.) I learned a great deal from him.

Mr. C. assigned us projects, but often he merely suggested them. One idea he floated was that the class might determine which of the little LED bars in a digital clock stayed lit the longest during a twelve-hour period. I don't think any of us ever found the answer.

I did try the clock LED problem, not in the PASCAL language we were studying in class, but using a BASIC program on my Commodore 128 at home. The 128 was a fantastic machine for its time, and it was a major upgrade from my old Commodore 64—itself practically a Cray compared to the machine I had started on, which was the revolutionary VIC-20.

BEHOLD! The VIC-20. Image from the VIC-20 article on Wikipedia.

God, the hours I spent on that VIC-20! The machine had 3k of RAM. Until we added a tape drive the following year, whatever program I was writing would be permanently erased as soon as the computer was turned off. So I used to write down my programs in a notebook, and that way if I wanted to run an old program again, I just typed it line by line from the notebook. A couple of years later, I upgraded to the Commodore 64. Then came the Commodore 128, with a much more powerful BASIC language.

I don't remember the answer my program gave to the clock LED problem, but whatever it was, it was probably wrong. Not that the problem is especially hard, just that I remember that I wrote an overly complicated program to solve it and likely ended up with garbage as output.

Over the years I've often thought about Mr. C. and his clock puzzle. Finally this weekend I wrote a little program in Mathematica to solve the problem. The results are below, but first here is how to solve the problem without using a computer.

***

The clock design I worked with looks like this (these are home-made images):

Here are all the digits:

The clock display is of the form AB:CD:EF, where A stands for the hours tens-digit, B the hours ones-digit, C the minute tens-digit, D the minute ones-digit, E the seconds tens-digit, and F the seconds ones-digit. In each digit's place, there are seven LED bars, each turned on or off to form a specific digit. I number the seven LED positions from top to bottom, left to right, as follows:

So, some good quantities to calculate would be A1, …, A7, B1, …, B7, …, F7—where C4, for example, is the total number of seconds when the middle LED in the minutes tens-digit will be lit during the period from 12:00:00 to 11:59:59.

Here are a few examples of calculating these quantities:

• C4. During the entire twelve-hour period, the minutes tens-digit will cycle a whole number of times through the values 0, 1, 2, 3, 4, 5, so that each digit gets an equal share of the time. Now when 0 and 1 are showing, the middle LED is dark; when 2, 3, 4, and 5 are showing, the middle LED is lit. So the middle LED is lit 4/6 = 2/3 of the time. We can write C4 = 2/3T, where T is twelve hours.

• C5. When 1, 3, 4, and 5 are showing, the lower-left LED is dark; when 0 and 2 are showing, the lower-left LED is lit. So the lower-left LED is lit 2/6 = 1/3 of the time. Thus C5 = 1/3T.

• B7. During the twelve-hour period, the hours ones-digit will progress through the values 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1. When 1, 4, 7 and 9 are showing, the bottom LED is dark; when 0, 2, 3, 5, 6, and 8 are showing, the bottom LED is lit. So the bottom LED is lit 7/12 of the time. Thus B7 = 7/12T.

• A3. During the twelve-hour period, the hours tens-digit will show a 1 for three hours and will be blank for nine hours. When the digit is blank, the upper-right LED is dark; when 1 is showing, the upper-right LED is lit. So the upper-right LED is lit 3/12 = 1/4 of the time. Thus A3 = 1/4T.

A shortcut: once you calculate the Ei and Fi values, you've also calculated the Ci and Di values. The same events happen in the seconds display and the minutes display, and each event in the seconds display happens sixty times as often as its corresponding event in the minutes display, but it only lasts for a sixtieth of the time. So the aggregate time for a given event is the same in the seconds display as in the minutes display.

The largest fraction turns out to be 9/10, for D6 and F6. The final answer is therefore a tie between the lower-right LED in the seconds ones-digit and the lower-right LED in the minutes ones-digit, both of which are lit 90% of the time. The next-closest fraction is 5/6, which occurs for six different LEDs.

***

Here is the computer output, shown several ways.

The fractions:

A: 0, 0, 1/4, 0, 0, 1/4, 0
B: 2/3, 1/2, 5/6, 2/3, 5/12, 5/6, 7/12
C: 2/3, 1/2, 5/6, 2/3, 1/3, 5/6, 2/3
D: 7/10, 3/5, 4/5, 7/10, 2/5, 9/10, 3/5
E: 2/3, 1/2, 5/6, 2/3, 1/3, 5/6, 2/3
F: 7/10, 3/5, 4/5, 7/10, 2/5, 9/10, 3/5

A heat map. Pure blue corresponds to never being lit, and pure red corresponds to always being lit:

A 3-D plot, where the height of each prism corresponds to the total time the LED is lit:

Coding has changed a lot since my high school days. The old acronyms are no more, and the tools are vastly more powerful; but many of the principles I learned as a kid are still relevant. Thanks Mr. C. for all you taught me.

## Friday, July 21, 2017

### A Syllable Word Game

I made up a word game just to illustrate how my syllable-counting algorithm gets used.

In each puzzle below, strike a letter to create a new word. Repeat for the indicated number of times. Constraint: every time you strike a letter, the new word has to have the same number of syllables as the old word.

Example:

DULLY → DULY is allowed, but DULLY → DULL is not.

1. CLOVEN  →  ________  →  ________

2. ATRIAL  →  ________  →  ________

3. WAIVERS  →  ________  →  ________  →  ________

I found the three words cloven, atrial, and waivers by writing a computer program that used the syllable-counting function to help identify potentially interesting cases.

By the way, here is a simpler syllabification algorithm that I saw online.
• Count the number of vowels in the word.
• Do not count double-vowels ("rain" has 2 vowels but is only 1 syllable)
• If last letter in word is vowel do not count ("side" is 1 syllable)
These instructions aren't 100% clear, but I implemented a version of this and compared it to the algorithm I've been using. It's not as good. Words in red are the 3 cases where my algorithm fails and the new one succeeds. Words in green are the 21 cases where my algorithm succeeds and the new one fails; 7 of these have an asterisk that is explained below. Words in blue are the 4 cases where both algorithms fail.

PYRAMIDALLY 5 4*
MISERICORDS 4 4
THYROXINS 3 3
PLICATION 3 3
PERTINACIOUS 5 4
LEAL 1 1
LYCOPOD 3 3
FRIPPERIES 3 3
INTERDEPENDENCY 6 5*
RITORNELLOS 4 4
PRESSORS 2 2
TINNY 2 1*
POOFTER 2 2
PETTLED 2 2
BACKPEDALLING 4 4
CHERRYLIKE 3 3
INTERCONVERT 4 4
VILLEIN 2 2
STALEST 2 2
PREVISION 3 3
TERRITORIALITY 7 5
ALKYLS 2 2
WAMBLED 2 2
TRILINGUAL 3 3
MONKSHOOD 2 2
UNSCREWED 2 3
SCOTIAS 3 2
SYMPHONY 3 2*
FOCALIZATION 5 5
CONTRARIETY 4 3
HABERDASHER 4 4
UNCURIOUS 4 3
UNSWORE 2 2
MULTIVOLUME 4 4
CHEF 1 1
PITH 1 1
PENTAMIDINE 4 4
VISITATIONS 4 4
STEEPEN 2 2
SYNCOPATING 4 4
INTRIGANTS 3 3
SCANDIAS 3 2
BREGMATE 2 2
INACTIVATION 5 5
UNDERUTILIZES 6 6
FLOC 1 1
TUBAE 2 1
UNSYSTEMATIZED 5 6
HELLENIZE 3 3
VEXT 1 1
MUDSLINGERS 3 3
PHILANTHROPISTS 4 4
TALLISH 2 2
DOWNER 2 2
OCHERS 2 2
ENFOLDING 3 3
CATWALKS 2 2
RAMPANT 2 2
PREORDAINMENT 4 3
TROUSSEAU 2 1
GRAVIDA 3 2
POLYWATER 4 4
INSUFFLATOR 4 4
MODERATENESSES 6 6
OUTCROWING 3 3
ACCOUCHEMENTS 4 4
UNDERDOGS 3 3
BRAIZE 1 1
VICEROYSHIP 4 4
CACHEXIAS 4 3
CUDDLIER 3 2
ASSIGNOR 3 3
SUEDED 2 2
TACTILITIES 4 4
SPHENOIDS 2 2
BANKROLLERS 3 3
OCTANTS 2 2
ANNUNCIATORY 6 4
TITLEHOLDERS 4 4
REPRESSOR 3 3
RECKONERS 3 3
FAVOURS 2 2
OSAR 2 2
EDUCATION 4 4
UNCREATES 2 3
MEASURABILITIES 6 6
AROUSERS 3 3
DISASSEMBLY 4 3*
LICHEE 2 1
MOTIVATOR 4 4
CONCEDEDLY 4 3*
VELLUM 2 2
MERCHANDIZE 3 3
CONCOURSES 3 3
PHILISTIA 4 2
COUNTERINSURGENCY 6 5*
DUMBWAITERS 3 3

The new algorithm has lots of problems with a final Y…maybe the person forgot to specify an exception to rule (3) when the end vowel is Y. Doing that would repair the 7 cases with an asterisk.

Here is the comparison with the list of 34 more peculiar cases:

AIDE 1 1
IDEA 3 1
IDEAS 2 2
IDEE 2 1
IDE 1 1
AIDA 2 1
PROUSTIAN 3 2
CHRISTIAN 3 2
CLICHE 1 1
HALIDE 2 2
TELEPHONE 3 3
TELEPHONY 4 3*
DUE 1 0
IDEAL 2 2
DEE 1 0
UREA 3 1
VACUO 3 1
SEANCE 1 1
SAILED 1 2
RIBBED 1 2
MOPED 1 2
BLESSED 1 2
AGED 1 2
TOTED 2 2
WARRED 1 2
UNDERFED 2 3
INBRED 2 2
BRED 1 1
RED 1 1
STATES 1 2
TASTES 1 2
TESTES 1 2
UTILIZES 4 4

There are some inevitable flip-flops here…for example, if a simple algorithm get testes right, then it's going to get tastes wrong, and conversely. Likewise for Proustian/Christian. But altogether there's a lot more green than red, even after fixing the asterisk cases.

## Thursday, July 20, 2017

### An Algorithm For Counting Syllables

A while ago I was talking to a friend who works for a startup company doing natural-language processing. At some point we got to talking about syllabification, and I mentioned a syllable-counting algorithm I'd made ten years ago. He seemed to think that there weren't many such things floating around, so I thought I'd post the algorithm here. It's kind of interesting even if you aren't in the syllable-counting industry.

The algorithm is described below. The code is also included. Given a word as a string of A–Z letters, the algorithm returns a number which is likely to be the number of syllables in the word. The algorithm doesn't tell you where the syllable breaks should be; it just guesses how many syllables there are.

How good is the algorithm? I don't have much data on that, but it seems to work well enough for my purposes (making word games). The algorithm gets 93 of the following 100 words correct:

PYRAMIDALLY 5
MISERICORDS 4
THYROXINS 3
PLICATION 3
PERTINACIOUS 5
LEAL 1
LYCOPOD 3
FRIPPERIES 3
INTERDEPENDENCY 6
RITORNELLOS 4
PRESSORS 2
TINNY 2
POOFTER 2
PETTLED 2
BACKPEDALLING 4
CHERRYLIKE 3
INTERCONVERT 4
VILLEIN 2
STALEST 2
PREVISION 3
TERRITORIALITY 7
ALKYLS 2
WAMBLED 2
TRILINGUAL 3
MONKSHOOD 2
UNSCREWED 2
SCOTIAS 3
SYMPHONY 3
FOCALIZATION 5
CONTRARIETY 4
HABERDASHER 4
UNCURIOUS 4
UNSWORE 2
MULTIVOLUME 4
CHEF 1
PITH 1
PENTAMIDINE 4
VISITATIONS 4
STEEPEN 2
SYNCOPATING 4
INTRIGANTS 3
SCANDIAS 3
BREGMATE 2
INACTIVATION 5
UNDERUTILIZES 6
FLOC 1
TUBAE 2
UNSYSTEMATIZED 5
HELLENIZE 3
VEXT 1
MUDSLINGERS 3
PHILANTHROPISTS 4
TALLISH 2
DOWNER 2
OCHERS 2
ENFOLDING 3
CATWALKS 2
RAMPANT 2
PREORDAINMENT 4
TROUSSEAU 2
GRAVIDA 3
POLYWATER 4
INSUFFLATOR 4
MODERATENESSES 6
OUTCROWING 3
ACCOUCHEMENTS 4
UNDERDOGS 3
BRAIZE 1
VICEROYSHIP 4
CACHEXIAS 4
CUDDLIER 3
ASSIGNOR 3
SUEDED 2
TACTILITIES 4
SPHENOIDS 2
BANKROLLERS 3
OCTANTS 2
ANNUNCIATORY 6
TITLEHOLDERS 4
REPRESSOR 3
RECKONERS 3
FAVOURS 2
OSAR 2
EDUCATION 4
UNCREATES 2
MEASURABILITIES 6
AROUSERS 3
DISASSEMBLY 4
LICHEE 2
MOTIVATOR 4
CONCEDEDLY 4
VELLUM 2
MERCHANDIZE 3
CONCOURSES 3
PHILISTIA 4
COUNTERINSURGENCY6
DUMBWAITERS 3

Here are 34 words that I used while developing the algorithm—they are tricky cases or else illustrate some of the exceptions being handled. The algorithm gets 27 of them correct.

AIDE 1
IDEA 3
IDEAS 2
IDEE 2
IDE 1
AIDA 2
PROUSTIAN 3
CHRISTIAN 3
CLICHE 1
HALIDE 2
TELEPHONE 3
TELEPHONY 4
DUE 1
IDEAL 2
DEE 1
UREA 3
VACUO 3
SEANCE 1
SAILED 1
RIBBED 1
MOPED 1
BLESSED 1
AGED 1
TOTED 2
WARRED 1
UNDERFED 2
INBRED 2
BRED 1
RED 1
STATES 1
TASTES 1
TESTES 1
UTILIZES 4

Some of the failures are interesting, because when you see the number of syllables assigned by the computer, you get a sense of how the computer is "misreading" the words. For example, cliché gets one syllable, so from the point of view of the algorithm, it is as if CLEE-SHAY were being read as CLEESH. (My dictionary doesn't include diacritic marks.) Some of the mispronunciations aren't far off the mark, in terms of patterns of pronunciation in English: testes gets one syllable, as if it were pronounced analogously to tastespertinacious gets 5 syllables, as if it were pronounced PER-TIN-A-SEE-US.

I'm surprised to see that the algorithm gets idea right but ideas wrong. I remember that an early version of the algorithm dropped terminal S's before applying the logic, but maybe that rule was worse, on balance. Clearly the algorithm could be improved in any number of ways, for example by adding more exception handling.

***

Here is the description from the comments to the code:

(*

Algorithm for counting syllables.

If the word has no consonants, then the number of syllables is the number of distinct letters in the word. Otherwise:

We count the 'leading' syllables by advancing through the word from left to right, examining pairs of consecutive letters.  If the pair is (vowel)(consonant), then we increment the syllable count by 1. Otherwise, we do nothing.

We next add syllables for each appearance of the vowel combination IA (as in EDITORIAL)

We next add syllables for each appearance of the vowel combination EO (as in PREORDAINED)

We add a syllable if the word ends in -IOUS or -IER

We next correct unwanted syllabification of (consonant+ED) endings.  We would be satisfied with giving certain ED endings their own syllable (BLESSED), but we don't want all ED endings to get a syllable.  The rule adopted here is that we deduct a syllable for an ED ending unless the prior letter is D, T, or ((consonant other than R)+R) or (consonant+L).

We next correct unwanted syllabification of ES endings.  The rule adopted here is that we deduct a syllable for an ES ending unless the prior letter is C, G, X, S, Z, or (consonant+L).

We now add 'final' syllables if necessary.  If the last letter is a consonant, or if the second-last letter is a consonant and the last letter is an E, then there are no final syllables. Otherwise, if the final string of 1 or more vowels matches one of a specified set of disyllabic pairs, then there are two final syllables; otherwise, there is one final syllable.

Finally, if the syllable count is less than 1, set the syllable count to 1.

The disyllabic combinations are specified to be EA,II,IO,UA,UO. (We don't have to include IA and EO because they have been handled above.)

*)

***

Here is a Mathematica implementation. It's ugly, in part because it's from ten years ago but mostly because I tend to code a project like this just about as fast as I can type, not worrying about planning or elegance.

Alphabet={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};

Vowels={"A","E","I","O","U","Y"};

Consonants=Complement[Alphabet,Vowels];

VowelPositionTFList[LetterListArg_]:=
Table[
MemberQ[Vowels,LetterListArg[[k]]],
{k,1,Length[LetterListArg]}];

ConsonantPositionTFList[LetterListArg_]:=
Map[Not,VowelPositionTFList[LetterListArg]];

LastConsonantPosition[LetterListArg_]:=
Max[
Position[
ConsonantPositionTFList[LetterListArg],
True
]
];

CountVowels[LetterListArg_]:=
Count[
VowelPositionTFList[LetterListArg],
True
];

DisyllabicVowelPairs={{"E","A"},(* {"E","O"}, {"I","A"},*) {"I","I"},{"I","O"},{"U","A"},{"U","O"}};

CountSyllables[WordArg_]:=
{
CharacterList=Characters[WordArg];
NCharacters=Length[CharacterList];
If[
CountVowels[CharacterList]==NCharacters,
Length[Union[CharacterList]],
RawSyllableCount=0;
Do[
TempCharacter1=CharacterList[[LetterIndex]];
TempCharacter2=CharacterList[[LetterIndex+1]];
If[MemberQ[Vowels,TempCharacter1]&&MemberQ[Consonants,TempCharacter2],
RawSyllableCount=RawSyllableCount+1
],
{LetterIndex,1,NCharacters-1}];
CurrentSyllableCount=RawSyllableCount;
CurrentSyllableCount=CurrentSyllableCount+Length[StringPosition[WordArg,"IA"]];
CurrentSyllableCount=CurrentSyllableCount+Length[StringPosition[WordArg,"EO"]];
If[
NCharacters>4&&StringTake[WordArg,-4]=="IOUS",
CurrentSyllableCount=CurrentSyllableCount+1
];
If[
NCharacters>3&&StringTake[WordArg,-3]=="IER",
CurrentSyllableCount=CurrentSyllableCount+1
];
If[
NCharacters>2&&CharacterList[[-1]]=="D"&&CharacterList[[-2]]=="E"&&MemberQ[Consonants,CharacterList[[-3]]],
EDCorrection=-1;
If[
MemberQ[{"D","T"},CharacterList[[-3]]],
EDCorrection=0,
If[
((NCharacters>3)&&CharacterList[[-3]]=="R"&&CharacterList[[-4]]!="R")||((NCharacters>3)&&CharacterList[[-3]]=="L"&&MemberQ[Consonants,CharacterList[[-4]]]),
EDCorrection=0
]
],
EDCorrection=0
];
CurrentSyllableCount=CurrentSyllableCount+EDCorrection;
If[
NCharacters>2&&CharacterList[[-1]]=="S"&&CharacterList[[-2]]=="E"&&MemberQ[Consonants,CharacterList[[-3]]],
ESCorrection=-1;
If[
MemberQ[{"C","G","X","S","Z"},CharacterList[[-3]]],
ESCorrection=0,
If[
((NCharacters>3)&&CharacterList[[-3]]=="L"&&MemberQ[Consonants,CharacterList[[-4]]]),
ESCorrection=0
]
],
ESCorrection=0
];
CurrentSyllableCount=CurrentSyllableCount+ESCorrection;
TempPosition=LastConsonantPosition[CharacterList];
If[
(TempPosition==NCharacters)||((TempPosition==NCharacters-1)&&(CharacterList[[-1]]=="E")),
FinalSyllableCount=0,
VowelChunk=Take[CharacterList,{TempPosition+1,NCharacters}];
FinalSyllableCount=
If[
MemberQ[DisyllabicVowelPairs,VowelChunk],
2,
1
]
];
CurrentSyllableCount=CurrentSyllableCount+FinalSyllableCount;
Max[CurrentSyllableCount,1]
]
}[[1]];

## Wednesday, July 19, 2017

### A Table in D'Arcy Thompson's "On Growth and Form" Has Some Inconsistencies

I was dipping into my 1992 edition of On Growth and Form, D'Arcy Thompson's magnum opus of mathematical biology, and I found some inconsistencies in one of the tables. These inconsistencies don't appear to be logged anywhere else, so I thought I'd note them here. They were present in the very first edition, published in 1917, and they're still in the newest edition, which was published in 2014.

Here is how the table looked in the 1917 edition, which is available online.

The point of the table is that the listed animals bear the majority of their weight on their front feet, not their hind feet. Weights are given in units of "cwt," which stands for "hundredweight." Unless I'm misunderstanding the data, the first three rows of the table all have inconsistencies. I don't see any inconsistencies in the last two rows.

First row (Bactrian camel)

The table says that a Bactrian camel puts 9.25 cwts on its fore-feet and 4.5 cwts on its hind-feet. One inconsistency I see is that 9.25 + 4.5 = 13.75, yet the table gives the gross weight of the camel as 14.25 cwts, not 13.75 cwts. The weight on the fore-feet plus the weight on the hind-feet should equal the gross weight.

The stated percentages, 67.3 and 32.7, have essentially the same ratio as the stated parts, 9.25 cwts and 4.5 cwts; but the parts don't agree with the whole.

Changing the gross weight from 14.25 cwts to 13.75 cwts would make the row self-consistent.

Second row (llama)

The inconsistency in the second row is of the same kind as the inconsistency in the first row. The table says that a llama puts 1.75 cwts on its fore-feet and 0.875 cwts on its hind-feet. Although 1.75 + 0.875 = 2.625, the table gives the gross weight of the llama as 2.75 cwts.

The stated percentages, 66.7 and 33.3, have the same ratio as the stated parts, 1.75 cwts and 0.875 cwts; but the parts don't agree with the whole.

Changing the gross weight from 2.75 cwts to 2.625 cwts would make the row self-consistent.

Third row (Indian elephant)

The inconsistency in the third row is of the same kind as the inconsistency in the first two rows. The table says that the elephant puts 20.5 cwts on its fore-feet and 14.75 cwts on its hind-feet. Although 20.5 + 14.75 = 35.25, the table gives the gross weight of the elephant as 35.75 cwts. (One ton = 20 hundredweight in this system.)

The stated percentages, 58.2 and 41.8, have essentially the same ratio as the stated parts, 20.5 cwts and 14.75 cwts; but the parts don't agree with the whole.

Changing the gross weight from 1 ton and 15.75 cwts to 1 ton and 15.25 cwts would make the row self-consistent.

***

The inconsistencies are still being printed. Here is what the table looks like in the 2014 edition, according to a snippet from Google Books:

The data are unchanged from the 1917 edition. (This is also what my 1992 edition has.)

***

On Growth and Form celebrates its centenary this year, with events in science and the arts being held all over the globe. It was a landmark work—Stephen Jay Gould called it "one of the great lights of science (and of English prose)." The book will be read (or at least dipped into) for another hundred years…maybe in a future edition somebody will add a footnote to the table.