2026-02-07 22:02:45
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 proven results are much smaller in absolute value [1].
I was playing around with this problem, and the first thing I thought of was to let the set A be the first n primes. This turned out to not be the most interesting example. Since all the primes except for the first are odd, and cos(kπ) = −1 for odd k, the minimum was always approximately −n and always occurred near π [2].
Here’s a plot where A is the set of primes less than 100.

For the cosine conjecture to be interesting, the set A should contain a mix of even and odd numbers.
Here’s a plot with A equal to a random selection of 25 points between 1 and 100. (I chose 25 because there are 25 primes less than 100.)

Here’s the Python code I used to generate the two sets A and the function to plot.
import numpy as np
from sympy import prime
def f(x, A):
return sum([np.cos(k*x) for k in A])
n = 25
A_prime = [prime(i) for i in range(1, n+1)]
np.random.seed(20260207)
A_random = np.random.choice(range(1, 101), size=n, replace=False)
If you wanted to explore the Chowla conjecture numerically, direct use of minimization software is impractical. As you can tell from the plots above, there are a lot of local minima. If the values in A are not too large, you can look at a plot to see approximately where the minimum occurs, then use a numerical method to find the minimum in this region, but that doesn’t scale.
Here’s an approach that would scale better. You could find all the zeros of the derivative of fA and evaluate the function at each. One of these is the minimum. The derivative is a sum of sines with integer frequencies, and so it could be written as a polynomial in z = exp(ix) [3]. You could find all the zeros of this polynomial using the QR algorithm as discussed in the previous post.
[1] Benjamin Bedert. Polynomial bounds for the Chowla cosine problem. arXiv
[2] If A is the set of the first n primes, fA(π) = 2 − n because the sum defining fA(π) has one term equal to 1 and n − 1 terms equal to −1. I think for n ≥ 4 this is the minimum, but I haven’t verified this. If so, the minimum isn’t just near π but exactly at π.
[3] You get a polynomial of degree n in z and 1/z. Then multiply by z2n to get a polynomial in z only of degree 2n.
The post Minimum of cosine sum first appeared on John D. Cook.2026-02-07 07:31:11
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 P are the eigenvalues of A.
Either A will be a 2 × 2 matrix, in which case you can find the roots using the quadratic formula, or the matrix will have been carefully selected so that P(λ) will be easy to factor. Otherwise, finding the roots of a polynomial is hard.
Numerical algorithms to find eigenvalues have gotten really good. In practice, you don’t compute determinants or find roots of polynomials. Instead you do something like the QR algorithm.
Finding all the roots of a polynomial is a challenging problem, and so what you might do in practice is find the roots by constructing a matrix, called the companion matrix, whose eigenvalues correspond to the roots you’re after.
As a classroom exercise, you calculate roots of polynomials to find eigenvalues.
In the real world, you might use an eigenvalue solver to find the roots of polynomials.
I wrote a similar post a few years ago. It explains that textbooks definite hyperbolic functions using ex, but you might want to compute ex using hyperbolic functions.
The post Eigenvalue homework problems are backward first appeared on John D. Cook.2026-02-06 01:14:20
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 no need to quickly verify that a number is a Fibonacci number.
You could write a program to generate Fibonacci numbers, and run it until it either produces F , in which case you know F is a Fibonacci number, or the program produces a larger number than F without having produced F, in which case you know it’s not a Fibonacci number. But there’s a faster way.
A certificate is data that allows you to confirm a solution to a problem in less time, usually far less time, than it took to generate the solution. For example, Pratt certificates give you a way to prove that a number is prime. For a large prime, you could verify its Pratt certificate much faster than directly trying to prove the number is prime.
There is a theorem that says a number f is a Fibonacci number if and only if one of 5f2 ± 4 is a perfect square. So in addition to F another number r that is a certificate that F is a Fibonacci number. You compute
N = 5F² − r²
and if N is equal to 4 or −4, you know that F is a Fibonacci number. Otherwise it is not.
Here’s a small example. Suppose I give you (12586269025, 28143753123) and claim that the first number is a Fibonacci number and the second number is its certificate. You can compute
5 × 12586269025² − 28143753123²
and get −4, verifying the claim.
Certificates are all about the amount of computation the verifier needs to do. The prover, i.e. the person producing the certificate, has to do extra work to provide a certificate in addition to a problem solution. This trade-off is acceptable, for example, in a blockchain where a user posts one transaction but many miners will verify many transactions.
2026-02-05 11:42:12
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 give a partial proof that may be more informative than the full proof.
The asymptotic expansion of the gamma function near zero is
where γ is the Euler-Mascheroni constant.
So when we set z = 1/n we find Γ(1/n) ≈ n − γ + O(1/n²). Since 0 < γ < 1, the theorem above is true for sufficiently large n. And it turns out “sufficiently large” can be replaced with n ≥ 1.
[1] Gamma at reciprocals of integers: 12225. American Mathematical Monthly. October 2022. pp 789–790.
The post Γ(1/n) first appeared on John D. Cook.2026-02-03 20:56:58
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 moje małpy,” literally “Not my circus, not my monkeys”.
The post Polish serenity first appeared on John D. Cook.2026-02-03 03:11:03
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 about 6400 km, so the volume of the LEO region is
There are about 12,500 satellites in LEO, so the average volume of LEO per satellite is about 100,000,000 km³.
Now this isn’t the last word in collision avoidance—there are lots of complications we’re not going to get into here—but it is the first word: there’s a lot of space in space.
The post Satellites have a lot of room first appeared on John D. Cook.