2025-12-16 23:49:52
Here’s a curious theorem I stumbled across recently [1]. Take an integer N which is not a multiple of 10. Then there is some multiple of N which only contains the digits 1, 2, 3, 4, and 5.
For example, my business phone number 8324228646 has a couple 8s and a couple 6s. But
6312 × 8324228646 = 52542531213552
which contains only digits 1 through 5.
For a general base b, let p be the smallest prime factor of b. Then for every integer N that is not a multiple of b, there is some multiple of N whose base b representation contains only the digits 1, 2, 3, …, b/p.
This means that for every number N that is not a multiple of 16, there is some k such that the hex representation of kN contains only the digits 1 through 8. For example, if we take the magic number at the beginning of every Java class file, 0xCAFEBABE, we find
1341 × CAFEBABEhex = 42758583546hex.
In the examples above, we’re looking for multiple containing only half the possible digits. If the largest prime dividing the base is larger than 2 then we can find a multiples with digits in a smaller range. For example, in base 35 we can find a multiple containing only the digits 1 through 7.
[1] Gregory Galperin and Michael Reid. Multiples Without Large Digits. The American Mathematical Monthly, Vol. 126, No. 10 (December 2019), pp. 950-951.
The post Multiples with no large digits first appeared on John D. Cook.2025-12-12 23:31:14
The expression
converges to the golden ratio φ. Another way to say this is that the sequence defined by x0 = 1 and
for n > 0 converges to φ. This post will be about how it converges.
I wrote a little script to look at the error in approximating φ by xn and noticed that the error is about three times smaller at each step. Here’s why that observation was correct.
The ratio of the error at one step to the error at the previous step is
If x = φ + ε the expression above becomes
when you expand as a Taylor series in ε centered at 0. This says the error multiplied by a factor of about
at each step. The next term in the Taylor series is approximately −0.03ε, so the exact rate of convergence is a slightly faster at first, but essentially the error is multiplied by 0.309 at each iteration.
The post Golden iteration first appeared on John D. Cook.2025-12-12 02:37:41
When I was a kid, I suppose sometime in my early teens, I was interested in music theory, but I couldn’t play piano. One time I asked a lady who played piano at our church to play a piece of sheet music for me so I could hear how it sounded. The music was in the key of A, but she played it in A♭. She didn’t say she was going to change the key, but I could tell from looking at her hands that she had.

I was shocked by the audacity of changing the music to be what you wanted it to be rather than playing what was on the page. I was in band, and there you certainly don’t decide unilaterally that you’re going to play in a different key!
In retrospect what the pianist was doing makes sense. Hymns are very often in the key of A♭. One reason is it’s a comfortable key for SATB singing. Another is that if many hymns are in the same key, that makes it easy to go from one directly into another. If a traditional hymn is not in A♭, it’s probably in a key with flats, like B♭ or D♭. (Contemporary church music is often in keys with sharps because guitarists like open strings, which leads to keys like A or E.)
The pianist wasn’t a great musician, but she was good enough. Picking her key was a coping mechanism that worked well. Unless someone in the congregation has perfect pitch, you can change a song from the key of D to the key of D♭ and nobody will know.
There’s something to be said for clever coping mechanisms, especially if they’re declared, “You asked for A. Is it OK if I give you B?” It’s better than saying “Sorry, I can’t help you.”
The post Just change the key first appeared on John D. Cook.2025-12-10 23:08:20

Say you have a common 6-sided die and need to roll it until the sum of your rolls is at least 6. How many times would you need to roll?
If you had a 20-sided die and you need to roll for a sum of at least 20, would that take more rolls or fewer rolls on average?
According to [1], the expected number of rolls of an n-sided dice for the sum of the rolls to be n or more equals
So for a 6-sided die, the expected number of rolls is (7/6)5 = 2.1614.
For a 20-sided die, the expected number of rolls is (21/20)19 = 2.5270.
The expected number of rolls is an increasing function of n, and it converges to e.

Here’s a little simulation script for the result above.
from numpy.random import randint
def game(n):
s = 0
i = 0
while s
This produced 2.5273.
[1] Enrique Treviño. Expected Number of Dice Rolls for the Sum to Reach n. American Mathematical Monthly, Vol 127, No. 3 (March 2020), p. 257.
The post Rolling n-sided dice to get at least n first appeared on John D. Cook.
2025-12-10 22:33:53
There are numerous memes floating around with the words “Being weak is nothing to be ashamed of; staying weak is.” Or some variation. I thought about this meme in the context of weak derivatives.

The last couple posts have talked about distributions, also called generalized functions. The delta function, for example, is not actually a function but a generalized function, a linear functional on a space of test functions.
Distribution theory lets you take derivatives of functions that don’t have a derivative in the classical sense. View the function as a regular distribution, take its derivative as a distribution, and if this derivative is a regular distribution, that function is called a weak derivative of the original function.
You can use distribution theory to complete a space of functions analogous to how the real numbers complete the rational numbers.
To show that an equation has a rational solution, you might first show that it has a real solution, then show that the real solution is in fact a rational. To state the strategy more abstractly, to find a solution in a small space, you first look for solutions in a larger space where solutions are easier to find. Then you see whether the solution you found lies in the smaller space.
This is the modern strategy for studying differential equations. You first show that a differential equation has a solution in a weak sense, then if possible prove a regularity result that shows the solution is a classical solution. There’s no shame in finding a weak solution. But from a classical perspective, there’s shame in stopping there.
2025-12-08 23:00:37
The previous post showed how we can take the Fourier transform of functions that don’t have a Fourier transform in the classical sense.
The classical definition of the Fourier transform of a function f requires the integral of |f| over the real line to be finite. This implies f(x) must approach zero as x goes to ∞ and −∞. A constant function won’t do, and yet we got around that in the previous post. Distribution theory even lets you take the Fourier transform of functions that grow as their arguments go off to infinity, as long as they don’t grow too fast, i.e. like a polynomial but not like an exponential.
In this post we want to take the Fourier transform of functions like sine and cosine. If you read that sentence as saying Fourier series, you have the right instinct for classical analysis: you take the Fourier series of periodic functions, not the Fourier transform. But with distribution theory you can take the Fourier transform, unifying Fourier series and Fourier transforms.
For this post I’ll be defining the classical Fourier transform using the convention
and generalizing this definition to distributions as in the previous post.
With this convention, the Fourier transform of 1 is δ, and the Fourier transform of δ is 2π.
One can show that the Fourier transform of a cosine is a sum of delta functions, and the Fourier transform of a sine is a difference of delta functions.
It follows that the Fourier transform of a Fourier series is a sum of delta functions shifted by integers. In fact, if you convert the Fourier series to complex form, the coefficients of the deltas are exactly the Fourier series coefficients.