I’ve been taking it out to local lakes and paddling around to get myself used to it. The first couple of times, because I was focused on assembling it correctly and getting in without tipping over, I forgot to start the Paddling workout on my Apple Watch, so I didn’t have a complete record of either of those little trips. But I have recorded the more recent paddles and have learned a rather disappointing fact: the Workout app doesn’t keep track of where you went.
This was quite a shock. For years, I’ve been using Workout to track my walks, getting both a nice map of my path and a sense of how fast I was going during each stretch.
(The map can also show that you got in the car and drove away before turning the workout off.)
I assumed the Paddling workout would do the same, but here’s what I saw after paddling around at Busse Woods a few days ago:
It gives you a dot where you started the workout but nothing else. A search of the web to see if I’d done something wrong soon told me that I hadn’t and that lots of paddlers were unhappy about this deficiency.
Apple has always been concerned with battery life on the Watch, but I don’t understand why keeping track of my location while kayaking is going to be any more draining than doing the same thing while hiking. Or biking, for that matter, a workout type that also tracks location and presents a map.
There are third-party paddling apps that will track my location, so I guess I’ll have to start trying them out. My initial sense is that these apps are meant for people who are a lot more serious about kayaking than I ever expect to be and therefore have features I’ll never use. Oh, well. Every hobby has hidden costs.
Update 18 May 2024 5:42 PM
A few updates:
In Matt Parker’s latest video, he gives two proofs to show that if you
you’ll get a number that is a multiple of your original number minus one. In words, this seems magical; in equation form,
$${b}^{n}-1=(b-1)\phantom{\rule{thinmathspace}{0ex}}(\phantom{\rule{thinmathspace}{0ex}}\mathrm{something}\phantom{\rule{thinmathspace}{0ex}})$$not so much. Certainly you know that
$${b}^{2}-1=(b-1)\phantom{\rule{thinmathspace}{0ex}}(b+1)$$because that comes up so often. You may also remember from algebra class that
$${b}^{3}-1=(b-1)\phantom{\rule{thinmathspace}{0ex}}({b}^{2}+b+1)$$So it isn’t tremendously surprising to hear that $b-1$ is a factor no matter what $n$ is. But what’s the proof?
Matt’s first proof is to notice that $b=1$ is a solution to
$${b}^{n}-1=0$$for any $n$. Therefore, $(b-1)$ has to be one of the factors of ${b}^{n}-1$. He considers this a rather prosaic proof, and quickly moves on to the fun one, which involves expressing the numbers in different bases. It is a cute proof, and you should watch the video to see it.
But I wanted to go back to
$${b}^{n}-1=(b-1)\phantom{\rule{thinmathspace}{0ex}}(\phantom{\rule{thinmathspace}{0ex}}\mathrm{something}\phantom{\rule{thinmathspace}{0ex}})$$and see if there’s a solution for something that works for every $n$. Obviously there is, or I wouldn’t have written this post. And you’ve probably already guessed what that solution is, but let’s figure it out systematically.
We’ll set up the polynomial division of ${b}^{n}-1$ by $b-1$ and run it out for a few steps:
As you can see, after Step $m$ in the process, the difference (i.e., the expression under the horizontal line) is
$${b}^{n-m}-1$$So after $m=n-1$ steps, the difference will be $b-1$, which means that the last term in the quotient will be $+1$ and there will be no remainder. Therefore, something is
$${b}^{n-1}+{b}^{n-2}+\dots +b+1=\sum _{m=0}^{n-1}{b}^{m}$$which is easier to remember than I would have guessed.
]]>Yesterday, I was thinking about what textbook I would move on to after I finish Adventures in Celestial Mechanics. Because I’ve been thinking about gravity, I pulled Oliver Kellogg’s Foundations of Potential Theory off my shelf and started leafing through it. I soon came upon a gravity problem that I first heard about when I was a teenager but never saw the solution for. The problem has to do with Pellucidar, and it’s not as tricky as I expected.
Pellucidar is an imaginary land created by Edgar Rice Burroughs for a series of pulpy adventure books, starting with At the Earth’s Core. The conceit of the stories is that the Earth is actually a hollow shell and that there’s an inhabited land, Pellucidar, on the inside surface of the shell. Intrepid adventurers from our side of the shell dig through to Pellucidar, meet the strange people and creatures who live there, and have adventures intrepidly. Never one to let an idea go unexploited, Burroughs even had Tarzan visit Pellucidar.
While I read one or two Tarzan books and several of the John Carter of Mars books, I never picked up any of the Pellucidar novels. But I did read somewhere—possibly in an Isaac Asimov science essay—that the concept of Pellucidar was flawed in a way apart from the many obvious ways: the inhabitants of Pellucidar would not “stick” to the inner surface of a hollow Earth because there’s no net gravitational force inside a spherical shell.
This seemed very odd to the teen-aged me, but Asimov (or whomever) didn’t explain it, and I didn’t have the analytical tools to check it out myself. But now I do, following more or less the derivation given by Kellogg.
Suppose we have a thin spherical shell of radius $a$. We want to know the gravitational attraction that the sphere exerts on a particle, $P$, which may be either inside or outside the sphere.
We’ll set up our coordinate system so that $P$ is on the $z$ axis. Every point on the sphere, $Q$, can be identified by two angular coordinates, $\theta $ and $\varphi $, which are the point’s latitude and longitude.
(If you’re wondering how we should handle the analysis if $P$ isn’t on the $z$ axis, don’t. One of the most important things to learn in mechanics is that the coordinate systems we use are up to us; there is no $x\text{-}y\text{-}z$ stamped on the universe. Wherever $P$ happens to be, we can draw a $z$ axis that runs through it from the center of the sphere.)
The gravitational force that some small differential element at $Q$ on the sphere exerts on particle $P$ is
$$dF=\frac{G\rho \phantom{\rule{thinmathspace}{0ex}}dA}{{r}^{2}}$$where $G$ is the universal gravitational constant, $\rho $ is the areal density of the sphere (i.e., it has units of mass per area, not mass per volume), and $r$ is the distance from $Q$ to $P$. $dA$ is the differential area of the element on the sphere, and $dF$ is the differential force (per unit mass of $P$) that element exerts on particle $P$.
Here’s a sketch of the differential area at $Q$:
It’s bounded by lines of latitude that are $d\theta $ apart from one another and lines of longitude that are $d\varphi $ apart from one another. The area of the element is
$$dA=(a\phantom{\rule{thinmathspace}{0ex}}d\theta )(a\mathrm{cos}\theta \phantom{\rule{thinmathspace}{0ex}}d\varphi )={a}^{2}\mathrm{cos}\theta \phantom{\rule{thinmathspace}{0ex}}d\varphi \phantom{\rule{thinmathspace}{0ex}}d\theta $$If you’re wondering why we can use the formula for the area of a rectangle when the edges and the surface itself are curved, I will remind you that this is how calculus works. These differential lengths are teeny tiny and therefore the difference between the area of the surface and the area of a rectangle is extra extra teeny tiny. In calculus, we keep track of the teeny tiny and throw away the extra extra teeny tiny.
To express the differential force in terms of $\theta $ and $\varphi $, let’s look at a side view of the sphere with $P$ and $Q$. First, we’ll consider the case where $P$ is “above” $Q$:
The distance between $P$ and $Q$ is
$$r=\sqrt{(a\mathrm{cos}\theta {)}^{2}+(z-a\mathrm{sin}\theta {)}^{2}}=\sqrt{{a}^{2}+{z}^{2}-2az\mathrm{sin}\theta}$$Although I’ve drawn the figure with $P$ outside the sphere, the formula above also applies when $P$ is inside the sphere. What matters is that $P$ is above $Q$.
Now let’s consider the case where $P$ is “below” $Q$:
Here, $r$ is the hypotenuse of a different right triangle, but it turns out that
$$r=\sqrt{(a\mathrm{cos}\theta {)}^{2}+(a\mathrm{sin}\theta -z{)}^{2}}=\sqrt{{a}^{2}+{z}^{2}-2az\mathrm{sin}\theta}$$is the same formula as before. That’s convenient. So the magnitude of the differential force is
$$dF=\frac{G\rho {a}^{2}\mathrm{cos}\theta}{\sqrt{{a}^{2}+{z}^{2}-2az\mathrm{sin}\theta}}\phantom{\rule{thinmathspace}{0ex}}d\varphi \phantom{\rule{thinmathspace}{0ex}}d\theta $$To determine the force on $P$ due to the entire sphere, we’re going to integrate on $\theta $ from $-\pi /2$ to $\pi /2$ and on $\varphi $ from $0$ to $2\pi $. But first, we need to think about the direction of the differential force.
Note that in each of the two side views, the gravitational force on $P$ has two components: a component parallel to the $z$ axis (vertical in our drawings) and a component perpendicular to the $z$ axis (horizontal in our drawings). When we integrate over $\varphi $, we’re dealing with forces associated with a circle of constant latitude, and the components perpendicular to the the $z$ axis (horizontal) will cancel each other out. For example, the horizontal component when $Q$ is at $\varphi =180\text{\xb0}$ cancels the horizontal component when $Q$ is at $\varphi =0\text{\xb0}$, the horizontal component for $\varphi =270\text{\xb0}$ cancels the horizontal component for $\varphi =90\text{\xb0}$, and so on.
The upshot is that we only have to worry about the “vertical” component of the force, i.e., the component in the $z$ direction. To get that component, we multiply $dF$ by the $z$ direction cosine.
When $P$ is above $Q$, the $z$ direction cosine is
$$-\frac{z-a\mathrm{sin}\theta}{\sqrt{{a}^{2}+{z}^{2}-2az\mathrm{sin}\theta}}$$where the minus sign out in front indicates that the component is acting in the negative $z$ direction. Remember, we’re computing the gravitational force on $P$ due to $Q$, so the force acts from $P$ toward $Q$.
When $P$ is below $Q$, the $z$ direction cosine is
$$\frac{a\mathrm{sin}\theta -z}{\sqrt{{a}^{2}+{z}^{2}-2az\mathrm{sin}\theta}}$$Compare this formula with the previous one and you’ll see that they are algebraically identical. As with the expressions for $r$, the signs work out to give the same equation for both cases.
So the $z$ component of the differential force acting on $P$ due to $Q$ is
$$d{F}_{z}=\frac{G\rho {a}^{2}\mathrm{cos}\theta \phantom{\rule{thinmathspace}{0ex}}(a\mathrm{sin}\theta -z)}{({a}^{2}+{z}^{2}-2az\mathrm{sin}\theta {)}^{3/2}}\phantom{\rule{thinmathspace}{0ex}}d\varphi \phantom{\rule{thinmathspace}{0ex}}d\theta $$and the total force that the sphere exerts on $P$ is
$$F={F}_{z}={\int}_{-\pi /2}^{\pi /2}{\int}_{0}^{2\pi}\frac{G\rho {a}^{2}\mathrm{cos}\theta \phantom{\rule{thinmathspace}{0ex}}(a\mathrm{sin}\theta -z)}{({a}^{2}+{z}^{2}-2az\mathrm{sin}\theta {)}^{3/2}}\phantom{\rule{thinmathspace}{0ex}}d\varphi \phantom{\rule{thinmathspace}{0ex}}d\theta $$This may seem awful, but it isn’t. First, notice that $\varphi $ doesn’t appear in the integrand, so the integral over $\varphi $ is just
$${\int}_{0}^{2\pi}d\varphi =2\pi $$We can pull that and the other constants out to get
$$F=2\pi G\rho {a}^{2}{\int}_{-\pi /2}^{\pi /2}\frac{\mathrm{cos}\theta \phantom{\rule{thinmathspace}{0ex}}(a\mathrm{sin}\theta -z)}{({a}^{2}+{z}^{2}-2az\mathrm{sin}\theta {)}^{3/2}}\phantom{\rule{thinmathspace}{0ex}}d\theta $$This still looks bad, but with tools like Mathematica and SymPy, integrations like this aren’t the pain in the ass they used to be. After a few seconds of chugging in Mathematica,
the answer pops out:
$$F=\frac{2\pi G\rho {a}^{2}}{{z}^{2}}\phantom{\rule{thinmathspace}{0ex}}(sgn(a-z)-1)$$where the signum function ($sgn$) is $+1$ if the argument is positive and $-1$ if the argument is negative. Therefore, if $P$ is outside the sphere ($a<z$),
$$F=\frac{2\pi G\rho {a}^{2}}{{z}^{2}}(-1-1)=-\frac{4\pi G\rho {a}^{2}}{{z}^{2}}$$At this point, we recall that $4\pi {a}^{2}$ is the area of the sphere, so that multiplied by the areal density, $\rho $ , is the mass of the sphere, which we’ll call $M$. So for this case
$$F=-\frac{GM}{{z}^{2}}$$which is just what we’d expect (remember that this is the force per unit mass of $P$, so there’s no mass term for the particle).
On the other hand, if $P$ is inside the sphere ($a>z$),
$$F=\frac{2\pi G\rho {a}^{2}}{{z}^{2}}(1-1)=0$$which is the surprising (to me, anyway) result that the sphere exerts no net gravitational force on a particle inside it.
How can this be? Well, certainly it makes sense if $P$ is at the center of the sphere. If we move $P$ up from the center, there’s more mass below $P$ but it is, on the average, farther away. It works out that the increasing mass and increasing distance balance each other to keep the net force at zero.
Oliver Kellogg didn’t have Mathematica. His suggestion was to do a change of variable from $\theta $ to $r$ and then integrate. He doesn’t give any details of the process, just the two answers. But I went ahead and did it his way, too, using
$$r=\sqrt{{a}^{2}+{z}^{2}-2az\mathrm{sin}\theta}$$ $$dr=-\frac{az\mathrm{cos}\theta}{\sqrt{{a}^{2}+{z}^{2}-2az\mathrm{sin}\theta}}\phantom{\rule{thinmathspace}{0ex}}d\theta =-\frac{az\mathrm{cos}\theta}{r}\phantom{\rule{thinmathspace}{0ex}}d\theta $$and
$$a\mathrm{sin}\theta -z=\frac{{a}^{2}-{z}^{2}-{r}^{2}}{2z}$$With those substitutions, the integrand becomes
$$-\frac{1}{2a{z}^{2}}\phantom{\rule{thinmathspace}{0ex}}\frac{{a}^{2}-{z}^{2}-{r}^{2}}{{r}^{2}}$$which is much easier to deal with than the original integrand. But we have to be careful with the limits. If $z>a$, the upper limit ($\theta =\pi /2$) becomes
$$r=z-a$$and the lower limit ($\theta =-\pi /2$) becomes
$$r=z+a$$Therefore, the integral is
$$F=\frac{\pi G\rho a}{{z}^{2}}{\int}_{z-a}^{z+a}\frac{{a}^{2}-{z}^{2}-{r}^{2}}{{r}^{2}}\phantom{\rule{thinmathspace}{0ex}}dr$$where I got rid of the negative sign at the front of the integrand by exchanging the limits. With no trig functions to make life difficult, this works out very quickly to
$$F=-\frac{4\pi G\rho {a}^{2}}{{z}^{2}}$$when $P$ is outside the sphere. This is the same answer as before.
If $z<a$, the upper limit ($\theta =\pi /2$) becomes
$$r=a-z$$and the lower limit ($\theta =-\pi /2$) becomes
$$r=a+z$$Therefore, the integral is
$$F=\frac{\pi G\rho a}{{z}^{2}}{\int}_{a-z}^{a+z}\frac{{a}^{2}-{z}^{2}-{r}^{2}}{{r}^{2}}\phantom{\rule{thinmathspace}{0ex}}dr$$which works out to
$$F=0$$when $P$ is inside the sphere. Again, a repeat of the answer we got when integrating over $\theta $.
While it was nice to see explicitly how Kellogg did the integration, it was faster to just let Mathematica do its thing. And I didn’t get any deeper physical insight doing the change of variable.
Anyway, now I understand the surprising thing I read about 45 or so years ago. And I’m downloading At the Earth’s Core.
]]>Kieran Healy tweeted out a gem earlier this evening:
Yes, Professor Huberman, a probability of 120% is indeed “a different thing altogether.”^{1}
While I find it fascinating that someone can run through an argument that clearly proves they are wrong and continue along as if they hadn’t, I don’t have any expertise in psychology, so I won’t try to explain it.
I do, however, have some expertise in probability, and Huberman is dancing around the edge of one of my favorite problems: If there’s a 1 in n chance of something happening in one try, what’s the probability of it happening in n tries?
Remarkably, the answer is not
$$n\left(\frac{1}{n}\right)=1$$It’s
$$1-{(1-\frac{1}{n})}^{n}$$The term in the parentheses is the probability of it not happening in a single trial. That term raised to the nth power is the probability of it not happening in n trials (assuming independence between trials). And subtracting that from 1 gives us the probability of it happening (at least once) in n trials.
What’s great about this problem is that you can make a pretty decent estimate of the answer without doing any calculations. The reason is
$$\underset{n\→\mathrm{\infty}}{\mathrm{lim}}{(1-\frac{1}{n})}^{n}=\frac{1}{e}\≈0.37$$and so
$$\underset{n\→\mathrm{\infty}}{\mathrm{lim}}1-{(1-\frac{1}{n})}^{n}=1-\frac{1}{e}\≈0.63$$Now, in the Huberman problem n is 5, which is not especially close to infinity, but luckily the convergence to the limit is pretty rapid.
I would have guessed the answer for $n=5$ was about 0.65; it’s actually 0.67. Not super accurate, but better than 1.
Update 10 May 2024 12:21 PM
John D. Cook also saw the Huberman clip and wrote a nice post this morning about how adding probabilities is a reasonably close approximation if both
Absolutely true, but not as much fun as a solution that ends up with Euler’s constant popping up out of nowhere.
As I was making tea this morning, I was reminded that many people on the internet think I’m an idiot. I’d like to defend myself.
I heat the water I use for brewing tea in a microwave oven. This is, according to the internet, a terribly dangerous practice, as I could very easily end up with superheated water that will suddenly boil over and scald me. That I’ve never had such an accident in maybe 20 years of making tea this way is a strong hint that I’m doing it safely, but it isn’t proof. Maybe I’ve just been lucky the roughly 6,000 times I’ve done it.
So let’s do some calculations. The thermal mug I currently drink from has a 20-oz capacity, so I heat up about 600 ml of water in a Pyrex measuring cup. I put the measuring cup in a 1200-watt microwave and set the timer for 3:10. That works out to
$$(1200\phantom{\rule{thickmathspace}{0ex}}\text{J/s})(190\phantom{\rule{thickmathspace}{0ex}}\text{s})=\mathrm{228,000}\phantom{\rule{thickmathspace}{0ex}}\text{J}$$of energy being put into the water (J = joules). This is an overestimate, as it doesn’t account for the heating of the glass cup.
The water coming out of my kitchen faucet tends to be 50–55°F. Let’s call it 12°C, so bringing this water to the boiling point requires
$$(88\phantom{\rule{thickmathspace}{0ex}}\text{K})(600\phantom{\rule{thickmathspace}{0ex}}\text{g})(1\phantom{\rule{thickmathspace}{0ex}}\text{cal/g-K})(4.184\phantom{\rule{thickmathspace}{0ex}}\text{J/cal})=\mathrm{220,900}\phantom{\rule{thickmathspace}{0ex}}\text{J}$$The energy I’m putting into the system is, at most, about what it takes to bring the water to a boil. So I’m not creating superheated water.
What about hot spots? If I’m not heating the water uniformly, I could still be superheating some portion of it, right? I suppose, but like all microwave ovens, mine has a turntable, so no part of the measuring cup stays in the same place. Not even the center, because I don’t put the cup in the middle of the turntable.
Now, I don’t want to be irresponsible here and suggest you all go out and start microwaving water with no concern for the risks. But there is a way to do it safely, and I’d like to be given some credit for knowing how.
]]>David Sparks tested out the Perplexity AI-driven search engine and was moderately impressed, even though he disagreed with one of its answers. I decided to give Perplexity my own test, a structural engineering problem similar to one I gave ChatGPT last year.
My first question was this:
A cantilever beam of length L has a concentrated load P at midspan. What is the deflection at the free end?
This is not the most clearly worded question in the world, but I thought most structural engineers would interpret it as this problem,
I would have been satisfied if Perplexity had answered “Listen, dumbass, the concept of ‘midspan’ is questionable when it comes to cantilever beams because they don’t have supports at both ends.” Instead, Perplexity gave basically the same wrong answer as ChatGPT did:
For a cantilever beam of length L with a concentrated load P at midspan, the deflection at the free end is given by:
δ_max = PL^3 / (3EI)
Where:
δ_max is the maximum deflection at the free end
P is the concentrated load applied at midspan
L is the length of the cantilever beam
E is the modulus of elasticity of the beam material
I is the moment of inertia of the beam cross-sectionThe key points are:
- The deflection is maximum at the free end of the cantilever beam.
- The deflection varies with the cube of the beam length L, making longer beams much more susceptible to deflection.
- The deflection is inversely proportional to the flexural rigidity EI of the beam, which depends on the material and cross-sectional geometry.
So in summary, to calculate the free end deflection of a cantilever beam with a midspan concentrated load, simply substitute the given values of P, L, E and I into the formula δ_max = PL^3 / (3EI).
Like ChatGPT, Perplexity treated the question as this problem,
which is perhaps the most common cantilever beam configuration in example problems you’d find on the internet, but it’s not what I asked about.
(Also, “the maximum deflection at the free end” makes less sense than “midspan of a cantilever beam.” But we’ll let that one go.)
I followed up with a clarification and asked Perplexity to try again:
This answer is for the load applied at the free end. I want the deflection at the free end when the load is applied halfway between the fixed end and the free end.
I hoped this was a more explicit description of where the load was applied. Here’s Perplexity’s answer:
For a cantilever beam of length L with a concentrated load P applied at the midspan (L/2 from the fixed end), the deflection at the free end is given by:
δ_max = PL^3 / (8EI)
Where:
δ_max is the maximum deflection at the free end
P is the concentrated load applied at midspan
L is the length of the cantilever beam
E is the modulus of elasticity of the beam material
I is the moment of inertia of the beam cross-sectionThe key points are:
- The maximum deflection occurs at the free end of the cantilever.
- The deflection varies with the cube of the beam length L.
- The deflection is inversely proportional to the flexural rigidity EI.
- For a midspan load, the deflection is 27% higher than for a load at the free end.
So to calculate the free end deflection for a midspan concentrated load on a cantilever beam, substitute the given values of P, L, E and I into the formula: δ_max = PL^3 / (8EI)
It was nice that Perplexity understood where the load was applied and that the formula for deflection had to be different from what it gave me before. However:
The deflection at the free end, as we determined last year, is
$$\delta =\frac{5P{L}^{3}}{48EI}$$not
$$\delta =\frac{P{L}^{3}}{8EI}$$as Perplexity said.
Every teacher has seen students come up with internally inconsistent answers and not recognize them as such, so in that way Perplexity is mimicking human behavior. But we wouldn’t call it intelligence.
]]>date
command to output the date some number of weekdays after the current date. So if I ran it today (Thursday, May 2, 2024) with this invocation,]]>
next
, which used the date
command to output the date some number of weekdays after the current date. So if I ran it today (Thursday, May 2, 2024) with this invocation,
next tue
it would return
2024-05-07
which is the Tuesday of next week. If I ran it with this invocation,
next tue 2
it would return
2024-05-14
which is the Tuesday after that, i.e., two Tuesdays after today.
This worked out pretty well, except that I had to run it in the Terminal^{1} and then copy the output if I wanted it to go into some document. The switching to the Terminal and back made next
a lot less convenient than it should have been.
So I rewrote it as a Keyboard Maestro macro that I can run from anywhere and get the output onto the clipboard immediately. I call the macro download it (you may need to right-click on that link).
, and you canWhen
is invoked, typically by ⌃⌘W, this window appears:You choose the day of the week from the popup menu (the default is Monday) and enter the number of those weekdays after today in the text field (the default is 1).
Assuming I choose two Tuesdays from today, as in the second next
example above, the output is this:
As you can see, it tells me what the date is and gives me the option to put it on the clipboard in either of two formats:
yyyy-mm-dd
, which is what I’d typically use if I were making notes for myself.Or I can just
the macro if all I want is to see the date.Because next
, it’s more complicated, but it still uses date
to do most of the work. Here’s the code:
The key is the shell script in the second step:
weeks=$(( $KMVAR_Local_Number - 1 ))
date -v+${weeks}w -v+1d -v+$KMVAR_Local_Chosen_Weekday '+%Y-%m-%d'
The first line subtracts 1 from the number of weekdays the user asks for and puts that into the variable $weeks
. The second line does the work. The first two -v
options tell date
to move forward $weeks
weeks and one day. The third -v
option tells it to move to the weekday chosen by the user. The final argument is the output format.
If I asked for the second Tuesday after today, as in the example, date
would be called like this:
date -v+1w -v+1d -v+Tuesday '+%Y-%m-%d'
which returns 2024-05-14
. The -v
option is pretty complicated, and I frankly don’t trust myself to give you a complete explanation of how it works. I suggest you RTFM and play around with it, possibly using the command above as your starting point.
OK, so that’s where we get the yyyy-mm-dd
form of the date. It’s stored in the Local Next Weekday
variable. The next shell script converts it to the long format through
date -jf '%Y-%m-%d' $KMVAR_Local_Next_Weekday +'%B %-e, %Y'
The -jf
combination of options is the common way to convert dates from one format to another. The -f
part has an argument that specifies the input format, and the -j
part says that the input date should not be used to set the computer’s date and time.
Yes, date
can be used to set the date, which sounds insane, but only the superuser can do that. Option letters usually have some relationship to what they do, but -j
has always seemed to me like a weird choice to turn off the date-setting feature. I’ve decided it stands for Jesus, don’t try to change the date!
The third script in the macro is a Python script to turn the cardinal number (1, 2, 3, etc.) stored in Local Number
into the ordinal number (1st, 2nd, 3rd, etc.) that’s used in the prompt of output window. This is an unnecessary bit of flair that I added to the macro because I already had the code to do it.
python:
#!/usr/bin/env python
import os
n = int(os.environ['KMVAR_Local_Number'])
s = ('th', 'st', 'nd', 'rd') + ('th',)*10
v = n%100
if v > 13:
print(f'{n}{s[v%10]}')
else:
print(f'{n}{s[v]}')
The last two steps of the macro are pretty straightforward. They display the output window and handle whatever button the user presses.
One last thing. If you think I misspelled “past” in the title of this post, you need to clear the X-Men out of your head. There’s a reason the examples get the dates of Tuesday afternoons.
]]>In previous reviews of Mould’s videos (here and here), I did some mechanics analysis to explain the videos in a more detailed (or just plain different) way. I’m not going to do that today, but I do have a brief comment on the question he raises at the end of the video, starting at about the 11:30 mark.
It concerns this mechanism he made with two rods hinged together and connected at their far ends by an elastic band.
Here’s his description:
It gets harder and harder to open this thing up as the elastic becomes more and more stretched. But actually, beyond a certain point it gets easier again. And that’s because of the shallow angle of the elastic. Only a small component of the force from the elastic is perpendicular to the arm. So it gets easier and easier and easier until it passes the pivot point. It’s actually slightly holding it open now. And you only need a really small force to close it again.
Mould felt sure he’d seen this kind of mechanism before, but he couldn’t come up with an example. He asked around and didn’t get any satisfactory answers, probably because he was asking a bunch of physicists and mathematicians.
It’s an over-center mechanism. I can’t think of any engineer or mechanic I’ve ever known who wouldn’t identify it immediately as such. It’s commonly used to latch or lock mechanisms in place. The most obvious example I could get my hands on in a hurry was a pair of vise grips.
As you squeeze the handles together, the mechanism reaches a point where the connecting link that runs between the handles snaps through into the locking position and whatever is between the jaws is held securely with no more effort from the user.
Another example is the latch on my toolbox.^{1}
Here it’s in the not-quite-latched position. When you push the bottom end of the lever the rest of the way in, the inverted U of the clasp squeezes the parts together and moves to the other side of the lever’s pivot point, locking the mechanism in place.
What’s interesting about Mould’s attempts to describe the mechanism is that he very nearly comes up with its name. He says “over the hump” a couple of times, and that is so close to “over center” that I half-expected him to answer the question on his own before the end of the video.
“Over the hump” reminds me of this post (one of my favorites) about the load-deflection curve of a toggle mechanism. Which is also an over-center device.
Why didn’t I notice the latch on the toolbox before I opened it to pull out the vise grips? Because I had vise grips on my mind. ↩
After writing the last post, I decided to do the calculations necessary to make Newmark’s influence chart.
I started with the Boussinesq equation:
$${\sigma}_{z}=\frac{3P}{2\pi}\frac{{z}^{3}}{({r}^{2}+{z}^{2}{)}^{5/2}}$$If you compare this with the formula I gave last time, you’ll see that I’ve deleted the negative sign. That’s because tensile stresses seldom arise in soil mechanics, so the convention is to take compressive stresses as positive.
This is a solution to the elasticity equations in cylindrical coordinates, $(r,\theta ,z)$, where the origin of the coordinate system is at the point on the surface where the load $P$ is applied. Notice that there’s a circular symmetry to the solution—${\sigma}_{z}$ is independent of the angle $\theta $.
This symmetry has an interesting and very useful consequence. We can move the origin of the coordinate system to the point on the surface above the point at which we are calculating the stress, and the formula for ${\sigma}_{z}$ will remain the same. We’ll use this to figure out the stress^{1} associated with a distributed load.
Because Newmark has made his chart as a series of rings split into sectors, we’re going to calculate the stress due to a uniform distributed load, $q$, acting over one of these sectors. The two radii that bound the sector are ${r}_{1}$ and ${r}_{2}$, and the two angles that bound the sector are ${\theta}_{1}$ and ${\theta}_{2}$.
With this loaded area defined, we can write the resulting stress as
$${\sigma}_{z}={\int}_{{\theta}_{1}}^{{\theta}_{2}}{\int}_{{r}_{1}}^{{r}_{2}}\frac{3q}{2\pi}\frac{{z}^{3}}{({r}^{2}+{z}^{2}{)}^{5/2}}r\phantom{\rule{thinmathspace}{0ex}}dr\phantom{\rule{thinmathspace}{0ex}}d\theta $$Because the integrand doesn’t contain $\theta $, that part of the integral will result in a ${\theta}_{2}-{\theta}_{1}$ term, which we’ll call $\Delta \theta $. That term, along with the constants, can be brought outside the integral over $r$:
$${\sigma}_{z}=\frac{3\phantom{\rule{thinmathspace}{0ex}}q\phantom{\rule{thinmathspace}{0ex}}{z}^{3}\phantom{\rule{thinmathspace}{0ex}}\Delta \theta}{2\pi}{\int}_{{r}_{1}}^{{r}_{2}}\frac{r}{({r}^{2}+{z}^{2}{)}^{5/2}}\phantom{\rule{thinmathspace}{0ex}}dr$$If there were an analytical solution to this integral, we’d be in business, but I don’t think there is. I gave the problem to Mathematica, and it thought for over five minutes without coming up with an answer before I stopped it. So we’re going to have to use numerical integration, which means it’s time to nondimensionalize the equation.
First, we note that ${\sigma}_{z}/q$ is nondimensional. This fits in with Newmark’s scheme, because this is what he calls the influence value (see the lower right corner of the chart). So we know this term is going to be 0.001.
$$\frac{{\sigma}_{z}}{q}=0.001=\frac{3\phantom{\rule{thinmathspace}{0ex}}{z}^{3}\phantom{\rule{thinmathspace}{0ex}}\Delta \theta}{2\pi}{\int}_{{r}_{1}}^{{r}_{2}}\frac{r}{({r}^{2}+{z}^{2}{)}^{5/2}}\phantom{\rule{thinmathspace}{0ex}}dr$$Second, we see that Newmark split each ring into an integral number of sectors. The number of sectors isn’t the same for each ring, but we can always say that
$$\Delta \theta =\frac{2\pi}{s}$$where $s$ is a positive integer. Therefore,
$$0.001=\frac{3\phantom{\rule{thinmathspace}{0ex}}{z}^{3}}{s}{\int}_{{r}_{1}}^{{r}_{2}}\frac{r}{({r}^{2}+{z}^{2}{)}^{5/2}}\phantom{\rule{thinmathspace}{0ex}}dr$$Finally, we note that Newmark scales the radii of the rings by the depth, $z$. So we’ll define a new variable, $\rho =r/z$, and rewrite the integral using this change of variable. We see that
$$dr=z\phantom{\rule{thinmathspace}{0ex}}d\rho $$and (this may not be as obvious, but you can check it)
$$({r}^{2}+{z}^{2}{)}^{5/2}={z}^{5}\phantom{\rule{thinmathspace}{0ex}}(1+{\rho}^{2}{)}^{5/2}$$So with these substitutions, we get
$$0.001=\frac{3\phantom{\rule{thinmathspace}{0ex}}{z}^{3}}{s}{\int}_{{\rho}_{1}}^{{\rho}_{2}}\frac{{z}^{2}\phantom{\rule{thinmathspace}{0ex}}\rho}{{z}^{5}\phantom{\rule{thinmathspace}{0ex}}(1+{\rho}^{2}{)}^{5/2}}\phantom{\rule{thinmathspace}{0ex}}d\rho $$Hey, look! The $z$’s all cancel out, and we’re left with
$$\frac{0.001\phantom{\rule{thinmathspace}{0ex}}s}{3}={\int}_{{\rho}_{1}}^{{\rho}_{2}}\frac{\rho}{(1+{\rho}^{2}{)}^{5/2}}\phantom{\rule{thinmathspace}{0ex}}d\rho $$Note that all the terms in this equation are pure numbers; none of them have any units, like feet or meters or pounds. That’s what I meant by “nondimensionalize.”
So now all we have to do is find a sequence of values for ${\rho}_{1}$ and ${\rho}_{2}$ that will solve this equation for the appropriate value of $s$. Starting at the origin of the chart, we know that ${\rho}_{1}=0$ and $s=8$ (you may have to zoom in to see that), and we can solve for ${\rho}_{2}$. Then for the next ring, we use the previously calculated value of ${\rho}_{2}$ as our new value for ${\rho}_{1}$ and set $s=16$. This continues on for all 25 rings in the chart.
The box below should contain the Mathematica notebook I used to do the calculations. If it’s empty, that means the Wolfram Cloud is being slow and stubborn, so you might have better luck following this link. Or not. I don’t have a lot of experience with the Wolfram Cloud, but so far I’ve noticed that it isn’t as responsive as the documentation would have you believe.
Whether you have any experience with Mathematica or not, I think the logic of the notebook is relatively easy to follow. For each pass through the Do
loop, we’re calculating a new upper limit for the numerical integral that solves the equation. That value is then appended to the list of radii and gets used as the lower limit of the numerical integration during the next loop. Finally, the ring thicknesses are calculated by subtraction.
The results are summarized in this table:
Ring | Sectors | Outer radius | Thickness |
---|---|---|---|
1 | 8 | 0.07327 | 0.07327 |
2 | 16 | 0.12778 | 0.05450 |
3 | 24 | 0.18259 | 0.05481 |
4 | 24 | 0.22600 | 0.04342 |
5 | 24 | 0.26382 | 0.03781 |
6 | 48 | 0.33048 | 0.06667 |
7 | 48 | 0.39080 | 0.06032 |
8 | 48 | 0.44807 | 0.05727 |
9 | 48 | 0.50413 | 0.05606 |
10 | 48 | 0.56025 | 0.05612 |
11 | 48 | 0.61747 | 0.05723 |
12 | 48 | 0.67678 | 0.05931 |
13 | 48 | 0.73921 | 0.06243 |
14 | 48 | 0.80596 | 0.06675 |
15 | 48 | 0.87854 | 0.07258 |
16 | 48 | 0.95895 | 0.08041 |
17 | 48 | 1.05003 | 0.09108 |
18 | 48 | 1.15606 | 0.10603 |
19 | 48 | 1.28396 | 0.12790 |
20 | 48 | 1.44608 | 0.16213 |
21 | 48 | 1.66772 | 0.22164 |
22 | 48 | 2.01358 | 0.34586 |
23 | 32 | 2.41493 | 0.40135 |
24 | 32 | 3.31945 | 0.90452 |
25 | 16 | 4.89898 | 1.57953 |
The inner radius of each ring is the outer radius of the ring before it. The exception is the first ring; recall that its inner radius is zero.
My first thought after running out these calculations was to check the numbers against measurements I could take from the chart. They were pretty close. Not perfect, but typically within a couple of percent. I couldn’t really expect any better, as the chart (which is a page from this PDF) wasn’t scanned at a particularly high resolution (only 150 dpi), and it wasn’t perfectly aligned with the scanner (the horizontal axis isn’t quite horizontal).
But would Newmark include a chart without giving the data necessary for readers to reproduce it? Of course not. In the appendix is a table of values for making all the various influence charts discussed in the paper.^{2} Here’s an excerpt from the table that shows the ring radii for the vertical pressure influence chart.
It’s the third column, which gives the radius as a fraction of the depth, $r/z$, that we can compare to the “Outer radius” column in the table above. As you can see, all the numbers match to three decimal places except the one for the 24th ring. Newmark shows 3.315, when the value should be 3.319. Should we blame the student who did the calculations, noted in the acknowledgments as Harold Crate? Should we blame the unacknowledged secretary who typed up Crate’s calculations? No, we have to blame Nate Newmark himself—after all, he’s the guy whose name is mentioned in all the soil mechanics textbooks.
If you haven’t noticed yet, I’m using the words, stress and pressure interchangeably because for this problem they are the same when I’m talking about what’s going on at depth $z$ in the soil. ↩
I’ve only discussed the chart for vertical pressure, but Newmark also provides charts for shear stresses, maximum principal stress, and so on. ↩
In a post this morning, John D. Cook listed several types of partial differential equation that are unusual in that they can be solved analytically. The last one in his list caught my eye because it’s one that I know pretty well from the theory of elasticity: Boussinesq’s equation.
Consider a linearly elastic body with a planar boundary that is infinite in extent below that boundary. Now apply a point load normal to the plane on that boundary:
Figure from Introduction to the Mechanics of a Continuous Medium by Lawrence Malvern
The solution for the vertical stress, ${\sigma}_{z}$, at a depth $z$ and a horizontal distance $r$ from the point of application of load $P$ is
$${\sigma}_{z}=-\frac{3P}{2\pi}\frac{{z}^{3}}{({r}^{2}+{z}^{2}{)}^{5/2}}=-\frac{3P}{2\pi}\frac{{z}^{3}}{{R}^{5}}$$This solution was derived by Joseph Boussinesq in 1885. Geotechnical engineers later found this solution interesting because it gave them an opportunity to calculate subsurface pressures in soil due to the weight of a building founded on that soil. It isn’t perfect because soils aren’t linearly elastic, but it’s a reasonable approach to making estimates, which is what engineering is all about.
Now, the Boussinesq equation is for a point load, and buildings aren’t points—buildings distribute their weight over their foundation footprint. In theory, this isn’t a problem, because we can handle the distributed load by integration. In practice, it’s a pain in the ass, because the integration has to be done numerically for realistic building footprints and, furthermore, has to be done repeatedly for different depths and different locations under the building. A nonstarter in the pre-computer era.
In 1938, Nathan Newmark, then a young professor in the Department of Civil Engineeering at the University of Illinois (my alma mater), came up with a graphical solution to the integration problem. He devised an influence chart that looked like this:
Figure from Engineering Experiment Station Bulletin No. 338
Here’s a more readable view of the scale and other information in the bottom right corner:
To figure out the vertical pressure in the soil at a given depth, you take that depth to be the distance OQ shown above and draw an outline of the foundation plan to that scale on tracing paper. You then put the drawing on the influence chart and position it so that the horizontal position at which you want the soil pressure is at the center of the chart. For example, if our building plan is a fat ell shape, 50′×75′ with a 25′×25′ chunk taken out of the southwest corner, and we want to calculate the soil pressure under the inside corner at a depth of 25′, we take OQ to be 25′, draw an outline of the building to that scale, and place the drawing with the inside corner at the center of the concentric circles. Like this:
Now we count the number of “squares” the building covers and multiply that by two values:
The result is the soil pressure 25′ below the inside corner. To get the pressure at other horizontal positions, we slide the drawing around and count the squares again. To get the pressures at another depth, we redraw the building footprint at a scale appropriate for that depth.^{1}
I’m not saying there isn’t a degree of tedium to this, but it’s a hell of a lot easier than doing multiple numerical integrations on paper with a slide rule and a desk calculator.
The soil pressure influence chart was hardly Newmark’s only contribution to engineering. He was a genius at coming up with alternate ways of seeing problems and devising solution techniques that could be used by everyday engineers working in design offices. Many of these techniques have been superseded by computer-based methods, but at least one—the beta method for structural dynamics problems—is still going strong.
Newmark had moved to emeritus status by the time I was a student; he died during my senior year. The department shut down for a day so the faculty could attend his funeral. Not only had he been their colleague, for many he had been their thesis advisor. This group included my advisor; academically, I am one of Newmark’s many grandchildren.
There’s also a pressure component due to the weight of the soil itself, but that’s just the unit weight of the soil multiplied by the depth. Add that to the value calculated via the influence chart to get the total vertical pressure in the soil. ↩
This morning, I read a short article describing certain deficiencies in Bing Copilot when it comes to doing math. The article interested me for two reasons:
The article investigates three math problems: one having to do with time zones, one an elementary logic problem, and the third a simple calculus problem. At first, I thought the time zone problem wasn’t really a math problem, but I soon learned that it was. McIlroy asked Copilot for the minimum time difference between Oregon and Florida. Copilot knew that both states have two time zones, and it could regurgitate the definition of “minimum,” but it didn’t know how to put those two pieces of information together.
I’ll let you explore the logic problem on your own. Suffice it to say that you shouldn’t worry about beating Copilot in a game of rock-paper-scissors.
The calculus problem was the most complicated: given a general ellipse defined by the usual equation,
$$\frac{{x}^{2}}{{a}^{2}}+\frac{{y}^{2}}{{b}^{2}}=1$$find the points on the ellipse where the magnitude of the slope is one.
McIlroy gave Copilot several opportunities to solve this problem. Although it always got the formula for the slope correct, it failed in different ways each time to apply that formula to the problem at hand.
The value of the article isn’t in simply pointing out that LLMs can be wrong. It’s in McIlroy’s detailed review of Copilot’s answers and where it went wrong in every step. By taking small problems and exploring the errors thoroughly, McIlroy does a better job of finding faults in large language models than any of the broad-brush criticisms I’ve read.
In the notes at the end of the article, McIlroy gives us its editing history. First written in December of last year; last edited just a few days ago. I should mention here that McIlroy will be celebrating his 92nd birthday tomorrow.
]]>A couple of days ago, two tweets appeared in my Mastodon timeline^{1} that got me thinking about how and why I type special characters on my Mac. The first was from Cabel Sasser,
… these are permanently hardwired into my brain: Option-2 for ™, Option-R for ®, Option-G for ©, Option-. for …, and Option-8 for •
and the second was a reply from David Friedman,
Great idea. Personally I use macOS text replacement: hhalf for ½, ccent for ¢, ttm for ™, ccopy for ©, aapple for , bbull for •, etc.
What struck me was that I use a mixture of these two techniques (OK, I use Typinator instead of the macOS’s text replacement system, but the idea is the same).
For example, like Cabel, I type the bullet (•) and ellipsis (…) characters directly; But like David, I use abbreviations (the Typinator term for text substitutions) for the cent (¢), trademark (™), and apple () symbols. Is there any logic to my system?
Certainly, some symbols that I use fairly frequently, like ⌘, ⌥, ⇧, and ⌃, have to be handled by abbreviations because they can’t be typed directly using the Option or Option-Shift keys.
But as you can see, the and ¢ characters can be typed directly. So why don’t I? I guess it comes down to habit. Long, long ago—back in the 80s, before the Mac had text substitutions or abbreviation utilities—I learned how to type certain characters using Option and Option-Shift because I needed them and there was no other way to get them. So bullet (•), degree (°), ellipsis (…), the n- and m-dashes (– and —), and all the curly quotation marks (‘,’,“, and ”) became part of my muscle memory—muscle memory that was somehow retained even after I took an eight-year Mac hiatus in the late 90s and early 00s.
But I never needed ™, ©, or enough to train my fingers how to type them. When I returned to the Mac and started using text expansion utilities,^{2} these were among the special characters I created abbreviations for. Expansion made it unnecessary to learn new key combinations.
There is one special character I’ve recently learned to type directly: Δ. I use this character to delimit equations here on the blog. I wanted something that was easy to type (⌥J) and had a mathy feel to it. So when I want to show something like
$${\int}_{0}^{a}\mathrm{sin}x\phantom{\rule{thinmathspace}{0ex}}dx$$I type
ΔΔ \int_0^a \sin x \, d x ΔΔ
For inline equations I use a single Δ.
I have a feeling many longtime Mac users are like me: some special characters are typed directly, some are done through expansion, and the rest—never used before and never expected to be used again—come through the Character Viewer.
Since Twitter is now X, I feel “tweet” has fallen into the public domain and can be applied to any shortform social media system. ↩
I’ve used TypeIt4Me, TextExpander (originally as Textpander), and now Typinator. ↩