Latest posts
- Shell variable ~-Mar 01, 2026John
After writing the previous post, I poked around in the bash shell documentation and found a handy feature I’d never seen before, the shortcut ~-. I frequently use the command cd - to return to the previous working directory, but didn’t know about ~- as a shotrcut for the shell variable $OLDPWD which contains the […] Shell variable ~- first appeared on John D. Cook.
- Working with file extensions in bash scriptsFeb 28, 2026John
I’ve never been good at shell scripting. I’d much rather write scripts in a general purpose language like Python. But occasionally a shell script can do something so simply that it’s worth writing a shell script. Sometimes a shell scripting feature is terse and cryptic precisely because it solves a common problem succinctly. One example […] Working with file extensions in bash scripts first appear
- Hyperbolic versions of latest postsFeb 26, 2026John
The post A curious trig identity contained the theorem that for real x and y, This theorem also holds when sine is replaced with hyperbolic sine. The post Trig of inverse trig contained a table summarizing trig functions applied to inverse trig functions. You can make a very similar table for the hyperbolic counterparts. The following Python […] Hyperbolic versions of latest posts first appeared o
- Trig of inverse trigFeb 25, 2026John
I ran across an old article [1] that gave a sort of multiplication table for trig functions and inverse trig functions. Here’s my version of the table. I made a few changes from the original. First, I used LaTeX, which didn’t exist when the article was written in 1957. Second, I only include sin, cos, […] Trig of inverse trig first appeared on John D. Cook.
- A curious trig identityFeb 24, 2026John
Here is an identity that doesn’t look correct but it is. For real x and y, I found the identity in [1]. The author’s proof is short. First of all, Then Taking square roots completes the proof. Now note that the statement at the top assumed x and y are real. You can see that this assumption is necessary […] A curious trig identity first appeared on John D. Cook.
- Copy and paste lawFeb 24, 2026John
I was doing some research today and ran into a couple instances where part of one law was copied and pasted verbatim into another law. I suppose this is not uncommon, but I’m not a lawyer, so I don’t have that much experience comparing laws. I do, however, consult for lawyers and have to look […] Copy and paste law first appeared on John D. Cook.
- Giant StepsFeb 23, 2026John
John Coltrane’s song Giant Steps is known for its unusual and difficult chord changes. Although the chord progressions are complicated, there aren’t that many unique chords, only nine. And there is a simple pattern to the chords; the difficulty comes from the giant steps between the chords. If you wrap the chromatic scale around a […] Giant Steps first appeared on John D. Cook.
- Tritone substitutionFeb 23, 2026John
Big moves in roots can correspond to small moves in chords. Imagine the 12 notes of a chromatic scale arranged around the hours of a clock: C at 12:00, C♯ at 1:00, D at 2:00, etc. The furthest apart two notes can be is 6 half steps, just as the furthest apart two times can […] Tritone substitution first appeared on John D. Cook.
- Bitcoin mining difficultyFeb 22, 2026John
The previous post looked at the Bitcoin network hash rate, currently around one zettahash per second, i.e. 1021 hashes per second. The difficulty of mining a Bitcoin block adjusts over time to keep the rate of block production relatively constant, around one block every 10 minutes. The plot below shows this in action. Notice the […] Bitcoin mining difficulty first appeared on John D. Cook.
- Exahash, Zettahash, YottahashFeb 22, 2026John
When I first heard of cryptographic hash functions, they were called “one-way functions” and seemed like a mild curiosity. I had no idea that one day the world would compute a mind-boggling number of hashes every second. Because Bitcoin mining requires computing hash functions to solve proof-of-work problems, the world currently computes around 1,000,000,000,000,000,000,000 hashes, […] Exahash, Ze
- 10,000,000th Fibonacci numberFeb 22, 2026John
I’ve written a couple times about Fibonacci numbers and certificates. Here the certificate is auxiliary data that makes it faster to confirm that the original calculation was correct. This post puts some timing numbers to this. I calculated the 10 millionth Fibonacci number using code from this post. n = 10_000_000 F = fib_mpmath(n) This […] 10,000,000th Fibonacci number first appeared on John D.
- Computing big, certified Fibonacci numbersFeb 21, 2026John
I’ve written before about computing big Fibonacci numbers, and about creating a certificate to verify a Fibonacci number has been calculated correctly. This post will revisit both, giving a different approach to computing big Fibonacci numbers that produces a certificate along the way. As I’ve said before, I’m not aware of any practical reason to […] Computing big, certified Fibonacci numbers firs
- Visualizing orbital velocityFeb 16, 2026John
The shape of a planet’s orbit around a star is an ellipse. To put it another way, a plot of the position of a planet’s orbit over time forms an ellipse. What about the velocity? Is its plot also an ellipse? Surprisingly, a plot of the velocity forms a circle even if a plot of […] Visualizing orbital velocity first appeared on John D. Cook.
- Race between primes of the forms 4k + 1 and 4k + 3Feb 15, 2026John
The last few posts have looked at expressing an odd prime p as a sum of two squares. This is possible if and only if p is of the form 4k + 1. I illustrated an algorithm for finding the squares with p = 2255 − 19, a prime that is used in cryptography. It is being […] Race between primes of the forms 4k + 1 and 4k + 3 first appeared on John D. Cook.
- Wagon’s algorithm in PythonFeb 14, 2026John
The last three posts have been about Stan Wagon’s algorithm for finding x and y satisfying x² + y² = p where p is an odd prime. The first post in the series gives Gauss’ formula for a solution, but shows why it is impractical for large p. The bottom of this post introduces Wagon’s […] Wagon’s algorithm in Python first appeared on John D. Cook.
- Finding a square root of -1 mod pFeb 14, 2026John
If p is an odd prime, there is a theorem that says x² = −1 mod p has a solution if and only if p = 1 mod 4. When a solution x exists, how do you find it? The previous two posts have discussed Stan Wagon’s algorithm for expressing an odd prime p as a […] Finding a square root of -1 mod p first appeared on John D. Cook.
- Finding a non-square mod pFeb 14, 2026John
The previous post briefly mentioned Stan Wagon’s algorithm for expressing an odd prime p as a sum of two squares when it is possible (i.e. when p = 1 mod 4). Wagon’s algorithm requires first finding a non-square mod p, i.e. a number c such that c ≠ d² mod p for any d in 1, […] Finding a non-square mod p first appeared on John D. Cook.
- Expressing a prime as the sum of two squaresFeb 13, 2026John
I saw where Elon Musk posted Grok’s answer to the prompt “What are the most beautiful theorems.” I looked at the list, and there were no surprises, as you’d expect from a program that works by predicting the most likely sequence of words based on analyzing web pages. There’s only one theorem on the list […] Expressing a prime as the sum of two squares first appeared on John D. Cook.
- 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.