Dictation automation

Writing about how I work leads me to think about improvements I can make, which I then want to write about, leading me to think about making further improvements, and so on. So it was with my recent “one notebook” post. The last paragraph included this ominous sentence:

I’m already thinking I’ll give up on the handwritten index on the endpapers and just dictate the last several entries into the text file every week or so.

Wouldn’t it be even better, I thought a couple of days later, if I had a semi-automated way of adding entries to the index file? That way I could add entries immediately after writing a note—no need to flip back through the notebook and scroll back through the index file to figure out where I made the last entry.

Since I always have my phone with me, the obvious thing to do was make a Shortcut that prompts me to dictate the index entry and then adds that to the end of the index file. Here it is:

Add Index Entry shortcut

Since my goal is to add entries to the index right after writing them in the notebook, I have Shortcuts get and format the date for me in the first two steps. Step 3 brings up the dictation UI and records my description of the note. Step 4 combines the date, dictated text, and a trailing linefeed into a chunk of text that Step 5 then appends to the index file. The file is named “Notebook index.txt,” and it’s stored in a folder named “personal” in the root directory of iCloud Drive. Dictation errors can be fixed in either BBEdit on my Mac or Textastic on my phone.

I launch Add Index Entry from the Shortcuts widget on my home screen.

iPhone widget with index entry shortcut

I find this way of launching more reliable than using Siri.1

One more thing on the notebook front: I had some trouble writing the other day and noticed that I’d worn down the tip of my Razor Point. This is a rarity. Usually I lose them before they have a chance to get to this state.

New and old Razor Point tips


  1. More reliable than Siri? Say it ain’t so! 


Happy and sad

Science writer Jennifer Ouillette linked to this Scientific American article on Mastodon this morning. It’s about happy and sad numbers, which I had never heard of before. The article is by Manon Bischof and was originally published in Spektrum der Wissenschaft, where she’s an editor.

Overall, the article made me happy, but one part of it made me sad. It’s this description of an algorithm you can use to categorize a three-digit number, where the hundreds, tens, and ones digits are i, j, and k, respectively:

Scientific American algorithm screenshot

The problem is in Step 5 of the algorithm, where I’ve spread out the equations to make them easier to read:

5. If neither case is true, set new values for i, j and k using the “floor function” Floor(x), which assigns each decimal number its rounded-down integer value (Floor(1.6) = 1):

i = Floor(z100),

j = Floor(a – 100 x i10 ),

k = ai x 100 – j x 10.

With these new values for i, j and k, continue the algorithm at step 2.

What’s wrong with this? Let us count the ways:

  1. The variable a in the equations for j and k should be z. There is no a.
  2. The letter “x” should not be used to represent multiplication, especially when you’re using a serifed font, and especially especially when you’ve used it as a variable earlier in the sentence. There is a symbol for multiplication, ×, which has an easy-to-remember HTML entity, &times.
  3. There’s no reason for a multiplication symbol in the first place. Surely Scientific American readers know that multiplication is implied when a number and a symbol are adjacent to one another: 100i=100×i100 i = 100 \times i.
  4. How about a little consistency in how you present multiplication? Yes, multiplication is commutative, but there’s no reason to write 100×i100 \times i in one formula and i×100i \times 100 in the next.
  5. In fact, let’s go further. Always put the number first. No one typesets math with a variable before the number.

And although it’s not wrong, it might have helped readers to be more explicit in noting that these formulas are a mathematical way to extract the hundreds, tens, and ones digits from z (and any of these digits could be zero). In the examples earlier in the article, the digits were determined by inspection.

Because I’ve been thinking a lot about expressing formulas on the web lately, I decided to look at the HTML source for Step 5 in the SciAm article. Here it is:

xml:
5. If neither case is true, set new values for <em>i</em>, 
<em>j</em> and <em>k</em> using the &ldquo;floor function&rdquo; 
Floor(<em>x</em>), which assigns each decimal number its 
rounded-down integer value (Floor(1.6) = 1): 
<em>i</em> = Floor(<em><sup>z</sup></em>&frasl;<sub>100</sub>), 
<em>j</em> = Floor(<em><sup>a</sup></em><sup> &ndash; 
100 x <em>i</em></sup> &frasl; <sub>10</sub> ), 
<em>k</em> = <em>a</em> &ndash; <em>i </em> x 100 &ndash; 
<em>j</em> x 10. 
With these new values for <em>i</em>, <em>j</em> and <em>k,</em> 
continue the algorithm at step 2.

Using <sup> and <sub> is a reasonable approach for simple formulas like this, but why isn’t Scientific American using MathML, MathJax, or whatever other systems are out there for rendering mathematics on a web page? They’ve been printing mathematics in the hardcopy magazine for ages.


You may have noticed that I’ve switched over to MathML here.1 If you keep up with the blog via RSS, you’ve seen that posts with equations (like this one) have a disclaimer at the top, telling you that there are formulas in the post that your feed reader may not render correctly. If the formulas don’t render correctly, that’s probably because of the subscription service you’re using, not the reader. I intend to write a post explaining what I’ve learned about MathML, feed readers, and subscription services soon.


  1. The MathJax logo in the sidebar and all the MathJax leftovers in the HTML source will be cleaned up as soon as I feel confident I’m done with all the changes. 


One notebook

Recently, Brad Dowdy—you know, The Pen Addict— ran a poll on Mastodon, asking how many different notebooks people use.

Pen Addict poll results

I understand why people use more than one notebook at a time. I used to do it, too, when I needed to keep various work projects separate from one another. It was also important for me to be able to move and reorganize pages. But since retiring (more or less) at the beginning of the year, I’ve decided that the simplicity of a single notebook with fixed pages outweighs the flexibility of multiple notebooks and moveable pages. So I’m now in the 29% group.

I started this year with a University of Illinois-branded A5 notebook given to me last year as a Father’s Day gift by my younger son. It worked well, but I thought a thicker paper would work out better (that has to do with the pen I use, which we’ll get to in a minute). My next experiment was with a Feela A5 notebook from Amazon.

Feela Amazon image

These come in many colors and package counts from 3 through 24(!). I went with black because I’m boring and a 3-pack because this was an experiment.

The Feela’s paper is definitely thick enough. I like writing on both sides of each sheet, and I use a Pilot Razor Point, which leave a pretty dark line, but I’ve never been distracted by seeing through to the previous page.

I started the year trying out Sakura Pigma Micron pens, which Brad recommends, but they never felt as comfortable in my hand as a Razor Point. I’m sure Brad is right about the higher quality of the Micron ink, but I started using Razor Points in college, and it’s hard to overcome four decades of experience.

(When I needed to take field notes for work, I tried a variety of pens, eventually settling on the Uniball Jetstream. Being retractable (no cap to lose) and drying instantly were important features when I was climbing up ladders and crawling under equipment, but I don’t take notes while doing those things anymore. I still have some Jetstreams lying around but don’t expect to buy any in the future.)

By the way, each Feela comes with a cheap pen. If you feel guilty about throwing it away, I suggest you “forget” it at a library carrel or hotel room.

The first Feela from my 3-pack was a success, and I’m partway through the second. Here’s what a couple of recent pages look like:

Feela note pages

When you write everything in a single notebook, finding what you’ve written—especially when it’s more than a few days old—can be difficult. I use the date and page number fields at the top of each page to help me out. I start page numbers over for each topic and use the dates for an index that I write onto the notebook’s endpapers.

Feela endpapers with index

There are 4 endpaper pages available for the index, which should be enough to cover the 128 pages in the notebook.

When a notebook is filled, I write its date range in silver Sharpy on the front cover and spine and put it on a bookshelf. The Illinois-branded notebook covered about 6 months and the first Feela covered about 3 months. The difference is due partly to the difference in the number of pages but mostly to my using the notebook more as the year went on. I’ve been thinking that the handwritten indices inside each notebook will be less helpful as I accumulate more of them. So I’ve been working on the simplest way to have a computer-based searchable index.

What I’ve done so far is dictate the handwritten indices into a simple plain text file, which should be easy to search. For each entry, I dictate the date as the month name and day number, then the description, then “newline.” That gives lines that look like this:

October 1 dummy unit load method for SS beam.
October 3 Castigliano's second for SS beam.
October 5 list of SS beam solutions.

This is a good way to get a lot of text into the file quickly, but it isn’t how I want the index to look. Apart from mistranscriptions and other one-off corrections, I want the dates to be in yyyy-mm-dd format and the descriptions to be capitalized and without a trailing period. Like this:

2023-10-01 Dummy unit load method for SS beam
2023-10-03 Castigliano's second for SS beam
2023-10-05 List of SS beam solutions

So I wrote this short Perl script to handle those common transformations.

perl:
 1:  #!/usr/bin/perl
 2:  
 3:  # Fix formatting issues that typically arise when I dictate my notes index.
 4:  
 5:  while (<>) {
 6:    # Fix only lines that haven't already been reformatted
 7:    if (/^                              # starts with
 8:          (January|February|March|      # one
 9:           April|May|June|              # of the
10:           July|August|September|       # month
11:           October|November|December)   # names
12:          \s+                           # some whitespace
13:          \d{1,2}                       # one or two digits
14:          \s+                           # some whitespace
15:        /x) {
16:      
17:      # Extract the date and the note
18:      ($month, $day, $note) = split /\s+/, $_, 3;
19:      
20:      # Reformat the date to yyyy-mm-dd
21:      $date = "$month $day";
22:      $date = `date -j -f "%B %d" "$date" +"%Y-%m-%d"`;
23:      chomp $date;
24:      
25:      # Reformat the note
26:      $note = ucfirst $note;            # capitalize
27:      $note =~ s/\.$//;                 # delete trailing period
28:      
29:      print "$date $note";
30:    } else {
31:      print;                            # print other lines as-is
32:    }
33:  }

It passes through unchanged the lines that don’t start with a month name and day number. The date command on Line 22 reformats the dates, and the short function and regex substitution calls on Lines 26–27 reformat the the descriptions.

You may be wondering two things:

  1. Why Perl instead of Python?
  2. How does the year show up in the output when it isn’t in the input?

It’s Perl instead of Python because it started as a simple shell script that used date. As the script grew and needed more capability, I didn’t want to abandon the work I’d put it to getting a working date command, and the easiest way to include a shell command in a non-shell script was Perl’s backticks.

As for the year, when the date command encounters an item in the output specification that isn’t in the input date—in this case, %Y—it substitutes the value for the current date and time. So as long as I run the command this year, “October 1” is transformed to “2023-10-01.” Will this give incorrect years for December entries when I run the command next January? Yes, but since I intend to work with this file in BBEdit, I can use its column editing feature to quickly change all the incorrect 2024s into 2023s.

I suspect this indexing system will change over time, but it’s a decent start. I’m already thinking I’ll give up on the handwritten index on the endpapers and just dictate the last several entries into the text file every week or so. Ultimately, everything is a work in progress.


Antiprism

A couple of days ago, Matt Parker posted this video about antiprisms.

It ends with Matt and Laura Taalman calculating the volume enclosed by the upper portion of the One World Trade Center tower and getting a very neat and compact solution:

V=56AbasehV = \frac{5}{6} A_{base} h

This works out so nicely because the tower’s antiprism is tapered such that its roof has half the area of its base. Watch the video for the details.

What I want to talk about here is the question that comes up earlier in the video: Is the volume of a square-ended antiprism less than, greater than, or equal to the volume of a square-ended prism of the same base and height?

Since I’m sure you watched the video, I don’t have to show you what a square-ended antiprism looks like, but here it is anyway:

Upright antiprism

The orientation of the square at the top is turned 45° to that of the square at the bottom, and the top and bottom are connected by triangular faces.

Matt’s reasoning regarding the volume of this shape relative to a prism with the same top, bottom, and height is both impeccable and familiar. He considers the cross-section of the antiprism at midheight, and recognizes that it’s an octagon with the same perimeter as the squares at the bottom and top. Since such an octagon has an area greater than the squares, the volume of the antiprism must be greater than the volume of the prism.

What made this familiar to me was that I did this same octagon/square comparison last year. The ratio of the octagon area to the square area is

12(1+2)65\frac{1}{2} \left( 1 + \sqrt{2} \right) \approx \frac{6}{5}

But that’s where Matt and Laura stop with the antiprism and move on to the tapered antiprism of One World Trade Center. I wanted them to follow through with the ratio of the volumes of the antiprism and prism. Since they didn’t, I will.

I didn’t try anything clever. I started by looking at the cross-sections at various heights.

Antiprism cross-sections

The key was the diagram in the lower right corner, which gives the dimensions of the non-regular octagon at an arbitrary height z above the base. You can see how it matches the dimensions of the other three cross-sections for z values of 0, h, and h/2.

To get the area of the arbitrary octogon, I redrew the figure this way and subtracted the areas of the four gray triangles from that of the large square.

Generic cross-section

A=[2a(1zh)+22azh]24[12(2azh)2]A = \left[ 2 a \left(1 - \frac{z}{h} \right) + 2 \sqrt{2} a \frac{z}{h} \right]^2 - 4 \left[ \frac{1}{2} \left( \sqrt{2} a \frac{z}{h} \right)^2 \right]

Simplifying, we get

A=4a2[1+2(21)zh2(21)(zh)2]A = 4 a^2 \left[ 1 + 2 \left( \sqrt{2} - 1 \right) \frac{z}{h} - 2 \left( \sqrt{2} - 1 \right) \left( \frac{z}{h} \right)^2 \right]

The ratio of this area to that of the squares at the top and bottom is

A~=A4a2=1+2(21)zh2(21)(zh)2\widetilde{A} = \frac{A}{4 a^2} = 1 + 2 \left( \sqrt{2} - 1 \right) \frac{z}{h} - 2 \left( \sqrt{2} - 1 \right) \left( \frac{z}{h} \right)^2

which plots as this parabola:

Area function

Note that this matches our expectations of 1 at the top and bottom and about 1.2 at midheight.

To get the volume, we integrate the area from bottom to top:

V=0hAdz=4a20hA~dzV = \int_0^h A\; dz = 4 a^2 \int_0^h \widetilde{A}\; dz V=4a2h(2+23)=(2+23)AbasehV = 4 a^2 h \left( \frac{2 + \sqrt{2}}{3} \right) = \left( \frac{2 + \sqrt{2}}{3} \right) A_{base} h

which is about 14% more than the volume of the prism. This is not as simple as the formula Matt and Laura got for the tapered antiprism, but it’s still fairly compact.