Latest posts
- Aligning one matrix with anotherFeb 11, 2026John
Suppose you have two n × n matrices, A and B, and you would like to find a rotation matrix Ω that lines up B with A. That is, you’d like to find Ω such that A = ΩB. This is asking too much, except in the trivial case of A and B being 1 × 1 matrices. You could […] Aligning one matrix with another first appeared on John D. Cook.
- Computing large Fibonacci numbersFeb 08, 2026John
The previous post discussed two ways to compute the nth Fibonacci number. The first is to compute all the Fibonacci numbers up to the nth iteratively using the defining property of Fibonacci numbers Fn + 2 = Fn + Fn + 1 with extended integer arithmetic. The second approach is to use Binet’s formula Fn = […] Computing large Fibonacci numbers first appeared on John D. Cook.
- Fibonacci numbers and time-space tradeoffsFeb 08, 2026John
A few days ago I wrote about Fibonacci numbers and certificates. As I pointed out in the article, there’s no need to certify Fibonacci numbers, but the point of the post was to illustrate the idea of a solution certificate in a simple context. Practical uses of certificates are more complicated. This time I want […] Fibonacci numbers and time-space tradeoffs first appeared on John D. Cook.
- Minimum of cosine sumFeb 07, 2026John
Suppose f(x) is the sum of terms of the form cos(kx) where k is an integer from a set A with n elements. Then the maximum value of f is f(0) = n. But what is the minimum value of f? The Chowla cosine conjecture says that the minimum should be less than −√n for large n. For now the best […] Minimum of cosine sum first appeared on John D. Cook.
- Eigenvalue homework problems are backwardFeb 06, 2026John
Classroom When you take a linear algebra course and get to the chapter on eigenvalues, your homework problems will include a small matrix A and you will be asked to find the eigenvalues. You do this by computing the determinant det(A − λI) = P(λ) and getting P(λ), a polynomial in λ. The roots of […] Eigenvalue homework problems are backward first appeared on John D. Cook.
- Fibonacci number certificatesFeb 05, 2026John
Suppose I give you a big number F and claim that F is a Fibonacci number. How could you confirm this? Before I go further, let me say what this post is really about. It’s not about Fibonacci numbers so much as it is about proofs and certificates. There’s no market for large Fibonacci numbers, and certainly […] Fibonacci number certificates first appeared on John D. Cook.
- Γ(1/n)Feb 05, 2026John
If n is a positive integer, then rounding Γ(1/n) up to the nearest integer gives n. In symbols, We an illustrate this with the following Python code. >>> from scipy.special import gamma >>> from math import ceil >>> for n in range(1, 101): ... assert(ceil(gamma(1/n)) == n) You can find a full proof in [1]. I’ll […] Γ(1/n) first appeared on John D. Cook.
- Polish serenityFeb 03, 2026John
Yesterday I ran across the following mashup by Amy Swearer of a Polish proverb and the Serenity Prayer. Lord, grant me the serenity to accept when it’s no longer my circus, the courage to control the monkeys that are still mine, and the wisdom to know the difference. The proverb is “Nie mój cyrk, nie […] Polish serenity first appeared on John D. Cook.
- Satellites have a lot of roomFeb 02, 2026John
I saw an animation this morning showing how the space above our planet is dangerously crowded with satellites. That motivated me to do a little back-of-the-envelope math. The vast majority of satellites are in low earth orbit (LEO), which extends from 160 to 2000 km above the earth’s surface. The radius of the earth is […] Satellites have a lot of room first appeared on John D. Cook.
- AGI, ASI, A*I – Do we have all we need to get there?Jan 30, 2026Wayne Joubert
Demis: “[to get to AGI] maybe there’s one or two big innovations needed” Sam: “everything based off what we see today is that it will happen.” Ilya: “But is the belief really that if you just 100x the scale, everything would be transformed? I don’t think that’s true.” Dario: “If you just kind of like […] AGI, ASI, A*I – Do we have all we need to get there? first appeared on John D. Cook.
- Bridging secrets is hardJan 30, 2026John
Cryptocurrency and privacy don’t fit together as easily as you might expect. Blockchains give you the illusion of privacy via pseudonymization: you don’t put your name on a blockchain, but you do put information on a blockchain that can be used to determine your name. Blockchain analysis can often reveal information that no one intended […] Bridging secrets is hard first appeared on John D. Cook.
- Fortunes and Geometric MeansJan 24, 2026John
I saw a post on X recently that said Bill Gates is closer to you in wealth than he is to Elon Musk. Mind blown. For round numbers, let’s say Elon Musk’s net worth is 800 billion and Bill Gates’ net worth is 100 billion. So if your net worth is less 450 billion, the […] Fortunes and Geometric Means first appeared on John D. Cook.
- Proving you know a productJan 24, 2026John
There is a way to prove that you know two numbers a and b, and their product c = ab, without revealing a, b, or c. This isn’t very exciting without more context — maybe you know that 7 × 3 = 21 — but it’s a building block of more interesting zero knowledge proofs, such as proving that a cryptocurrency transaction […] Proving you know a product first appeared on John D. Cook.
- How to prove you know a discrete logarithmJan 23, 2026John
In a high school math class, the solution to the equation bx = y is the logarithm of y in base b. The implicit context of the equation is the real numbers, and the solution is easy to calculate. The same problem in the context of finite groups is called the discrete logarithm problem, and it is difficult […] How to prove you know a discrete logarithm first appeared on John D. Cook.
- Mills ratio and tail thicknessJan 21, 2026John
The Mills ratio [1] is the ratio of the CCDF to the PDF. That is, for a random variable X, the Mills ratio at x is the complementary cumulative distribution function divided by the density function. If the density function of X is f, then The Mills ratio highlights an important difference between the Student […] Mills ratio and tail thickness first appeared on John D. Cook.
- Sigmas and StudentJan 21, 2026John
I saw something yesterday saying that the Japanese bond market had experienced a six standard deviation move. This brought to mind a post I’d written eight years ago. All probability statements depend on a model. And if you’re probability model says an event had a probability six standard deviations from the mean, it’s more likely […] Sigmas and Student first appeared on John D. Cook.
- StylometryJan 20, 2026John
I was reading an article this morning that mentioned a stylometric analysis of a controversial paragraph written by Roman historian Flavius Josephus. I’ve written several posts that could be called stylometry or adjacent, but I haven’t used that word. Here are some posts that touch on the statistical analysis of a text or of an […] Stylometry first appeared on John D. Cook.
- Two cheers for ugly codeJan 19, 2026John
Ugly code may be very valuable, depending on why it’s ugly. I’m not saying that it’s good for code to be ugly, but that code that is already ugly may be valuable. Some of the ugliest code was started by someone who knew the problem domain well but did not know how to write maintainable […] Two cheers for ugly code first appeared on John D. Cook.
- Prime gaps and GapcoinJan 19, 2026John
The previous post looked at tightly clustered primes. This post looks at the opposite, large gaps between primes. Riecoin is a cryptocurrency that uses finding prime clusters as its proof of work task. Gapcoin uses finding prime gaps as its proof of work task. There’s some nuance to defining prime gaps. It’s trivial to produce […] Prime gaps and Gapcoin first appeared on John D. Cook.
- Prime clusters and RiecoinJan 18, 2026John
Prime clusters are sets of primes that appear as close together as is generally possible. There is one pair of consecutive prime numbers, 2 and 3, but there cannot be any more: in any larger pair of consecutive numbers, one of the pair will be even. But there are a lot of twin primes, perhaps infinitely […] Prime clusters and Riecoin first appeared on John D. Cook.
- Efficiently testing multiple primes at onceJan 16, 2026John
The previous post looked at a technique for inverting multiple integers mod m at the same time, using fewer compute cycles than inverting each integer individually. This post will do something analogous for prime chains, revisiting a post from a few days ago about testing prime chains. A prime chain is a sequence of primes in […] Efficiently testing multiple primes at once first appeared on John D
- Tighter bounds in the prime number theoremJan 16, 2026John
The most elementary form of the prime number theorem says that π(x), the number of prime numbers less than x, is asymptotically equal to x / log(x). That’s true, but a more accurate result says π(x) is asymptotically equal to li(x) where Five years ago I wrote about a result that was new at the […] Tighter bounds in the prime number theorem first appeared on John D. Cook.
- Efficiently computing multiple modular inverses at onceJan 14, 2026John
Suppose you have a large prime number M and you need to find the inverse of several numbers mod M. Montgomery’s trick is a way to combine the computation of the inverses to take less time than computing the inverses individually. Peter Montgomery (1947–2020) came up with this trick in 1985. We will illustrate Montgomery’s trick by […] Efficiently computing multiple modular inverses at once first
- The middle binomial coefficientJan 12, 2026John
The previous post contained an interesting observation: Is it true more generally that for large n? Sorta, but the approximation gets better if we add a correction factor. If we square both sides of the approximation and move the factorials to one side, the question becomes whether Now the task becomes to estimate the middle coefficient […] The middle binomial coefficient first appeared on John D.
- Combining in-shuffles and out-shufflesJan 12, 2026John
A few days ago I wrote two posts about perfect shuffles. Once you’ve cut a deck of cards in half, an in-shuffle lets a card from the top half fall first, and an out-shuffle lets a card from the bottom half fall first. Suppose we have a deck of 52 cards. We said in the […] Combining in-shuffles and out-shuffles first appeared on John D. Cook.
- Primecoin primality testJan 10, 2026John
When I wrote about how Primecoin uses prime chains for proof of work, I left out a detail. To mine a new Primecoin block, you have to find a prime chain of specified length that starts with a number that is a multiple of the block header hash. According to the Primecoin whitepaper Another important […] Primecoin primality test first appeared on John D. Cook.
- Bi-twin prime chainsJan 10, 2026John
I mentioned bi-twin prime chains in the previous post, but didn’t say much about them so as not to interrupt the flow of the article. A pair of prime numbers are called twins if they differ by 2. For example, 17 and 19 are twin primes. A bi-twin chain is a sequence of twin primes […] Bi-twin prime chains first appeared on John D. Cook.
- Prime chainsJan 10, 2026John
The title of this post has a double meaning. We will look at chains in the sense of number theory and in the sense of cryptocurrency, i.e. Cunningham chains and blockchains, that involve prime numbers. Cunningham chains A chain of primes is a sequence of prime numbers in which each is almost double its predecessor. […] Prime chains first appeared on John D. Cook.
- Compressing a set of hash valuesJan 09, 2026John
Suppose you have a set of k hash values, each n bits long. Can you compress the set into less than kn bits? It’s not possible to compress a list of hashes into less than kn bits, but you can hash a set into fewer bits. Suppose you have a set of 230, roughly a billion, 64-bit hashes. Sort the […] Compressing a set of hash values first appeared on John D. Cook.
- Memorizing chemical element symbolsJan 07, 2026John
Here’s something I’ve wondered about before: are there good mnemonics for chemical element symbols? Some element symbols are based on Latin or German names and seem arbitrary to English speakers, such as K (kalium) for potassium or Fe (ferrum) for iron. However, these elements are very common and so their names and symbols are familiar. […] Memorizing chemical element symbols first appeared on Joh