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 2024-11-22 08:17
Beatty’s theorem
Here’s a surprising theorem [1]. (Beatty’s theorem) Let a and b be any pair of irrational numbers greater than 1 with 1/a + 1/b = 1. Then the sequences { ⌊na⌋ } and { ⌊nb⌋ } contain every positive integer without repetition. Illustration Here’s a little Python code to play with this theorem.We set a […]The post Beatty’s theorem first appeared on John D. Cook.
Corner quotes in Unicode
In his book Mastering Regular Expressions, Jeffrey Friedl uses corner quotes to delimit regular expressions. Here’s an example I found by opening his book a random: ⌜(\.\d\d[1-9]?)\d*⌟ The upper-left corner at the beginning and the lower-right corner at the end are not part of the regular expression. This particularly comes in handy if a regular […]The post Corner quotes in Unicode first appeared on John D. Cook.
Three paths converge
When does the equation x2 + 7 = 2n have integer solutions? This is an interesting question, but why would anyone ask it? This post looks at three paths that have led to this problem. Ramanujan Ramanujan [1] considered this problem in 1913. He found five solutions and conjectured that there were no more. Then […]The post Three paths converge first appeared on John D. Cook.
One diagram, two completely different meanings
I was thumbing through a new book on causal inference, The Effect by Nick Huntington-Klein, and the following diagram caught my eye. Then it made my head hurt. It looks like a category theory diagram. What’s that doing in a book on causal inference? And if it is a category theory diagram, something’s wrong. Either […]The post One diagram, two completely different meanings first appeared on John D. Cook.
Memorable techniques
My favorite part of this post by Ian Miellis the introduction. The article is about shell commands, but the introduction brings up a more general point. … there are thousands of reusable patterns I’ve picked up … Unfortunately, I’ve forgotten about 95% of them. … The point is to reflect on what actually stuck, so […]The post Memorable techniques first appeared on John D. Cook.
Architecture and Math
I recently received a review copy of Andrew Witt’s new book Formulations: Architecture, Mathematics, and Culture. The Hankel function on the cover is the first clue that this book contains some advanced mathematics. Or rather, it references some advanced mathematics. I’ve only skimmed the book so far, but I didn’t see any equations. Hankel functions […]The post Architecture and Math first appeared on John D. Cook.
Turning the Golay problem sideways
I’ve written a couple posts about the Golay problem recently, first here then here. The problem is to find all values of N and n such that is a power of 2, say 2p. Most solutions apparently fall into three categories: n = 0 or n = N, N is odd and n = (N-1)/2, […]The post Turning the Golay problem sideways first appeared on John D. Cook.
Update on the Golay problem
I played around with what I’m calling the Golay problem over Christmas and wrote a blog post about it. I rewrote the post as I learned more about the problem due to experimentation and helpful feedback via comments and Twitter. In short, the Golay problem is to classify the values of N and n such […]The post Update on the Golay problem first appeared on John D. Cook.
Names and numbers for modal logic axioms
Stanislaw Ulam once said Using a term like nonlinear science is like referring to the bulk of zoology as the study of non-elephant animals. There is only one way to be linear, but there are many ways to not be linear. A similar observation applies to non-classical logic. There are many ways to not be […]The post Names and numbers for modal logic axioms first appeared on John D. Cook.
When do two-body systems have stable Lagrange points?
The previous post looked at two of the five Lagrange points of the Sun-Earth system. These points, L1 and L2, are located on either side of Earth along a line between the Earth and the Sun. The third Lagrange point, L3, is located along that same line, but on the opposite side of the Sun. […]The post When do two-body systems have stable Lagrange points? first appeared on John D. Cook.
Finding Lagrange points L1 and L2
The James Webb Space Telescope (JWST) is on its way to the Lagrange point L2 of the Sun-Earth system. Objects in this location will orbit the Sun at a fixed distance from Earth. There are five Lagrange points, L1 through L5. The points L1, L2, and L3 are unstable, and points L4 and L5 are […]The post Finding Lagrange points L1 and L2 first appeared on John D. Cook.
Most popular posts of 2021
These were the most popular posts from 2021 on this site, listed in chronological order. Simple gamma approximation Floor, ceiling, bracket Evolution of random number generators Format text in twitter Where has all the productivity gone? Computing zeta(3) Morse code palindromes Much less than, much greater than Monads and macros Partial functionsThe post Most popular posts of 2021 first appeared on John D. Cook.
The exception case is normal
Sine and cosine have power series with simple coefficients, but tangent does not. Students are shocked when they see the power series for tangent because there is no simple expression for the power series coefficients unless you introduce Bernoulli numbers, and there’s no simple expression for Bernoulli numbers. The perception is that sine and cosine […]The post The exception case is normal first appeared on John D. Cook.
Binomial sums and powers of 2
Marcel Golay noticed that and realized that this suggested it might be possible to create a perfect code of length 23. I wrote a Twitter thread on this that explains how this relates to coding theory (and to sporadic simple groups). This made me wonder how common it is for cumulative sums of binomial coefficients […]The post Binomial sums and powers of 2 first appeared on John D. Cook.
O Come, O Come, Emmanuel: condensing seven hymns into one
The Christmas hymn “O Come, O Come, Emmanuel” is a summary of the seven “O Antiphons,” sung on December 17 though 23, dating back to the 8th century [1]. The seven antiphons are O Sapientia O Adonai O Radix Jesse O Clavis David O Oriens O Rex Gentium O Emmanuel The corresponding verses of “O […]The post O Come, O Come, Emmanuel: condensing seven hymns into one first appeared on John D. Cook.
Error correcting code from octonions
Yesterday I wrote about how to multiply octets of real numbers, the octonions. Today I’ll show how to create an error correcting code from the octonions. In fact, we’ll create a perfect code in the sense explained below. We’re going to make a code out of octonions over a binary field. That is, we’re going […]The post Error correcting code from octonions first appeared on John D. Cook.
Conjugate theorem for octonions
Yesterday I wrote about the fact that quaternions, unlike complex numbers, can form conjugates via a series of multiplications and additions. This post will show that you can do something similar with octonions. If x is an octonion x = r0 e0 + r1 e1 + … + r7 e7 where all the r‘s are […]The post Conjugate theorem for octonions first appeared on John D. Cook.
How to multiply octonions
This post will present a way of multiplying octonions that’s easy to remember. Please note that there are varying conventions for how to define multiplication for octonions [1]. Octonions The complex numbers have one imaginary unit i, and the quaternions have three: i, j, and k. The octonions have seven, and so it makes sense […]The post How to multiply octonions first appeared on John D. Cook.
Complex Conjugates versus Quaternion Conjugates
The conjugate of a complex number is the complex number Taking the conjugate flips over a complex number, taking its reflection in the real axis. Multiplication stretches and rotates complex numbers, and addition translates complex numbers. You can’t flip the complex plane over by any series of dilatations, rotations, and translations. The situation is different […]The post Complex Conjugates versus Quaternion Conjugates first appeared on John D. Cook.
The center may not hold
“… Things fall apart; the centre cannot hold …” — Yeats, The Second Coming Center of a group The center of a group is the set of elements that commute with everything else in the group. For example, matrix multiplication is not commutative in general. You can’t count on AB being equal to BA, […]The post The center may not hold first appeared on John D. Cook.
The congruent number problem
A positive integer n is said to be congruent if there exists a right triangle with area n such that the length of all three sides is rational. You could always choose one leg to have length n and the other to have length 2. Such a triangle would have area n and two rational […]The post The congruent number problem first appeared on John D. Cook.
Aesthetic uses of Latin squares
We think they like randomness in design, but we don’t exactly. People like things that are sorta random, but not too random. When you literally scatter things randomly, they looked too clumped [1]. There are many ways around this problem, variations on randomness that people find more aesthetically pleasing. One of these ways is random […]The post Aesthetic uses of Latin squares first appeared on John D. Cook.
Know the rules to break the rules
There’s a saying in the arts “Know the rules before you break the rules.” Master the classical conventions of your field before you violate them. Break the rules deliberately and not accidentally, skillfully and not due to a lack of skill. There’s a world of difference between a beginning musician playing a wrong note and […]The post Know the rules to break the rules first appeared on John D. Cook.
How many Latin squares are there?
A Latin square is an n × n grid with a number from 1 to n in each cell, such that no number appears twice in a row or twice in a column. It’s not obvious that Latin squares exist for all n, but they do, and in fact there are a lot of them. […]The post How many Latin squares are there? first appeared on John D. Cook.
Yule statistics Y and Q
I recently wrote about the Yule-Simon distribution. The same Yule, George Udny Yule, is also known for the statistics Yule’s Y and Yule’s Q. The former is also known as the coefficient of colligation, and the latter is also known as the Yule coefficient of association. Both measure how things are related. Given a 2 […]The post Yule statistics Y and Q first appeared on John D. Cook.
Deleting reproducible files in Emacs dired
Imagine you could list the contents of a directory from a command line, and then edit the text output to make things happen. That’s sorta how Emacs dired works. It’s kind of a cross between a bash shell and the Windows File Explorer. Why would you ever want to use such a bizarre hybrid? One […]The post Deleting reproducible files in Emacs dired first appeared on John D. Cook.
Fraud, Sloppiness, and Statistics
A few years ago the scientific community suddenly realized that a lot of scientific papers were wrong. I imagine a lot of people knew this all along, but suddenly it became a topic of discussion and people realized the problem was bigger than imagined. The layman’s first response was “Are you saying scientists are making […]The post Fraud, Sloppiness, and Statistics first appeared on John D. Cook.
Comparing three discrete power laws
Yesterday I wrote about the zeta distribution and the Yule-Simon distribution and said that they, along with the Zipf distribution, are all discrete power laws. This post fills in detail for that statement. The probability mass functions for the zeta, Zipf, and Yule-Simon distributions are as follows. Here the subscripts ζ, y, and z stand for […]The post Comparing three discrete power laws first appeared on John D. Cook.
The zeta distribution
The previous post on the Yule-Simon distribution mentioned the zeta distribution at the end. This is a powerlaw distribution on the positive integers with normalizing constant given by the Riemann zeta distribution. That is, the zeta distribution has density f(k; s) = k–s / ζ(s). where k is a positive integer and s > 1 is […]The post The zeta distribution first appeared on John D. Cook.
Yule-Simon distribution
The Yule-Simon distribution, named after Udny Yule and Herbert Simon, is a discrete probability with pmf The semicolon in f(k; ρ) suggests that we think of f as a function of k, with a fixed parameter ρ. The way the distribution shows the connection to the beta function, but for our purposes it will be […]The post Yule-Simon distribution first appeared on John D. Cook.
Mahalanobis distance and Henry V
I was reading a stats book that mentioned Mahalanobis distance and that made me think of Non Nobis from Henry V, a great scene in a great movie. As far as I know, there’s no connection between Mahalanobis and Non Nobis except that both end in “nobis.” Since Mahalanobis is an Indian surname and Non […]The post Mahalanobis distance and Henry V first appeared on John D. Cook.
Probability of a magical permutation
Take a permutation of the numbers 1 through n² and lay out the elements of the permutation in a square. We will call a permutation a magic permutation if the corresponding square is a magic square. What is the probability that a permutation is a magic permutation? That is, if you fill a grid randomly […]The post Probability of a magical permutation first appeared on John D. Cook.
Degree of magic
A square grid of distinct integers is a magic square if all its rows columns and full diagonals have the same sum. Otherwise it is not a magic square. Now suppose we fill a square grid with samples from a continuous random variable. The probability that the entries are distinct is 1, but the probability […]The post Degree of magic first appeared on John D. Cook.
Universal properties
I started to write a blog post about universal properties, but ended up writing a Twitter thread instead.The post Universal properties first appeared on John D. Cook.
The ring of entire functions
Rings made a bad first impression on me. I couldn’t remember the definitions of all the different kinds of rings, much less have an intuition for what was important about each one. As I recall, all the examples of rings in our course were variations on the integers, often artificial variations. Entire functions I’m more […]The post The ring of entire functions first appeared on John D. Cook.
The awkward middle child of algebra
Abstract algebra is basically the study of groups, rings, and fields. There are more concepts, but these are the big three. Groups have the least structure and fields have the most structure. Rings are somewhere in the middle. Groups have just one operation, which is thought of as multiplication by default. If the group operation […]The post The awkward middle child of algebra first appeared on John D. Cook.
Partial functions and total functions
I was thinking about writing a post about entire functions and it occurred to me that I should say something about how entire functions are unrelated to total functions. But then I realized they’re not unrelated. I intend to say something about entire functions in a future post. Update: See The ring of entire functions. […]The post Partial functions and total functions first appeared on John D. Cook.
Exact sequences
A couple days ago, near the end of a post, I mentioned exact sequences. This term does not mean what you might reasonably think it means. It doesn’t mean exact in the sense of not being approximate. It means that the stuff that comes out of one step is exactly the stuff that gets set […]The post Exact sequences first appeared on John D. Cook.
Data swamps
I recently heard the term data swamp, a humorous take on data lakes. I thought about data swamps yesterday when I hiked past the literal swamp in the photo above. Swamps are a better metaphor than lakes for heterogeneous data collections because a lake is a homogeneous body of water. What makes a swamp a […]The post Data swamps first appeared on John D. Cook.
Numerical footnote
Yesterday’s post said that that you could construct a chain of linear relationships between the hypergeometric function F(a, b; c; z) and F(a+i, b+j; c+k; z) for integers i, j, and k. Toward the end of the post I said that this could be used to speed up programs by computing function values from previous […]The post Numerical footnote first appeared on John D. Cook.
Four, five, and nine lemmas
This post is similar in spirit to the previous post: reducing mathematical theorems to moves in a board game by looking at things from a ridiculously high level. The theorems we’ll be looking at are known as the four lemma, the five lemma, and the nine lemma. The nine lemma is also known as the […]The post Four, five, and nine lemmas first appeared on John D. Cook.
3D Go with identities
Let’s play a game that’s something like Go in three dimensions. Our game is played on the lattice of points in 3D that have integer coordinates. Someone places stones on two lattice points, and your job is to create a path connecting the two stones by adding stones to neighboring locations. Game cube We don’t […]The post 3D Go with identities first appeared on John D. Cook.
Area of spherical triangle
A few days ago I wrote about how you could calculate the area of a spherical triangle by measuring the angles at its vertices. As was pointed out in the comments, there’s a much more direct way to find the area. Folke Eriksson gives the following formula for area in [1]. If a, b, and […]The post Area of spherical triangle first appeared on John D. Cook.
Triangles on a pseudosphere
The previous post was about triangles on a sphere. This post will be about triangles on a pseudosphere. A pseudosphere looks something like the bell of a trumpet or a trombone. Here’s a plot of a pseudosphere. This was created in Mathematica with the code ParametricPlot3D[ { Cos[p] Sech[t], -Sin[p] Sech[t], t - Tanh[t] }, […]The post Triangles on a pseudosphere first appeared on John D. Cook.
A tale of three cities
Pick three cities and form a spherical triangle by connecting each pair of cities with the shortest arc between them. How might you find the area of this triangle? For this post, I’ll assume the earth is perfectly spherical. (Taking into account that the earth is slightly oblate makes the problem much more complicated. Maybe […]The post A tale of three cities first appeared on John D. Cook.
Great circle through two points on a sphere
Given two points on a unit sphere, there is a unique great circle passing through the two points. This post will show two ways to find a parameterization for this circle. Both approaches have their advantages. The first derivation is shorter and in some sense simpler. The second derivation is a little more transparent and […]The post Great circle through two points on a sphere first appeared on John D. Cook.
Wire gauge and user perspective
Wire gauge is a perennial source of confusion: larger numbers denote smaller wires. The reason is that gauge numbers were assigned from the perspective of the manufacturing process. Thinner wires require more steps in production. This is a common error in user interface design and business more generally: describing things from your perspective rather than […]The post Wire gauge and user perspective first appeared on John D. Cook.
New twitter account: tensor_fact
I’ve started a new Twitter account: @tensor_fact. The word “tensor” is used to describe several different but related mathematical objects. My intention, at least for now, it to focus on tensor calculus: things with indices that obey certain transformation rules. More on other meanings of tensor here. Related From tape measures to tensors Technical Twitter […]The post New twitter account: tensor_fact first appeared on John D. Cook.
How to put a series in hypergeometric form
I skipped a step in the previous post, not showing how a series was put into the form of a hypergeometric function. Actually I skipped two steps. I first said that a series was not obviously hypergeometric, and yet at first glance it sorta is. I’d like to make up for both of these omissions, […]The post How to put a series in hypergeometric form first appeared on John D. Cook.
Quintic trinomial root
This post looks at an exercise from Special Functions, exercise 6 in Appendix E. Suppose that xm+1 + ax – b = 0. Show that Use this formula to find a solution to x5 + 4x + 2 = 0 to four decimal places of accuracy. When m = 0 this series reduces to the […]The post Quintic trinomial root first appeared on John D. Cook.
...16171819202122232425...