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-24 18:01
Conformal map between square and disk
Conformal maps transform one region into another while preserving angles. You might solve a PDE, for example, by mapping it to a standard region, solving it there, then mapping the solution back to the original region. Some tasks are easier to do in a square and others in a disk, so it’s clearly useful to […]The post Conformal map between square and disk first appeared on John D. Cook.
Conformal map of ellipse interior to a disk
This post will present the conformal map between the interior of an ellipse and the unit disk. Given an ellipse centered at the origin with semi-major axis a and semi-minor axis b. Will will assume without loss of generality that a² – b² = 1 and so the foci are at ±1. Hermann Schwarz published […]The post Conformal map of ellipse interior to a disk first appeared on John D. Cook.
Big correlations and big interactions
An outcome cannot be highly correlated with a large number of independent predictors. This observation has been called the piranha problem. Predictors are compared to piranha fish. If you have a lot of big piranhas in a small pond, they start eating each other. If you have a lot of strong predictors, they predict each […]The post Big correlations and big interactions first appeared on John D. Cook.
Incircle and excircles
An earlier post looked at the nine-point circle of a triangle, a circle passing through nine special points associated with a triangle. Feuerbach’s theorem that says the nine point circle of a triangle is tangent to the incircle and three excircles of the same triangle. The incircle of a triangle is the largest circle that […]The post Incircle and excircles first appeared on John D. Cook.
Double final consonants
I was listening to the latest episode of The History of English podcast and the host talked about rules for when final letters are doubled in English. One of the things he said was that if a consonant is doubled at the end of a word, it’s probably S, L, F, or Z. I tested […]The post Double final consonants first appeared on John D. Cook.
Artemis lunar orbit
I haven’t been able to find technical details of the orbit of Artemis I, and some of what I’ve found has been contradictory, but here are some back-of-the-envelope calculations based on what I’ve pieced together. If someone sends me better information I can update this post. Artemis is in a highly eccentric orbit around the […]The post Artemis lunar orbit first appeared on John D. Cook.
The nine-point circle theorem
The nine-point circle theorem says that for any triangle, there is a circle passing through the following nine points: The midpoints of each side. The foot of the altitude to each side. The midpoint between each vertex and the orthocenter. The orthocenter is the place where the three altitudes intersect. In the image above, the […]The post The nine-point circle theorem first appeared on John D. Cook.
The Möbius Inverse Monoid
I’ve written about Möbius transformations many times because they’re simple functions that nevertheless have interesting properties. A Möbius transformation is a function f : ℂ → ℂ of the form f(z) = (az + b)/(cz + d) where ad – bc ≠ 0. One of the basic properties of Möbius transformations is that they form […]The post The Möbius Inverse Monoid first appeared on John D. Cook.
Locally invertible floating point functions
Is the function x ↦ x + 2 invertible? Sure, its inverse is the function x ↦ x – 2. Is the Python function def f(x): return x + 2 invertible? Not always. You might reasonably think the function def g(x): return x - 2 is the inverse of f, and it is for many […]The post Locally invertible floating point functions first appeared on John D. Cook.
Solving Laplace’s equation in the upper half plane
In the previous post, I said that solving Laplace’s equation on the unit disk was important because the unit disk is a sort of “hub” of conformal maps: there are references and algorithms for mapping regions to and from a disk conformally. The upper half plane is a sort of secondary hub. You may want […]The post Solving Laplace’s equation in the upper half plane first appeared on John D. Cook.
Solving Laplace’s equation on a disk
Why care about solving Laplace’s equation on a disk? Laplace’s equation is important in its own right—for example, it’s important in electrostatics—and understanding Laplace’s equation is a stepping stone to understanding many other PDEs. Why care specifically about a disk? An obvious reason is that you might need to solve Laplace’s equation on a disk! […]The post Solving Laplace’s equation on a disk first appeared on John D. Cook.
Posts on ellipses and elliptic integrals
I wrote a lot of posts on ellipses and related topics over the last couple months. Here’s a recap of the posts, organized into categories. Basic geometry Eccentricity, flattening, and aspect ratio Latus rectum Directrix Example of a highly elliptical orbit More advanced geometry Pascal’s theorem Intersection of two conics Determining conic sections by points […]The post Posts on ellipses and elliptic integrals first appeared on John D. Cook.
Design of experiments and design theory
Design of experiments is a branch of statistics, and design theory is a branch of combinatorics, and yet they overlap quite a bit. It’s hard to say precisely what design theory is, but it’s consider with whether objects can be arranged in certain ways, and if so how many ways this can be done. Design […]The post Design of experiments and design theory first appeared on John D. Cook.
Repunits: primes and passwords
A repunit is a number whose base 10 representation consists entirely of 1s. The number consisting of n 1s is denoted Rn. Repunit primes A repunit prime is, unsurprisingly, a repunit number which is prime. The most obvious example is R2 = 11. Until recently the repunit numbers confirmed to be prime were Rn for […]The post Repunits: primes and passwords first appeared on John D. Cook.
Recent posts on solving equations
I’ve written several blog posts about equation solving recently. This post will summarize how in hindsight they fit together. Trig equations How to solve trig equations in general, and specifically how to solve equations involving quadratic polynomials in sine and cosine. Polynomial equations This weekend I wrote about a change of variables to “depress” a […]The post Recent posts on solving equations first appeared on John D. Cook.
Expert witness experiences
The world of expert testimony seems mysterious from the outside, so I thought some readers would find it interesting to have a glimpse inside. Kinds of experts There are two kinds of experts, consulting experts and testifying experts. These names mean what they say: consulting experts consult with their clients, and testifying experts testify. Usually […]The post Expert witness experiences first appeared on John D. Cook.
Eliminating terms from higher-order differential equations
This post ties together two earlier posts: the previous post on a change of variable to remove a term from a polynomial, and an older post on a change of variable to remove a term from a differential equation. These are different applications of the same idea. A linear differential equation can be viewed as […]The post Eliminating terms from higher-order differential equations first appeared on John D. Cook.
How to depress a general polynomial
This post showed how to do a change of variables to remove the quadratic term from a cubic equation. Here we will show that the technique works more generally to remove the xn-1 term from an nth degree polynomial. We will use big-O notation O(xk) to mean terms involving x to powers no higher than […]The post How to depress a general polynomial first appeared on John D. Cook.
How to solve a cubic equation
The process for solving a cubic equation seems like a sequence of mysterious tricks. I’d like to try to make the steps seem a little less mysterious. Depressed cubic The previous post showed how to reduce a general cubic equation to one in the form which is called a “depressed cubic.” In a nutshell, you […]The post How to solve a cubic equation first appeared on John D. Cook.
How to depress a cubic
The title of this post sounds like the opening to a bad joke: How do you depress a cubic? … Insert your own punch line. A depressed cubic is a simplified form of a cubic equation. The odd-sounding terminology suggests that this is a very old idea, older than the current connotation of the word […]The post How to depress a cubic first appeared on John D. Cook.
New SI prefixes and their etymology
Five months ago I wrote a post speculating about new SI prefixes. I said in this post “There’s no need for more prefixes; this post is just for fun.” Well, truth is stranger than fiction. There are four new SI prefixes. These were recently approved at the 27th General Conference on Weights and Measures. Here […]The post New SI prefixes and their etymology first appeared on John D. Cook.
Calculating sine to an absurd number of digits
Suppose you wanted to calculate sin(x) to a million decimal places using a Taylor series. How many terms of the series would you need? You can use trig identities to reduce the problem to finding sin(x) for |x| ≤ 1. Let’s take the worst case and assume we want to calculate sin(1). The series for […]The post Calculating sine to an absurd number of digits first appeared on John D. Cook.
Simple example of Kleisli composition
When a program needs to work with different systems of units, it’s best to consistently use one system for all internal calculations and convert to another system for output if necessary. Rigidly following this convention can prevent bugs, such as the one that caused the crash of the Mars Climate Orbiter. For example, maybe you […]The post Simple example of Kleisli composition first appeared on John D. Cook.
Getting pulled back in
“Just when I thought I was out, they pull me back in.” — Michael Corleone, The Godfather, Part 3 My interest in category theory goes in cycles. Something will spark my interest in it, and I’ll dig a little further. Then I reach my abstraction tolerance and put it back on the shelf. Then sometime […]The post Getting pulled back in first appeared on John D. Cook.
Exploring bad passwords
If your password is in the file rockyou.txt then it’s a bad password. Password cracking software will find it instantly. (Use long, randomly generated passwords; staying off the list of worst passwords is necessary but not sufficient for security.) The rockyou.txt file currently contains 14,344,394 bad passwords. I poked around in the file and this […]The post Exploring bad passwords first appeared on John D. Cook.
When a cubic or quartic has a double root
Thanks to the quadratic equation, it’s easy to tell whether a quadratic equation has a double root. The equation has a double root if and only if the discriminant is zero. The discriminant of a cubic is much less known, and the analogs for higher order polynomials are unheard of. There is a discriminant for […]The post When a cubic or quartic has a double root first appeared on John D. Cook.
Entropy of a Student t distribution
I was looking up the entropy of a Student t distribution and something didn’t seem right, so I wanted to look at familiar special cases. The Student t distribution with ν degrees of freedom has two important special cases: ν = 1 and ν = ∞. When ν = 1 we get the Cauchy distribution, […]The post Entropy of a Student t distribution first appeared on John D. Cook.
Solving quadratic trig equations
A few days ago I wrote about how to systematically solve trig equations. That post was abstract and general. This post will be concrete and specific, looking at the special case of quadratic equations in sines and cosines, i.e. any equation of the form As outlined earlier, we turn the equation into a system of equations […]The post Solving quadratic trig equations first appeared on John D. Cook.
Simultaneous root-finding
In 1891 Karl Weierstrass developed a method for numerically finding all the roots of a polynomial at the same time. True to Stigler’s law of eponymy this method is known as the Durand-Kerner method, named after E. Durand who rediscovered the method in 1960 and I. Kerner who discovered it yet again in 1966. The […]The post Simultaneous root-finding first appeared on John D. Cook.
Mercator and polar projections
This post is a more quantitative version of the previous post. Before I said that straight lines on a Mercator projection map correspond to loxodrome spirals on a sphere. This post will make that claim more explicit. So suppose we plot a straight path from Quito to Jerusalem on a Mercator projection. The red dot […]The post Mercator and polar projections first appeared on John D. Cook.
Straight on a map or straight on a globe?
Straight lines on a globe are not straight on a map, and straight lines on a map are not straight on a globe. A straight line on a globe is an arc of a great circle, the shortest path between two points. When projected onto a map, a straight path looks curved. Here’s an image […]The post Straight on a map or straight on a globe? first appeared on John D. Cook.
Elliptic coordinates and Laplace’s equation
In rectangular coordinates, constant values of x are vertical lines and constant values of y are horizontal lines. In polar coordinates, constant values of r are circles and constant values of θ are lines from the origin. In elliptic coordinates, the position of a point is specified by two numbers, μ and ν. Constant values […]The post Elliptic coordinates and Laplace’s equation first appeared on John D. Cook.
Computing arccos
Suppose you take two numbers, a and b, and repeatedly take their arithmetic mean and their geometric mean. That is, suppose we set a0 = a b0 = b then a1 = (a0 + b0)/2 b1 = √(a0 b0) and repeat this process, each new a becoming the arithmetic mean of the previous a and […]The post Computing arccos first appeared on John D. Cook.
Three diagrams
This post will give examples of three similar diagrams that occur in three dissimilar areas: design of experiments, finite difference methods for PDEs, and numerical integration. Central Composite Design (CCD) The most popular design for fitting a second-order response surface is the central composite design or CCD. When there are two factors being tested, the […]The post Three diagrams first appeared on John D. Cook.
Carlson’s elliptic integrals
Although its a little fuzzy to say exactly which functions are “special” functions, these are generally functions that come up frequently in applications, that have numerous symmetries, and that satisfy many useful identities. The copious interconnections between special functions that are part of what makes them special also makes these functions hard to organize: everything […]The post Carlson’s elliptic integrals first appeared on John D. Cook.
Kinds of elliptic integrals
There are three fundamental kinds of elliptic integrals, and these are prosaically but unhelpfully called elliptic integrals of the first kind, the second kind, and the third kind. These names sound odd to modern ears, but it’s no different than classical musicians naming symphonies Symphony No. 1, Symphony No. 2, etc. This post covers the […]The post Kinds of elliptic integrals first appeared on John D. Cook.
Three interesting curves
Here are three curves that have interesting names and interesting shapes. The fish curve The fish curve has parameterization x(t) = cos(t) – sin²(t)/√2 y(t) = cos(t) sin(t) We can plot this curve in Mathematica with ParametricPlot[ {Cos[t] - Sin[t]^2/Sqrt[2], Cos[t] Sin[t]}, {t, 0, 2 Pi}] to get the following. It’s interesting that the image […]The post Three interesting curves first appeared on John D. Cook.
What is a Pentanomial GFSR random number generator?
The ISO random number generation standard, ISO 28640, speaks of a “Pentanomial GFSR method” for generating random variates. What is this? We’ll break it down, starting with GFSR. GFSR In short, a GFSR random number generator is what is now more commonly called a linear feedback shift register, or LFSR. The terminology “GFSR” was already […]The post What is a Pentanomial GFSR random number generator? first appeared on John D. Cook.
Systematically solving trigonometric equations
Students are asked to solve trigonometric equations shortly after learning what sine and cosine are. By some combination of persistence and luck they may be able to find a solution. After proudly presenting the solution to a teacher, the teacher may ask “Is that the only solution?” A candid student would respond by saying “How […]The post Systematically solving trigonometric equations first appeared on John D. Cook.
Nephroids and evolutes
The previous post looked at the evolute of an ellipse. This post will look at evolutes more generally, and then look at nephroids. As a quick reminder, given a curve curve c, a point on its evolute is the center of curvature for a point on c. See the previous post for a detailed example. […]The post Nephroids and evolutes first appeared on John D. Cook.
Evolute of an ellipse
Suppose you’re standing on an ellipse. (You actually are: lines of longitude are elliptical because of earth’s equatorial bulge.) Now draw a line perpendicular to where you’re standing. Lines of longitude are nearly circles, but we’ll look at a more obviously elliptical ellipse. The line is perpendicular to the northeast side of the ellipse where […]The post Evolute of an ellipse first appeared on John D. Cook.
Newton’s method: The Good, The Bad, and The Ugly
This post will give examples where Newton’s method gives good results, bad results, and really bad results. Our example problem is to solve Kepler’s equation M = E – e sin E for E, given M and e, assuming 0 ≤ M ≤ π and 0 < e < 1. We will apply Newton’s method […]The post Newton’s method: The Good, The Bad, and The Ugly first appeared on John D. Cook.
Uniform sampling from an ellipse
There is a simple way to randomly sample points from an ellipse, but it is not uniform. Assume your ellipse is parameterized by with t running from 0 to 2π. The naive approach would be to take uniform samples from t and stick them into the equations above. Rather than looking at random sampling, this […]The post Uniform sampling from an ellipse first appeared on John D. Cook.
How to calculate length of an elliptic arc
This post will show how to find the length of piece of an ellipse and explain what elliptic integrals have to do with ellipses. Assume we have an ellipse centered at the origin with semi-major axis a and semi-minor axis b. So a > b > 0, the longest diameter of the ellipse is 2a […]The post How to calculate length of an elliptic arc first appeared on John D. Cook.
Python code to solve Kepler’s equation
The previous post looked at solving Kepler’s equation using Newton’s method. The problem with using Newton’s method is that it may not converge when the eccentricity e is large unless you start very close to the solution. As discussed at the end of that post, John Machin came up with a clever way to start […]The post Python code to solve Kepler’s equation first appeared on John D. Cook.
Solving Kepler’s equation with Newton’s method
In the introduction to his book Solving Kepler’s Equation Over Three Centuries, Peter Colwell says In virtually every decade from 1650 to the present there have appeared papers devoted to the Kepler problem and its solution. This is remarkable because Kepler’s equation isn’t that hard to solve. It cannot be solved in closed form using […]The post Solving Kepler’s equation with Newton’s method first appeared on John D. Cook.
The world is lumpy
The Pareto principle, or the 80-20 rule, says that 80% of output comes from 20% of inputs. For example, maybe the top 20% of salesmen generate 80% of a company’s revenue. For some reason, the Pareto principle angers some people. Mention the Pareto principle and someone will explain why it can’t be true, based on […]The post The world is lumpy first appeared on John D. Cook.
Another problem with A/B testing: interaction effects
The previous post looked at a paradox with A/B testing: your final result may depend heavily on the order of your tests. This post looks at another problem with A/B testing: the inability to find interaction effects. Suppose you’re debating between putting a photo of a car or a truck on your web site, and […]The post Another problem with A/B testing: interaction effects first appeared on John D. Cook.
A/B testing and a voting paradox
One problem with A/B testing is that your results may depend on the order of your tests. Suppose you’re testing three options: X, Y, and Z. Let’s say you have three market segments, equal in size, each with the following preferences. Segment 1: X > Y > Z. Segment 2: Y > Z > X. Segment […]The post A/B testing and a voting paradox first appeared on John D. Cook.
Smoothly extending arctan(k tan(t))
I wrote a while back about the function f(t) = arctan(k tan(t)). I keep running into this function. Has anybody given this function a name or studied it? The direct implementation has a discontinuity at π/2 but I needed to extend it continuously. Using the two-argument version of inverse tangent fixes this. In Python, the […]The post Smoothly extending arctan(k tan(t)) first appeared on John D. Cook.
...17181920212223242526...