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 11:47
Mentally calculating the day of the week in 2023
Mentally calculating the day of the week will be especially easy in 2023. The five-step process discussed here reduces to three steps in 2023. One of the steps involves leap years, and 2023 is not a leap year. Another step involves calculating and adding in the “year share,” and the year share for 2023 is […]The post Mentally calculating the day of the week in 2023 first appeared on John D. Cook.
Jacobi functions with complex parameter
Jacobi functions are complex-valued functions of a complex variable z and a parameter m. Often this parameter is real, and 0 ≤ m < 1. Mathematical software libraries, like Python’s SciPy, often have this restriction. However, m could be any complex number. The previous couple of posts spoke of the fundamental rectangle for Jacobi functions. […]The post Jacobi functions with complex parameter first appeared on John D. Cook.
Conformal map from rectangles to half plane
As discussed in the previous post, the Jacobi elliptic function sn(z, m) is doubly periodic in the complex plane, with period 4K(m) in the horizontal direction and period 2K(1-m) in the vertical direction. Here K is the complete elliptic integral of the first kind. The function sn(z, m) maps the rectangle (-K(m), K(m)) × (0, K(1-m)) […]The post Conformal map from rectangles to half plane first appeared on John D. Cook.
Solve for Jacobi sn parameter to have given period(s)
Here’s a calculation that I’ve had to do a few times. I’m writing it up here for my future reference and for the benefit of anybody else who needs to do the same calculation. The Jacobi sn function is doubly periodic: it has one period as you move along the real axis and another period […]The post Solve for Jacobi sn parameter to have given period(s) first appeared on John D. Cook.
Why determinants with columns of ones?
Geometric equations often involve a determinant with a column of 1s. For example, the equation of a line through two points or a circle through three points Or a general conic section through five points Why all the determinants and why all the 1s? When you see a determinant equal to zero, you immediately think […]The post Why determinants with columns of ones? first appeared on John D. Cook.
Conformal map of rectangle to ellipse
The previous post looked at what the sine function does to circles in the complex plane. This post will look at what it does to an rectangle. The sine function takes a rectangle of the form [0, 2π] × [0, q] to an ellipse with semi major axis cosh(q) and semi minor axis sinh(q). The […]The post Conformal map of rectangle to ellipse first appeared on John D. Cook.
Sine of a circle
What does it look like when you take the sine of a circle? Not the angle of points on a circle, but the circle itself as a set of points in the complex plane? Here’s a plot for the sine of circles of radius r centered at the origin, 0 < r < π/2. Here’s […]The post Sine of a circle first appeared on John D. Cook.
Test whether three complex numbers are vertices of an equilateral triangle
Let a, b, and c be three complex numbers. These numbers form the vertices of an equilateral triangle in the complex plane if and only if This theorem can be found in [1]. If we rotate the matrix above, we multiply its sign by -1. If we then swap two rows we multiply the determinant […]The post Test whether three complex numbers are vertices of an equilateral triangle first appeared on John D. Cook.
Arbitrary precision math in gawk
The idea of using awk for any math beyond basic arithmetic is kinda strange, and yet it has some nice features. Awk was designed for file munging, a task it does well with compact syntax. GNU awk (gawk) supports the original minimalist version of awk and adds more features. It supports arbitrary precision arithmetic by […]The post Arbitrary precision math in gawk first appeared on John D. Cook.
Unicode arrows: math versus emoji
I used the character ↔︎︎ (U+2194) in a blog post recently and once again got bit by the giant pawn problem. That’s my name for when a character intended to be rendered as text is surprisingly rendered as an emoji. I saw when what I intended was I ran into the same problem a while […]The post Unicode arrows: math versus emoji first appeared on John D. Cook.
The Orange Book
I was spelunking around in Unicode and saw that there’s an emoji for orange book, U+1F4D9. As is often the case, the emoji renders differently in different contexts. The image above is from my Linux desktop and the image below is from my Macbook. I tried created an image on my Windows box but it […]The post The Orange Book first appeared on John D. Cook.
What does rotating a matrix do to its determinant?
This post will look at rotating a matrix 90° and what that does to the determinant. This post was motivated by the previous post. There I quoted a paper that had a determinant with 1s in the right column. I debated rotating the matrix so that the 1s would be along the top because that […]The post What does rotating a matrix do to its determinant? first appeared on John D. Cook.
Area of a triangle in the complex plane
I recently ran across an elegant equation for the area of a triangle in the complex plane with vertices at z1, z2, and z3. [1]. This formula gives the signed area: the area is positive if the points are given in countclockwise order and negative otherwise. I’ll illustrate the formula with a little Python code. […]The post Area of a triangle in the complex plane first appeared on John D. Cook.
Finding a vector potential whose curl is given
The previous post showed that if a vector field F over a simply connected domain has zero curl, then there is a potential function φ whose gradient is F. An analogous result says that if the vector field F has zero divergence, again over a simply connected domain, then there is a vector potential Φ […]The post Finding a vector potential whose curl is given first appeared on John D. Cook.
Conservative vector fields
The previous post discussed the fact that the curl of a divergence is zero. The converse is also true (given one more requirement): a vector field F is the gradient of some potential φ function if ∇×F = 0. In that case we say F is a conservative vector field. It’s clear that having zero […]The post Conservative vector fields first appeared on John D. Cook.
{div, grad, curl} of a {div, grad, curl}
The various combinations of divergence, gradient, and curl are confusing to someone seeing them for the first time, and even for someone having seen them many times. Is the divergence of a curl zero or is it the divergence of a gradient that’s zero? And there’s another one, Is it curl of curl or or […]The post {div, grad, curl} of a {div, grad, curl} first appeared on John D. Cook.
Arabic numerals and numerals that are Arabic
The characters 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 are called Arabic numerals, but there are a lot of other numerals that are Arabic. I discovered this when reading the documentation on Perl regular expressions, perlre. Here’s the excerpt from that page that caught my eye. Many scripts have their own […]The post Arabic numerals and numerals that are Arabic first appeared on John D. Cook.
Telescopes, awk, and learning
Here’s a quote I think about often: “It is faster to make a four-inch mirror and then a six-inch mirror than to make a six-inch mirror.” — Bill McKeenan, Thompson’s law of telescopes If your goal is to make a six-inch mirror, why make a four-inch mirror first? From a reductionist perspective this makes no […]The post Telescopes, awk, and learning first appeared on John D. Cook.
The messy version of Napoleon’s theorem
Napoleon’s theorem is usually presented as I presented it in the previous post. You start with a triangle (solid blue) and add equilateral triangles (dashed green) on the outside of the triangle. When you connect the centroids of these triangles you get a (dotted red) equilateral triangle. But Napoleon’s theorem is more general than this. […]The post The messy version of Napoleon’s theorem first appeared on John D. Cook.
Napoleon’s theorem
The following theorem is attributed to Napoleon Bonaparte (1769–1821). There’s some debate over whether Napoleon was the first to discover the theorem, but I don’t believe there’s any doubt that the theorem, like Morley’s theorem from the previous post, was discovered a long time after Euclid. Start with any triangle and draw equilateral triangles on […]The post Napoleon’s theorem first appeared on John D. Cook.
Trilinear coordinates
The first time I saw a reference to trilinear coordinates I thought this must be another name for barycentric coordinates. It’s not. Barycentric coordinates come up often in applications, such as when working with finite element meshes. Trilinear coordinates are less common, at least in my experience, and yet trilinear coordinates simplify a lot of classical […]The post Trilinear coordinates first appeared on John D. Cook.
Unexpected symmetry
Take an arbitrary triangle and draw the trisectors of each angle. Morley’s theorem says that the trisector lines will intersect at the vertices of an equilateral triangle. This theorem is surprising because out of a triangle with no symmetry pops a triangle with three-fold symmetry. The theorem is also historically surprising. It’s a theorem of […]The post Unexpected symmetry first appeared on John D. Cook.
Elliptic functions of a complex argument in Python
I used Mathematica to create the graphics for my previous two posts because SciPy didn’t have the functions I needed. In particular, elliptic integrals and elliptic functions in SciPy only take real-valued arguments, but I needed to use complex arguments. Also, I needed theta functions, which are not in SciPy at all. I thought mpmath […]The post Elliptic functions of a complex argument in Python first appeared on John D. Cook.
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.
...15161718192021222324...