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-09-12 01:46
Saxophone with two octave keys
Last year I wrote a post about saxophone octave keys. I was surprised to discover, after playing saxophone for most of my life, that a saxophone has not one but two octave holes. Modern saxophones have one octave key, but two octave holes. Originally saxophones had a separate octave key for each octave hole; you had to […]
Listening to golden angles
The other day I wrote about the golden angle, a variation on the golden ratio. If φ is the golden ratio, then a golden angle is 1/φ2 of a circle, approximately 137.5°, a little over a third of a circle. Musical notes go around in a circle. After 12 half steps we’re back where we […]
Color theory questions
Here’s a script I wanted to write: given a color c specified in RGB and an angle θ, rotate c on the color wheel by θ and return the RGB value of the result. You can’t rotate RGB values per se, but you can rotate hues. So my initial idea was to convert RGB to […]
A sixth sense for category theory
From Paul Phillips: I see adjoint functors. How often do you see them? All the time. They’re everywhere. pic.twitter.com/6PkGJ9wP4A — Paul Phillips (@contrarivariant) May 27, 2017 Mashup of Saunders Mac Lane’s quip “Adjoint functors arise everywhere” and Haley Joel Osment’s famous line from Sixth Sense. Related: Applied category theory
Student’s future, teacher’s past
“Teachers should prepare the student for the student’s future, not for the teacher’s past.” — Richard Hamming I ran across the above quote from Hamming this morning. It made me wonder whether I tried to prepare students for my past when I used to teach college students. How do you prepare a student for the […]
Ideal background for algebraic geometry
From Foundations of Algebraic Geometry: … in an ideal world, people would learn this material over many years, after having background courses in commutative algebra, algebraic topology, differential geometry, complex analysis, homological algebra, number theory, and French literature.
Changing your mind
From Dorothy Sayers’ essay Why Work? It is always strange and painful to have to change a habit of mind; though, when we have made the effort, we may find a great relief, even a sense of adventure and delight, in getting rid of the false and returning to the true.
Volume of a rose-shaped torus
Start with a rose, as described in the previous post: Now spin that rose around a vertical line a distance R from the center of the rose. This makes a torus (doughnut) shape whose cross sections look like the rose above. You could think of having a cutout shaped like the rose above and extruding Play-Doh […]
Length of a rose
The polar graph of r = cos(kθ) is called a rose. If k is even, the curve will trace out 2k petals as θ runs between 0 and 2π. If k is odd, it will trace out k petals, tracing each one twice. For example, here’s a rose with k = 5. (I rotated the […]
When length equals area
The graph of hyperbolic cosine is called a catenary. A catenary has the following curious property: the length of a catenary between two points equals the area under the catenary between those two points. The proof is surprisingly simple. Start with the following: Now integrate the first and last expressions between two points a and […]
Solving systems of polynomial equations
In a high school algebra class, you learn how to solve polynomial equations in one variable, and systems of linear equations. You might reasonably ask “So when do we combine these and learn to solve systems of polynomial equations?” The answer would be “Maybe years from now, but most likely never.” There are systematic ways to […]
Generating pink noise
Different colors of noise are named by analogy with colors of light. Pink noise is between white noise and red noise. White noise has equal power at all frequencies, just as white light is a combination of all the frequencies of the visible spectrum. The components of red noise are weighted toward low frequencies, just […]
Building software the right way
Yesterday a friend told me about a software project whose owners said “We’re going to do this the right way.” I told him I have two opposite reactions when I hear that: Ooh, that sounds like fun! Run away! I’ve been on several projects where the sponsors have identified some aspect of the status quo […]
The 3n+1 problem and Benford’s law
This is the third, and last, of a series of posts on Benford’s law, this time looking at a famous open problem in computer science, the 3n + 1 problem, also known as the Collatz conjecture. Start with a positive integer n. Compute 3n + 1 and divide by 2 repeatedly until you get an odd […]
Cauchy, Benford, and a problem with NHST
Introduction Samples from a Cauchy distribution nearly follow Benford’s law. I’ll demonstrate this below. The more data you see, the more confident you should be of this. But with a typical statistical approach, crudely applied NHST (null hypothesis significance testing), the more data you see, the less convinced you are. This post assumes you’ve read the […]
Weibull distribution and Benford’s law
Introduction to Benford’s law In 1881, Simon Newcomb noticed that the edges of the first pages in a book of logarithms were dirty while the edges of the later pages were clean. From this he concluded that people were far more likely to look up the logarithms of numbers with leading digit 1 than of […]
Golden angle
The golden angle is related to the golden ratio, but it is not as well known. And the relationship is not quite what you might think at first. The golden ratio φ is (1 + √5)/2. A golden rectangle is one in which the ratio of the longer side to the shorter side is φ. […]
What personality classifications have in common
There are many ways to divide people into four personality types, from the classical—sanguine, choleric, melancholic, and phlegmatic—to contemporary systems such as the DISC profile. The Myers-Briggs system divides people into sixteen personality types. I just recently ran across the “enneagram,” an ancient system for dividing people into nine categories. There’s one thing advocates of […]
Denver airport, Weierstrass, and A&S
Last night I was driving toward the Denver airport and the airport reminded me of the cover of Abramowitz and Stegun’s Handbook of Mathematical Functions. Here’s the airport: And here’s the book cover: I’ve written about the image on book cover before. Someone asked me what function it graphed and I decided it was probably […]
Resisting simplicity
As much as we admire simplicity and strive for simplicity, something in us isn’t happy when we achieve it. Sometimes we’re disappointed with a simple solution because, although we don’t realize it yet, we didn’t properly frame the problem it solves. I’ve been in numerous conversations where someone says effectively, “I understand that 2+3 = […]
Flying through a 3D fractal
A Menger sponge is created by starting with a cube a recursively removing chunks of it. Draw a 3×3 grid on one face of the cube, then remove the middle square, all the way through the cube. Then do the same for each of the eight remaining squares. Repeat this process over and over, and do it […]
Computing harmonic numbers
The harmonic numbers are defined by Harmonic numbers are sort of a discrete analog of logarithms since As n goes to infinity, the difference between Hn and log n is Euler’s constant γ = 0.57721… [1] How would you compute Hn? For small n, simply use the definition. But if n is very large, there’s a way […]
Technical notes and other relatively hidden content
I’ve written quite a few pages that are separate from the timeline of the blog. These are a little hidden, not because I want to hide them, but because you can’t make everything equally easy to find. These notes cover a variety of topics: Math diagrams Numerical computing Probability and approximations Differential equations Python Regular expressions […]
New Twitter icons
I’ve updated the icons for my Twitter accounts.
Mercury and the bandwagon effect
The study of the planet Mercury provides two examples of the bandwagon effect. In her new book Worlds Fantastic, Worlds Familiar, planetary astronomer Bonnie Buratti writes The study of Mercury … illustrates one of the most confounding bugaboos of the scientific method: the bandwagon effect. Scientists are only human, and they impose their own prejudices […]
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 […]
...48495051525354555657...