I have decades of consulting experience helping companies solve complex problems involving applied math, statistics, and data privacy.
The RSS's url is : https://www.johndcook.com/blog/feed/
2024-09-17 21:27:02
I recently ran across a theorem connecting the arithmetic mean, geometric mean, harmonic mean, and the golden ratio. Each of these comes fairly often, and there are elegant connections between them, but I don’t recall seeing all four together in one theorem before. Here’s the theorem [1]: The arithmetic, geometric, and harmonic means of two […]
The post Arithmetic, Geometry, Harmony, and Gold first appeared on John D. Cook.2024-09-15 02:30:59
I keep running into Edward John Routh (1831–1907). He is best known for the Routh-Hurwitz stability criterion but he pops up occasionally elsewhere. The previous post discussed Routh’s mnemonic for moments of inertia and his “stretch” theorem. This post will discuss his triangle theorem. Before stating Routh’s theorem, we need to say what a cevian […]
The post Ceva, cevians, and Routh’s theorem first appeared on John D. Cook.2024-09-15 00:08:16
Edward John Routh (1831–1907) came up with a mnemonic for summarizing many formulas for moment of inertia of a solid rotating about an axis through its center of mass. Routh’s mnemonic is I = MS / k where M is the mass of an object, S is the sum of the squares of the semi-axes, […]
The post Moments of inertia mnemonic first appeared on John D. Cook.2024-09-13 22:29:02
I recently came across an upper bound I hadn’t seen before [1]. Given a binomial coefficient C(r, k), let n = min(k, r − k) and m = r − n. Then for any ε > 0, C(n + m, n) ≤ (1 + ε)n + m / εn. The proof follows quickly from applying […]
The post Binomial bound first appeared on John D. Cook.2024-09-10 22:41:11
I was skimming through the book Mathematical Reflections [1] recently. He was discussing a set of generalizations [2] of the Star of David theorem from combinatorics. The theorem is so named because if you draw a Star of David by connecting points in Pascal’s triangle then each side corresponds to the vertices of a triangle. […]
The post Separable functions in different contexts first appeared on John D. Cook.2024-09-08 09:12:54
Body Roundness Index (BRI) is a proposed replacement for Body Mass Index (BMI) [1]. Some studies have found that BRI is a better measure of obesity and a more effective predictor of some of the things BMI is supposed to predict [2]. BMI is based on body mass and height, and so it cannot distinguish […]
The post Body roundness index first appeared on John D. Cook.2024-09-08 06:32:40
I’ve written a couple posts on the approximation by the Indian astronomer Aryabhata (476–550). The approximation is accurate for x in [−π/2, π/2]. The first post collected a Twitter thread about the approximation into a post. The second looked at how far the coefficients in Aryabhata’s approximation are from the optimal approximation as a ratio […]
The post A couple more variations on an ancient theme first appeared on John D. Cook.2024-09-08 03:00:16
Write the letters of the alphabet around a circle, then strike out the letters that are symmetrical about a vertical line. The remaining letters are grouped in clumps of 3, 1, 4, 1, and 6 letters. I’ve heard that this observation is due to Martin Gardner, but I don’t have a specific reference. In case […]
The post Finding pi in the alphabet first appeared on John D. Cook.2024-09-03 20:33:28
A few days ago I wrote about the approximation for cosine due to the Indian astronomer Aryabhata (476–550) and gave this plot of the error. I said that Aryabhata’s approximation is “not quite optimal since the ripples in the error function are not of equal height.” This was an allusion to the equioscillation theorem. Chebyshev […]
The post Optimal rational approximation first appeared on John D. Cook.2024-09-02 09:32:02
As mentioned in the previous post, the ratio of consecutive Fibonacci numbers converges to the golden ratio. Is there a sequence whose ratios converge to the silver ratio the way ratios of Fibonacci numbers converge to the golden ratio? (If you’re not familiar with the silver ratio, you can read more about it here.) The […]
The post Pell is to silver as Fibonacci is to gold first appeared on John D. Cook.2024-09-01 19:41:49
The number of kilometers in a mile is k = 1.609344 which is close to the golden ratio φ = 1.6180334. The ratio of consecutive Fibonacci numbers converges to φ, and so you can approximately convert miles to kilometers by multiplying by a Fibonacci number and dividing by the previous Fibonacci number. For example, you […]
The post Miles to kilometers first appeared on John D. Cook.2024-09-01 01:33:40
This post started out as a Twitter thread. The text below is the same as that of the thread after correcting an error in the first part of the thread. I also added a footnote on a theorem the thread alluded to. *** The following approximation for sin(x) is remarkably accurate for 0 < x […]
The post Ancient accurate approximation for sine first appeared on John D. Cook.2024-08-31 20:16:13
This post will give three ways to multiply by π taken from [1]. Simplest approach Here’s a very simple observation about π : π ≈ 3 + 0.14 + 0.0014. So if you need to multiply by π, you need to multiply by 3 and by 14. Once you’ve multiplied by 14 once, you can […]
The post Mentally multiply by π first appeared on John D. Cook.2024-08-31 19:45:09
For a standard normal random variable Z, the probability that Z exceeds some cutoff z is given by If you wanted to compute this probability numerically, you could obviously evaluate its defining integral numerically. But as is often the case in numerical analysis, the most obvious approach is not the best approach. The range of […]
The post A better integral for the normal distribution first appeared on John D. Cook.2024-08-30 21:09:19
Take a compass and draw a circle on a globe. Then take the same compass, opened to the same width, and draw a circle on a flat piece of paper. Which circle has more area? If the circle is small compared to the radius of the globe, then the two circles will be approximately equal […]
The post Drawing with a compass on a globe first appeared on John D. Cook.2024-08-29 22:54:01
The Poisson probability distribution gives a simple, elegant model for count data. You can even derive from certain assumptions that data must have a Poisson distribution. Unfortunately reality doesn’t often go along with those assumptions. A Poisson random variable with mean λ also has variance λ. But it’s often the case that data that would […]
The post The negative binomial distribution and Pascal’s triangle first appeared on John D. Cook.2024-08-29 20:11:24
It is well known that the harmonic series 1 + ½ + ⅓ + ¼ + … diverges. But if you take the denominators as numbers in base 11 or higher, the series converges [1]. I wonder what inspired this observation. Maybe Brewster was bored, teaching yet another cohort of students that the harmonic series […]
The post A strange take on the harmonic series first appeared on John D. Cook.2024-08-27 00:18:12
Suppose you have two normal random variables, X and Y, and that the variance of X is less than the variance of Y. Let M be an equal mixture of X and Y. That is, to sample from M, you first chose X or Y with equal probability, then you choose a sample from the […]
The post Variance matters more than mean in the extremes first appeared on John D. Cook.2024-08-24 23:52:29
Orbital mechanics is fascinating. I’ve learned a bit about it for fun, not for profit. I seriously doubt Elon Musk will ever call asking me to design an orbit for him. [1] One of the things that makes orbital mechanics interesting is that it can be counter-intuitive. For example, atmospheric friction can make a satellite […]
The post Increasing speed due to friction first appeared on John D. Cook.2024-08-24 21:42:06
Draw a quadrilateral by pick four arbitrary points on a circle and connecting them cyclically. Now multiply the lengths of the pairs of opposite sides. In the diagram below this means multiplying the lengths of the two horizontal-ish blue sides and the two vertical-ish orange sides. Ptolemy’s theorem says that the sum of the two […]
The post Ptolemy’s theorem first appeared on John D. Cook.2024-08-20 22:14:31
There is a simple rule of thumb for converting between (circular) trig identities and hyperbolic trig identities known as Osborn’s rule: stick an h on the end of trig functions and flip signs wherever two sinh functions are multiplied together. Examples For example, the circular identity sin(θ + φ) = sin(θ) cos(φ) + cos(θ) sin(φ) […]
The post Rule for converting trig identities into hyperbolic identities first appeared on John D. Cook.2024-08-19 19:25:29
This weekend I wrote three posts related to interpolation: Compression and interpolation Bessel, Everett, and Lagrange interpolation Binomial coefficients with non-integer arguments The first post looks at reducing the size of mathematical tables by switching for linear to quadratic interpolation. The immediate application is obsolete, but the principles apply to contemporary problems. The second post […]
The post Interpolation and the cotanc function first appeared on John D. Cook.2024-08-19 05:25:38
When n and r are positive integers, with n ≥ r, there is an intuitive interpretation of the binomial coefficient C(n, r), namely the number of ways to select r things from a set of n things. For this reason C(n, r) is usually pronounced “n choose r.” But what might something like C(4.3, 2)? […]
The post Binomial coefficients with non-integer arguments first appeared on John D. Cook.2024-08-19 04:26:42
I never heard of Bessel or Everett interpolation until long after college. I saw Lagrange interpolation several times. Why Lagrange and not Bessel or Everett? First of all, Bessel interpolation and Everett interpolation are not different kinds of interpolation; they are different algorithms for carrying out the same interpolation as Lagrange. There is a unique […]
The post Bessel, Everett, and Lagrange interpolation first appeared on John D. Cook.2024-08-17 20:56:36
Data compression is everywhere. We’re unaware of it when it is done well. We only become aware of it when it is pushed too far, such as when a photo looks grainy or fuzzy because it was compressed too much. The basic idea of data compression is to not transmit the raw data but to […]
The post Compression and interpolation first appeared on John D. Cook.2024-08-16 11:13:39
Forman Acton’s book Numerical Methods that Work describes Chebyschev polynomials as cosine curves with a somewhat disturbed horizontal scale, but the vertical scale has not been touched. The relation between Chebyshev polynomials and cosines is Tn(cos θ) = cos(nθ). Some sources take this as the definition of Chebyshev polynomials. Other sources define the polynomials differently […]
The post Chebyshev polynomials as distorted cosines first appeared on John D. Cook.2024-08-13 23:27:00
The convention in math for writing numbers in bases larger than 10 is to insert capital letters after 9, starting with A. So, for example, the digits in base 12 are 0, 1, 2, …, 9, A, and B. So if you’re familiar with math but not Linux, and you run across the base32 utility, […]
The post Math’s base 32 versus Linux’s base 32 first appeared on John D. Cook.2024-08-11 20:30:08
I don’t use sed very often, but it’s very handy when I do use it, particularly when needing to make a small change to a large file. Fixing a JSON file Lately I’ve been trying to fix a 30 MB JSON file that has been corrupted somehow. The file is one very long line. Emacs […]
The post Editing a file without an editor first appeared on John D. Cook.2024-08-09 11:51:12
Suppose you wanted to approximate Γ(10.3). You know it’s somewhere between Γ(10) = 9! and Γ(11) = 10!, and linear interpolation would give you Γ(10.3) ≈ 0.7 × 9! + 0.3 × 10! = 1342656. But the exact value is closer to 716430.69, and so our estimate is 53% too high. Not a very good […]
The post Interpolating the gamma function first appeared on John D. Cook.2024-08-05 07:05:54
One way to find the volume of a sphere would be to imagine the sphere in a box, randomly select points in the box, and count how many of these points fall inside the sphere. In principle this would work in any dimension. The problem with naive Monte Carlo We could write a program to […]
The post Too clever Monte Carlo first appeared on John D. Cook.