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-11 03:16
Why eliminate trusted third parties?
Suppose one company would like to buy another company's client list, but only if the lists don't overlap too much. Neither company wants to hand over their list to the other before a sale takes place. What can they do? A low-tech solution would be for both parties to provide their client lists to a [...]The post Why eliminate trusted third parties? first appeared on John D. Cook.
Discrete Taylor series
Newton's interpolation formula looks awfully complicated until you introduce the right notation. With the right notation, it looks like a Taylor series. Not only is this notation simpler and more memorable, it also suggests extensions. The notation we need comes in two parts. First, we need the forward difference operator defined by and its [...]The post Discrete Taylor series first appeared on John D. Cook.
Podcast feed
The previous post was an AI-generated podcast that I friend made by crawling my web site. I decided to create an actual podcast for posting occasional audio files. I expect to post very sporadically. I've posted two audio files, and I have one more in mind to post some day. Maybe that'll be the end [...]The post Podcast feed first appeared on John D. Cook.
Consulting Podcast
A friend just sent me an audio file of a podcast about my consulting that he created by asking an AI to crawl my web site. The podcast is a remarkably natural-sounding conversation between two synthetic hosts. The only clues that the audio is automatically generated are a couple of mispronounced acronyms. DownloadThe post Consulting Podcast first appeared on John D. Cook.
RSA security in light of news
A recent article reported on the successful factoring of a 512-bit RSA key. The process took $8 worth of rented computing power. What does that say about the security of RSA encryption? The following Python function estimates the computation steps required to factor a number b bits long using the best known algorithm. We're going [...]The post RSA security in light of news first appeared on John D. Cook.
Can AI models reason like a human?
We're awaiting the release of OpenAI's o3 model later this month. Its performance is impressive on very hard benchmarks like SWE-bench Verified, Frontier Math and the ARC AGI benchmark (discussed previously in this blog). And yet at the same time some behaviors of the frontier AI models are very concerning. Their performance on assorted math [...]The post Can AI models reason like a human? first appeared on John D. Cook.
Quick change directory
One difficulty when working at a command line is navigating between directories, particularly between locations with long paths. There are several ways to mitigate this. One of the simplest is using cd - to return to the previous directory. Another is to use pushd and popd. Still another is to set the CDPATH variable. qcd [...]The post Quick change directory first appeared on John D. Cook.
Converse of RSA
The security of RSA encryption depends on the difficulty of factoring the product of two large primes. If you can factor large numbers efficiently, you can break RSA. But if can break RSA, can you factor large numbers? Sorta. It's conceivable that there is a way to break RSA encryption without having to recover the [...]The post Converse of RSA first appeared on John D. Cook.
Unicode Steganography
Steganography attempts to prevent messages from being read by unintended recipients by hiding the messages rather than (or in addition to) encrypting them. Steganography is used when you not only want to keep your communication private, you want to hide the fact that you've communicated at all. Fun fact: The words steganography and stegosaurus are [...]The post Unicode Steganography first appeared on John D. Cook.
Carnival of Mathematics 235
A blog carnival is a way to discover new blogs. Writers on a given topic, such as math, take turns hosting the carnival, featuring recent posts from various writers. Blog carnivals were once much more common, but most have faded away. The Carnival of Mathematics, however, is one of the oldest carnivals and still active, [...]The post Carnival of Mathematics 235 first appeared on John D. Cook.
Up to isomorphism
The previous post showed that there are 10 Abelian groups that have 2025 elements. Implicitly that means there are 10 Abelian groups up to isomorphism, i.e. groups that are not in some sense the same" even if they look different. Sometimes it is clear what we mean by the same" and there's no need to [...]The post Up to isomorphism first appeared on John D. Cook.
Abelian groups of order 2025
Every finite Abelian group can be written as the direct sum of cyclic groups of prime power order. To find the number of Abelian groups of order 2025 we have to find the number of ways to partition the factors of 2025 into prime powers. Now 2025 = 34 * 52. We can partition 34 [...]The post Abelian groups of order 2025 first appeared on John D. Cook.
Cycle of New Year’s Days
Here's a visualization of how the day of the week for New Year's Day changes. The green diamonds represent leap years and the blue squares represent ordinary years. The day of the week for New Year's Day advances one day after each ordinary year and two days after each leap year, hence the diagonal stripes [...]The post Cycle of New Year's Days first appeared on John D. Cook.
Details of generating primes for cryptography
RSA public key cryptography begins by finding a couple large primes. You essentially do this by testing random numbers until you find primes, but not quite. Filippo Valsorda just posted a good article on this. Suppose you're looking for a 1024-bit prime number. You generate random 1024-bit numbers and then test until you find one [...]The post Details of generating primes for cryptography first appeared on John D. Cook.
What exactly is a second?
The previous post looked into the common definition of Unix time as the number of seconds since January 1, 1970 GMT" and why it's not exactly true. It was true for a couple years before we started inserting leap seconds. Strictly speaking, Unix time is the number of non-leap seconds since January 1, 1970. This [...]The post What exactly is a second? first appeared on John D. Cook.
Unix Time and a Modest Proposal
The time it takes earth to orbit the sun is not a simple multiple of the time it takes earth to rotate on its axis. The ratio isn't even constant. The time it takes earth to circle the sun wobbles a bit, and the rotation of the earth is slowing down slightly. The ratio is [...]The post Unix Time and a Modest Proposal first appeared on John D. Cook.
Most popular posts of 2024
I looked at Hacker News to see which posts on this site were most popular. I didn't look at my server logs, but generally the posts that get the most traffic are posts that someone submits to Hacker News. Older posts popular this year Two posts written earlier got a lot of traffic this year, [...]The post Most popular posts of 2024 first appeared on John D. Cook.
Series for the reciprocal of the gamma function
Stirling's asymptotic series for the gamma function is Now suppose you'd like to find an asymptotic series for the function 1/(z). Since the series for has the form f(z) times an infinite sum, it would make sense to look for a series for 1/ of the form 1/f(z) times an infinite sum. The hard [...]The post Series for the reciprocal of the gamma function first appeared on John D. Cook.
Starlink configurations
My nephew recently told me about being on a camping trip and seeing a long line of lights in the sky. The lights turned out to be Starlink satellites. It's fairly common for people report seeing lines of these satellites. Why would the satellites be in a line? Wouldn't it be much more efficient to [...]The post Starlink configurations first appeared on John D. Cook.
Putting a face on a faceless account
I've been playing around with Grok today, logging into some of my X accounts and trying out the prompt Draw an image of me based on my posts." [1] In most cases Grok returned a graphic, but sometimes it would respond with a text description. In the latter case asking for a photorealistic image made [...]The post Putting a face on a faceless account first appeared on John D. Cook.
Can AI models reason: Just a stochastic parrot?
OpenAI has just released its full o1 model-a new kind of model that is more capable of multi-step reasoning than previous models. Anthropic, Google and others are no doubt working on similar products. At the same time, it's hotly debated in many quarters whether AI models actually reason" in a way similar to humans. Emily [...]The post Can AI models reason: Just a stochastic parrot? first appeared on John D. Cook.
Interval arithmetic and fixed points
A couple days ago I analyzed the observation that repeatedly pressing the cosine key on a calculator leads to a fixed point. After about 90 iterations the number no longer changes. This post will analyze the same phenomenon a different way. Interval arithmetic Interval arithmetic is a way to get exact results of a sort [...]The post Interval arithmetic and fixed points first appeared on John D. Cook.
Normal probability approximation
The previous post presented an approximation for -1 x 1 and said that it was related to a probability function. This post will make the connect explicit. LetX be a normally distributed random variable with mean and variance ^2. Then the CDF of X is So if = 0 and ^2 [...]The post Normal probability approximation first appeared on John D. Cook.
Simple error function approximation
I recently ran across the fact that is a remarkably good approximation for -1 x 1. Since the integral above defines the error function erf(x), modulo a constant, this says we have a good approximation for the error function again provided -1 x 1. The error function is closely related to [...]The post Simple error function approximation first appeared on John D. Cook.
Pressing the cosine key over and over
No matter what number you start with, if you press the cos key on a calculator repeatedly, the numbers eventually quit changing. This fact has been rediscovered by countless children playing with calculators. If you start with 0, which is likely the default when you turn on a calculator, you'll hit the final value after [...]The post Pressing the cosine key over and over first appeared on John D. Cook.
Perpetual Calendars
The previous post explained why the Gregorian calendar is the way it is, and that it consists of a whole number of weeks. It follows that the Gregorian calendar repeats itself every 400 years. For example, the calendar for 2025 will be exactly the same as the calendar for 1625 and 2425. There are only [...]The post Perpetual Calendars first appeared on John D. Cook.
Gregorian Calendar and Number Theory
The time it takes for the earth to orbit the sun is not an integer multiple of the time it takes for the earth to rotate on its axis, nor is it a rational number with a small denominator. Why should it be? Much of the complexity of our calendar can be explained by rational [...]The post Gregorian Calendar and Number Theory first appeared on John D. Cook.
Golden hospital gowns
Here's something I posted on X a couple days ago: There's no direct connection between AI and cryptocurrency, but they have a similar vibe. They both leave you wondering whether the emperor is sumptuously clothed, naked, or a mix of both. Maybe he's wearing a hospital gown with gold threads. In case you're unfamiliar with [...]The post Golden hospital gowns first appeared on John D. Cook.
LLMs and regular expressions
Yesterday I needed to write a regular expression as part of a client report. Later I was curious whether an LLM could have generated an equivalent expression. When I started writing the prompt, I realized it wasn't trivial to tell the LLM what I wanted. I needed some way to describe the pattern that the [...]The post LLMs and regular expressions first appeared on John D. Cook.
Coiled logarithmic graph
A logarithmic scale is very useful when you need to plot data over an extremely wide range. However, sometimes even a logarithmic scale may not reduce the visual range enough. I recently saw a timeline-like graph that was coiled into a spiral, packing more information into a limited visual window [1]. I got to thinking [...]The post Coiled logarithmic graph first appeared on John D. Cook.
Solution to a problem of Erdős
How many ways can you select six points in the plane so that every subset of three points forms the vertices of an isosceles triangle? This is a question asked by Erds and recently resolved. One solution is to choose the five vertices of a regular pentagon and the center. It's easy to verify that [...]The post Solution to a problem of Erds first appeared on John D. Cook.
Multiple angles and Osborn’s rule
This post was motivated by an exercise in [1] that says Prove that for the hyperbolic functions ... formulas hold similar to those in Section 2.3 with all the minuses replaced by pluses. My first thought was that this sounds like Osborn's rule, a heuristic for translating between (circular) trig identities and hyperbolic trig identities. [...]The post Multiple angles and Osborn's rule first appeared on John D. Cook.
The vis-viva equation
The vis-viva equation greatly simplifies some calculations in orbital mechanics. It is reminiscent of how conservation of energy can sometimes trivialize what appears to be a complicated problem. In fact, the vis-viva equation is derived from conservation of energy, but the derivation is not trivial. Which is good: the effort required in the derivation implies [...]The post The vis-viva equation first appeared on John D. Cook.
Efficiently transferring to a much higher orbit
The most efficient maneuver for transferring from one circular orbit to another circular orbit of roughly the same size is the Hohmann transfer orbit. It requires two burns: one to leave the initial circular orbit into an elliptical orbit, and another to leave the elliptic orbit for the new circular orbit. If the new orbit [...]The post Efficiently transferring to a much higher orbit first appeared on John D. Cook.
Rotating MacBook keys
Shortly after I started using a MacBook I remapped the keys so that they function the same way on Mac OS, Windows, and Linux. The key in the lower left corner, for example, behaves the same way across operating systems, as does the key to the left of the space bar. Note that I'm going [...]The post Rotating MacBook keys first appeared on John D. Cook.
Asymmetric generation / verification costs
We tend to think that the effort required to generate a solution and verify a solution are roughly equal, assuming that you need to retrace the generation steps to verify that they are correct. But sometimes verification can be far easier than generation [1]. Factoring For example, suppose I generate two 1000-digit prime numbers, multiply [...]The post Asymmetric generation / verification costs first appeared on John D. Cook.
Dogecoin anthem
Someone sent me an AI-generated Dogecoin anthem: To Da Moon. Here's the audio. And here are the lyrics: Yo, it started as a joke, now we in the game, Dogecoin rocket, yeah, remember the name. Crypto vibes, makin' history soon, Strapped to the rocket, we're goin' to the moon. Elon on the tweets, got [...]The post Dogecoin anthem first appeared on John D. Cook.
Blogging pace
When I started this blog, almost 17 years ago, I posted nearly every day. The first time I went a couple days without posting I got a message from someone asking if everything was OK. I've slowed down since then, and even more lately. Last week I was busy with professional work, and this week [...]The post Blogging pace first appeared on John D. Cook.
Confidential OCR
A client emailed me a screenshot of a table rather than pasting the table as text into an email. I thought about using an LLM to convert it to text, but the table is confidential client information and so I shouldn't upload it anywhere. I searched for a command line utility to do OCR and [...]The post Confidential OCR first appeared on John D. Cook.
Perfect numbers
A perfect number is a positive integer equal to the sum of its proper divisors, all divisors less than itself. The first three examples are as follows. 6 = 1 + 2 + 3 28 = 1 + 2 + 4 + 7 + 14 496 = 1 + 2 + 4 + 8 + [...]The post Perfect numbers first appeared on John D. Cook.
Food and Grace
I stumbled on a post on X this morning, a commentary on the photo of RFK eating food from McDonalds that has been making the rounds. This photo divides Puritans from Southerners. Puritans think because RFK Jr is on the side of health food he can never commit such a sin." Southerners think a rare [...]The post Food and Grace first appeared on John D. Cook.
Bluesky account
I've had a Bluesky account for over a year, but never posted much on it. Recently I noticed I'd gotten more followers on Bluesky and thought I might try posting there more often. I am not moving to Bluesky. I have orders of magnitude more followers on X than on Bluesky and so I will [...]The post Bluesky account first appeared on John D. Cook.
The mathematics of GPS
The basic idea of GPS is that if you know the distance to several satellites, you can figure out your position. But you don't actually know, or need to know, the distance to the satellites: you know the time (according to each satellite's clock) when the signals were sent, and you know the time (according [...]The post The mathematics of GPS first appeared on John D. Cook.
GPS satellite orbits
GPS satellites all orbit at the same altitude. According to the FAA, GPS satellites fly in circular orbits at an altitude of 10,900 nautical miles (20,200 km) and with a period of 12 hours. Why were these orbits chosen? You can determine your position using satellites that are not in circular orbits, but with circular [...]The post GPS satellite orbits first appeared on John D. Cook.
Ramanujan’s master theorem
A few weeks ago I wrote about the Mellin transform. Mitchell Wheat left comment saying the transform seems reminiscent of Ramanujan's master theorem, which motivated this post. Suppose you have a function f that is nice enough to have a power series. Now focus on the coefficients ak as a function of k. We'll introduce [...]The post Ramanujan's master theorem first appeared on John D. Cook.
Linear combination of sine and cosine as phase shift
Here's a simple calculation that I've done often enough that I'd like to save the result for my future reference and for the benefit of anyone searching on this. A linear combination of sines and cosines a sin(x) + b cos(x) can be written as a sine with a phase shift A sin(x + ). [...]The post Linear combination of sine and cosine as phase shift first appeared on John D. Cook.
Resolving a mysterious problem with find
Suppose you want to write a shell script searches the current directory for files that have a keyword in the name of the file or in its contents. Here's a first attempt. find . -name '*.py' -type f -print0 | grep -i "$1" find . -name '*.py' -type f -print0 | xargs -0 grep -il [...]The post Resolving a mysterious problem with find first appeared on John D. Cook.
The Postage Stamp Problem
I recently stumbled upon the Postage Stamp Problem. Given two relatively prime positive numbers a and b, show that any sufficiently large number N, there exists nonnegative integers x and y such that ax + by = N. I initially missed the constraint that x and y must be positive, in which result is well [...]The post The Postage Stamp Problem first appeared on John D. Cook.
Impersonating an Edwardian math professor
I've read some math publications from around a century or so ago, and I wondered if I could pull off being a math professor if a time machine dropped me into a math department from the time. I think I'd come across as something of an autistic savant, ignorant of what contemporaries would think of [...]The post Impersonating an Edwardian math professor first appeared on John D. Cook.
Maybe Copernicus isn’t coming
Before Copernicus promoted the heliocentric model of the solar system, astronomers added epicycle on top of epicycle, creating ever more complex models of the solar system. The term epicycle is often used derisively to mean something ad hoc and unnecessarily complex. Copernicus' model was simpler, but it was less accurate. The increasingly complex models before [...]The post Maybe Copernicus isn't coming first appeared on John D. Cook.
...234567891011...