Back when the US government classified strong encryption as “munitions,” RSA public key cryptography was illegal to export. In 1995, Adam Back protested this by creating a terse, obfuscated implementation of RSA in Perl code and used it as an email signature. The code was also printed on T-shirts. The shirt was classified as munitions […] The post RSA munitions T-shirt first appeared on John D. C…
John D. Cook
Prolog is the original logic programming language. The name comes from programming in logic. More specifically, the name comes from programmation en logique because the inventor of the language, Philippe Roussel, is French. Prolog has its advantages and disadvantages. One of the advantages is that the language represents logical problems directly. One of the disadvantages […] The post Solving a c…

computer-scienceprogramming-languages
I ran an experiment today to see whether Claude could generate Lean code to prove a calculation at the bottom of this post, six lines of calculus. I started with this prompt This page contains a mathematical proof that a Fourier coefficient, a_n, is given in terms of a Bessel function. The LaTeX source for […] The post Formally proving a calculation with Claude and Lean first appeared on John D. …
mathematical-physicsmathematics
Often there’s a thread running through a sequence of my posts. Sometimes I make this explicit and sometimes I don’t. The latest thread started with this post commenting on a tweet that observed that exp(−x²) ≈ (1 + cos(sin(x + x))/2. Some people said online that that the approximation is simply due to the first […] The post Pulling on a thread first appeared on John D. Cook .
Kepler solved his eponymous equation M = E − e sin(E) by finding a fixed point of E = M + e sin(E). So guess a value of E and stick it into the right hand side. Then plug that value into the right hand side again. Kepler said a couple iterations should be enough. And a couple […] The post Aitken acceleration before Aitken first appeared on John D. Cook .
An earlier post discussed how to solve Kepler’s equation M = E − e sin(E) using a sine series. You could also solve Kepler’s equation using a power series, which Lagrange did in 1771. Both approaches express E as a function of e and M, but from different perspectives. Bessel thought of his solution as a sum of sines in […] The post The Laplace limit first appeared on John D. Cook .
I ran across a cranky formula for π based on physical constants here and decided to play around with it. The source describes λ as “wavelength (chosen in the microwave region)” and I thought perhaps you could chose a value of λ to make the equation work. But as a comment pointed out, the bracketed […] The post A crank formula for π first appeared on John D. Cook .
mathematicsnumber-theory
The previous post very briefly said that the integral representation for Bessel functions was motived by solving Kepler’s equation. This post will go into more detail. Kepler’s equation There are multiple ways to describe the position of a planet in an elliptical orbit around a star. For historical reasons, these descriptions have arcane names such […] The post From Kepler to Bessel first appeare…
algebramathematical-physicsmathematics
Yesterday I wrote a post showing that the trapezoid rule evaluates the integral very efficiently. But how do we know what the exact integral is for comparison? If you ask Mathematica, it will tell you the integral equals −2π J1(1) where J1 is a Bessel function. This may seem like rabbit out of a hat, […] The post Mr. Bessel’s eponymous functions first appeared on John D. Cook .
mathematical-physicsmathematics
One reason people study Latin is that it is the ancestor of many modern languages. English derives from West Germanic languages, not from Latin, but much of English vocabulary, perhaps as much as 60%, derives from Latin, either directly or indirectly through French. Knowing a bit of Latin makes sense of many things that would […] The post The Latin of Linux first appeared on John D. Cook .
Several posts lately have looked at the function f(x) = cos(sin(x) + x). This post will look at the function from a different angle. It’s a smooth function with period 2π, and it’s very flat at odd multiples of π, i.e. the first five derivatives are zero. For reasons I wrote about here, this means that […] The post Integrating smooth periodic functions first appeared on John D. Cook .
I was thinking more about the cosine approximation to the Gaussian exp(−z²) ≈ (1 + cos(sin(z) + z))/2 that I wrote about last week. The two expressions above are close along the real axis but not along the imaginary axis. If z = iy, the right side grows much faster than the left, behaving like exp(exp(y)). This led to […] The post Partitions over permutations first appeared on John D. Cook .
Suppose you run across the power series for the exponential function and decide to code it up. Good idea: you’ll probably learn something, though maybe not what you expect. Maybe you decide a tolerance of 10−12 is good enough, and so you sum the terms until the next term to add is below the tolerance. […] The post Naively summing an alternating series first appeared on John D. Cook .
mathematicsnumerical-methods
There is still active discussion on X about the approximation exp(−x²) ≈ (1 + cos(sin(x) + x))/2 and some are saying this can just be explained by Taylor series: the series for the two sides differ for the first time at the x6 term, so that’s why you get a good approximation. As I wrote […] The post It’s not just Taylor series first appeared on John D. Cook .
Readers have subscribed to this blog via email almost from its beginning in 2008, but how they have subscribed has changed several times. I’ve used several services to provide email subscription that have come and gone. For the past two years I’ve been using Substack to send out emails announcing new blog posts. That has […] The post Subscribe by email first appeared on John D. Cook .

The function (1 + cos(x))/2 gives a fair approximation to the Gaussian density exp(−x²) You can make the approximation much better by raising it to a power. The function ((1 + cos(x))/2)4 gives a good lower bound and ((1 + cos(x))/2)3.5597 gives a good upper bound. More on that here. There are other ways of […] The post Another Gaussian approximation first appeared on John D. Cook .
mathematicsprobabilitystatistics
If a polynomial identity holds at a few random points, it’s very like true. We’ll make this statement more precise, but first let’s look at some applications. You may want to test an identity that naturally presents itself as a statement that two polynomials are equal. Or you might use something like the binomial coefficient […] The post Spot checking polynomial identities first appeared on John …
algebramathematics
Canonical example The sample variance of a set of numbers is defined in terms of the sum of the squared distances from each point to the mean. So it would seem that you first need to calculate the mean, then go back and compute the squared differences from the mean. And yet sample variance can […] The post Online (one-pass) algorithms first appeared on John D. Cook .
algorithmscomputer-science
Kullback-Leibler divergence Kullback-Leibler divergence is defined for two random variables X and Y by K-L divergence is non-negative, and it’s zero if and only if X and Y have the same distribution. But it is not a metric, for reasons explained here. For one thing, it’s not symmetric. Jeffreys divergence We can fix the symmetry problem by […] The post Turning K-L divergence into a metric first a…
mathematicsprobabilitystatistics
I saw a post yesterday saying that the Meta logo is a Besace curve. A Besace curve has the implicit form and the parametric form where t ranges over [0, 2π]. So given a Besace curve, such as the Meta logo, how do you find the parameters a and b to fit the curve? We can rewrite […] The post The Meta logo and fitting Besace curves first appeared on John D. Cook .
research.ioSign up to keep scrolling
Create your feed subscriptions, save articles, keep scrolling.
Already have an account?

