Feed john-d-cook John D. Cook

Favorite IconJohn D. Cook

Link https://www.johndcook.com/blog
Feed http://feeds.feedburner.com/TheEndeavour?format=xml
Updated 2025-11-21 09:02
Quantile-quantile plots and powers of 3/2
This post serves two purposes. It will empirically explore a question in number theory and demonstrate quantile-quantile (q-q) plots. It will shed light on a question raised in the previous post. And if you’re not familiar with q-q plots, it will serve as an introduction to such plots. The previous post said that for almost all x > […]
Uniform distribution of powers mod 1
A few days ago I wrote about how powers of the golden ratio are nearly integers but powers of π are not. This post is similar but takes a little different perspective. Instead of looking at how close powers are to the nearest integers, we’ll look at how close they are to their floor, the largest […]
Example of the bike shed principle
One of the case studies in Michael Beirut’s book How to is the graphic design for the planned community Celebration, Florida. The logo for the town’s golf course is an illustration of the bike shed principle. C. Northcote Parkinson observed that it is easier for a committee to approve a nuclear power plant than a bicycle […]
Plastic powers
Last week I wrote a blog post showing that powers of the golden ratio are nearly integers. Specifically, the distance from φn to the nearest integer decreases exponentially as n increases. Several people pointed out that the golden constant is a Pisot number, the general class of numbers whose powers are exponentially close to integers. […]
Visualizing kinds of rings
When I first saw ring theory, my impression was that there were dozens of kinds of rings with dozens of special relations between them—more than I could keep up with. In reality, there just a few basic kinds of rings, and the relations between them are simple. Here’s a diagram that shows the basic kinds of […]
Freudian hypothesis testing
In his paper Mindless statistics, Gerd Gigerenzer uses a Freudian analogy to describe the mental conflict researchers experience over statistical hypothesis testing. He says that the “statistical ritual” of NHST (null hypothesis significance testing) “is a form of conflict resolution, like compulsive hand washing.” In Gigerenzer’s analogy, the id represents Bayesian analysis. Deep down, a […]
Golden powers are nearly integers
This morning I was reading Terry Tao’s overview of the work of Yves Meyer and ran across this line: The powers φ, φ2, φ3, … of the golden ratio lie unexpectedly close to integers: for instance, φ11 = 199.005… is unusually close to 199. I’d never heard that before, so I wrote a little code […]
Antidepressants for van Gogh
In a recent interview, Tyler Cowen discusses complacency, (neruo-)diversity, etc. Let me give you a time machine and send you back to Vincent van Gogh, and you have some antidepressants to make him better. What actually would you do, should you do, could you do? We really don’t know. Maybe he would have had a […]
New podcast interview
Radim Řehůřek of Rare Technologies just posted an interview he and I did a few days ago. We mostly talk about consulting: getting started, finding work, good and bad leads, etc.
Duals and double duals of Banach spaces
The canonical examples of natural and unnatural transformations come from linear algebra, namely the relation between a vector space and its first and second duals. We will look briefly at the finite dimensional case, then concentrate on the infinite dimensional case. Two finite-dimensional vector spaces over the same field are isomorphic if and only if […]
Natural transformations
The ladder of abstractions in category theory starts with categories, then functors, then natural transformations. Unfortunately, natural transformations don’t seem very natural when you first see the definition. This is ironic since the original motivation for developing category theory was to formalize the intuitive notion of a transformation being “natural.” Historically, functors were defined in order […]
Eight Ramanujan posts
Eight short, accessible blog posts based on the work of the intriguing mathematician Srinivasa Ramanujan: Ramanujan series for computing π Ramanujan π approximation Ramanujan’s nested radical Ramanujan approximation for circumference of an ellipse Ramanujan’s most beautiful identity Ramanujan’s factorial approximation Sums of fourth powers Algorithm used for world record pi calculations
Unnatural language processing
Larry Wall, creator of the Perl programming language, created a custom degree plan in college, an interdisciplinary course of study in natural and artificial languages, i.e. linguistics and programming languages. Many of the features of Perl were designed as an attempt to apply natural language principles to the design of an artificial language. I’ve been […]
Complex analysis image quilt
A blog post by Evelyn Lamb yesterday introduced Thomas Baruchel’s web site by of images from complex analysis. I wondered what a collage of these images would look like, so I used the ImageQuilts software by Edward Tufte and Adam Schwartz to create the image below. Related: Applied complex analysis
How areas of math are connected
In my previous post, I discussed how number theory and topology relate to other areas of math. Part of that was to show a couple diagrams from Jean Dieudonné’s book Panorama of Pure Mathematics, as seen by N. Bourbaki. That book has only small star-shaped diagrams considering one area of math at a time. I’ve created a […]
Mathematical balance of trade
Areas of math all draw on and contribute to each other. But there’s a sort of trade imbalance between areas. Some, like analytic number theory, are net importers. Others, like topology, are net exporters. Analytic number theory uses the tools of analysis, especially complex analysis, to prove theorems about integers. The first time you see […]
Improving on the Unix shell
Yesterday I ran across Askar Safin’s blog post The Collapse of the UNIX Philosophy. Two quotes from the post stood out. One was from Rob Pike about the Unix ideal of little tools that each do one job: Those days are dead and gone and the eulogy was delivered by Perl. The other was a […]
Numerically integrating periodic functions
The trapezoid rule is the most obvious numerical integration technique. It comes directly from the definition of a definite integral, just a Riemann sum. It’s a very crude technique in general; you can get much more accuracy with the same number of function evaluations by using a more sophisticated method. But for smooth periodic functions, […]
Are polar coordinates backward?
I’d never given any thought to the order of polar coordinates until yesterday. They’re written (r, θ). That’s just how it is. But a friend pointed out two reasons why this bothers him. First, r is typically a function of θ, just as y is typically a function of x. But in rectangular coordinates, the […]
Function on cover of Abramowitz & Stegun
Someone mailed me this afternoon asking if I knew what function was graphed on the cover of Abramowitz and Stegun’s famous Handbook of Mathematical Functions. Here’s a close-up of the graph from a photo of my copy of A&S. This was my reply. It looks like a complex function of a complex variable. I assume […]
Bessel series for a constant
Fourier series express functions as a sum of sines and cosines of different frequencies. Bessel series are analogous, expressing functions as a sum of Bessel functions of different orders. Fourier series arise naturally when working in rectangular coordinates. Bessel series arise naturally when working in polar coordinates. The Fourier series for a constant is trivial. […]
SHA1 is no longer recommended, but hardly a failure
The web is all abuzz about how SHA1 is “broken”, “a failure,” “obsolete”, etc. It is supposed to be computationally impractical to create two documents that have the same secure hash code, and yet Google has demonstrated that they have done just that for the SHA1 algorithm. I’d like to make two simple observations to […]
Assignment complete, twenty years later
In one section of his book The Great Good Thing, novelist Andrew Klavan describes how he bluffed his way through high school and college, not reading anything he was assigned. He doesn’t say what he majored in, but apparently he got an English degree without reading a book. He only tells of one occasion where […]
Microresumés
I posted a couple things on Twitter today about micro-resumés. First, here’s how I’d summarize my work in a tweet. What I’ve done: Math prof, programmer, statistician What I do now: Consulting #microresume — John D. Cook (@JohnDCook) February 21, 2017 (The formatting is a little off above. It’s leaving out a couple line breaks […]
Visualizing graph spectra like chemical spectra
You can associate a matrix with a graph and find the eigenvalues of that matrix. This gives you a spectrum associated with the graph. This spectrum tells you something about the graph analogous to the way the spectrum of a star’s light tells you something about the chemical composition of the start. So maybe it […]
Simulating seashells
In 1838, Rev. Henry Moseley discovered that a large number of mollusk shells and other shells can be described using three parameters: k, T, and D. First imagine a thin wire running through the coil of the shell. In cylindrical coordinates, this wire follows the parameterization r = ekθ z = Tt If T = 0 this is a […]
Recreating the Vertigo poster
In his new book The Perfect Shape, Øyvind Hammer shows how to create a graph something like the poster for Alfred Hitchcock’s movie Vertigo. Hammer’s code uses a statistical language called Past that I’d never heard of. Here’s my interpretation of his code using Python. import matplotlib.pyplot as plt from numpy import arange, sin, cos, […]
Inverse Fibonacci numbers
As with the previous post, this post is a spinoff of a blog post by Brian Hayes. He considers the problem of determining whether a number n is a Fibonacci number and links to a paper by Gessel that gives a very simple solution: A positive integer n is a Fibonacci number if and only if either 5n2 – […]
Approximate inverse of the gamma function
The other day I ran across a blog post by Brian Hayes that linked to an article by David Cantrell on how to compute the inverse of the gamma function. Cantrell gives an approximation in terms of the Lambert W function. In this post we’ll write a little Python code to kick the tires on […]
How efficient is Morse code?
Morse code was designed so that the most frequently used letters have the shortest codes. In general, code length increases as frequency decreases. How efficient is Morse code? We’ll compare letter frequencies based on Google’s research with the length of each code, and make the standard assumption that a dash is three times as long as a dot. […]
Tidying up trivial details
The following quote gives a good description of the value of abstract mathematics. The quote speaks specifically of “universal algebra,” but consistent with the spirit of the quote you could generalize it to other areas of mathematics, especially areas such as category theory. Universal algebra is the study of features common to familiar algebraic systems […]
Measuring graph robustness
There are a couple ways to measure how well a graph remains connected when nodes are removed. One ways is to consider nodes dropping out randomly. Another way, the one we look at here, assumes an adversary is trying to remove the most well-connected nodes. This approach was defined by Schneider et al [1]. It […]
Data-driven charity
In this post I interview GiveDirectly co-founder Paul Niehaus about charitable direct cash transfers and their empirical approach to charity. JC: Can you start off by telling us a little bit about Give Directly, and what you do? PN: GiveDirectly is the first nonprofit that lets individual donors like you and me send money directly to […]
Big data and the law
Excerpt from the new book Big Data of Complex Networks: Big Data and data protection law provide for a number of mutual conflicts: from the perspective of Big Data analytics, a strict application of data protection law as we know it today would set an immediate end to most Big Data applications. From the perspective of […]
Particle filter and unscented Kalman filter in a nutshell
Suppose you have a linear dynamic system. That is, the function that predicts the next state from the current state to the next is linear. Suppose also that the states in your system are not known precisely but have some uncertainty modeled by a (multivariate) normal distribution. Then the uncertainty in the state at the […]
Heavy-tailed random matrices
Suppose you fill the components of a matrix with random values. How are the eigenvalues distributed? We limit our attention to large, symmetric matrices. We fill the entries of the matrix on the diagonal and above the diagonal with random elements, then fill in the elements below the diagonal by symmetry. If we choose our […]
Simplify integration with complex variables
Last night I was helping my daughter with her calculus homework. One of the problems was the following integral: This is an interesting problem for two reasons. First, it illustrates a clever variation on integration by parts; that’s why it was assigned. But it can also be computed using complex variables. As is often the […]
Sticky cards
Suppose you shuffle a deck of cards. How likely is it that there are two cards that were next to each other before the shuffle are still next to each other after the shuffle? It depends on how well you shuffle the cards. If you do what’s called a “faro shuffle” then the probability of […]
Category Theory and Facebook
From Drew Armstrong’s notes on adjoint functors: Once upon a time, my opinion of category theory was the same as my opinion of Facebook: if I ignore it for long enough, hopefully it will go away. It is now my educated opinion that category theory will not go away, and in fact the language of […]
Infinite primes via Fibonacci numbers
A well-known result about Fibonacci numbers says gcd(Fm, Fn) = Fgcd(m, n) In words, the greatest common divisor of the mth and nth Fibonacci numbers is the gth Fibonacci number where g is the greatest common divisor of m and n. You can find a proof here. M. Wunderlich used this identity to create a short, clever proof that there are infinitely many […]
Safe primes, Sylow theorems, and Cryptography
A logarithm is the inverse of an exponential, and so we can generalize the idea of a logarithm wherever we can generalize the idea of an exponential. In particular, we can raise elements to exponents in a discrete group, and that leads to the definition of a discrete logarithm. Diffie-Hellman public key cryptography is based […]
Automated theorem proving
When I first heard of automated theorem proving, I imagined computers being programmed to search for mathematical theorems interesting to a wide audience. Maybe that’s what a few of the pioneers in the area had in mind too, but that’s not how things developed. The biggest uses for automated theorem proving have been highly specialized […]
Probability of secure hash collisions
A hash function maps arbitrarily long input strings to fixed-length outputs. For example, SHA-256 maps its input to a string of 256 bits. A cryptographically secure hash function h is a one-way function, i.e. given a message m it’s easy to compute h(m) but it’s not practical to go the other way, to learn anything about m from h(m). Secure hash functions are useful for […]
Three proofs that 2017 is prime
Aaron Meurer asked on Twitter whether there’s a proof that 2017 is prime that would fit into 140 characters. My first reply was this: sqrt(2017) < 45. 2017 not divisible by 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, or 43. Ergo prime. I’m not sure that’s what he had […]
Monthly highlights
If you enjoy reading the articles here, you might like a monthly review of the most popular posts. I send out a newsletter at the end of each month. I’ve sent out around 20 so far. They all have two parts: a review of the most popular posts of the month, and a few words […]
Cover time of a graph: cliques, chains, and lollipops
Cover time The cover time of a graph is the expected time it takes a simple random walk on the graph to visit every node. A simple random walk starts at some node, then at each step chooses with equal probability one of the adjacent nodes. The cover time is defined to be the maximum […]
Changing names
I’ve just started reading Laurus, an English translation of a contemporary Russian novel. The book opens with this paragraph. He had four names at various times. A person’s life is heterogeneous, so this could be seen as an advantage. Life’s parts sometimes have little in common, so little that it might appear that various people […]
Bernoulli numbers, Riemann zeta, and strange sums
In the previous post, we looked at sums of the first n consecutive powers, i.e. sums of the form where p was a positive integer. Here we look at what happens when we let p be a negative integer and we let n go to infinity. We’ll learn more about Bernoulli numbers and we’ll see what […]
Sums of consecutive powers
There’s a well-known formula for the sum of the first n positive integers: 1 + 2 + 3 + … + n = n(n + 1) / 2 There’s also a formula for the sum of the first n squares 12 + 22 + 32 + … + n2 = n(n + 1)(2n + 1) / 6 […]
Rapidly mixing random walks on graphs
Random walks mix faster on some graphs than on others. Rapid mixing is one of the ways to characterize expander graphs. By rapid mixing we mean that a random walk approaches its limiting (stationary) probability distribution quickly relative to random walks on other graphs. Here’s a graph that supports rapid mixing. Pick a prime p and label nodes 0, 1, 2, 3, […]
...50515253545556575859...