All the data you need.

Tag: Math

Sum of squares mod n uniformly distributed
Let s be an integer equal to at least 5 and let n be a positive integer. Look at all tuples of s integers, each integer being between 0 and n-1 inclusive, and look at the sum of their squares mod n. About 1/n will fall into each possible value. …
Day of the year
Occasionally it’s useful to find the day of the year. For example, today is 272nd day of 2022. How hard would it be to calculate the day of the year in your head? Each month has about 30 days, so the dth day of the mth month is approximately day …
The original Room square
A few days ago I wrote about Room squares, squares named after Thomas Room. This post will be about Room’s original square. You could think of a Room square as a tournament design in which the rows represent locations and the columns represent rounds (or vice versa). Every team plays …
Visualizing correlations with graphs
My local library had a book sale this weekend and I picked up a statistics textbook for geologists [1] for $1. When I thumbed through the book an image similar to the one below caught my eye. This image approximates Figure 15.2 in [1], The nodes represent six factors of …
Room squares and Tournaments
A Room square is a variation on a Latin square. Room squares are named after Thomas Room, though there is an application to rooms as in compartments of a building that we’ll discuss below. In a Latin square of size n you have to assign one of n symbols to …
Field of order 9
This post will give a detailed example of working in a field with nine elements. This is important because finite fields are not often treated concretely except for the case of prime order. In my first post on Costas arrays I mentioned in a footnote that Lempel’s algorithm works more …
Costas arrays in Mathematica
A couple days ago I wrote about Costas arrays. In a nutshell, a Costas array of size n is a solution to the n rooks problem, with the added constraint that if you added wires between the rooks, no two wires would have the same length and slope. See the …
Costas arrays
The famous n queens problem is to find a way to position n queens on a n×n chessboard so that no queen attacks any other. That is, no two queens can be in the same row, the same column, or on the same diagonal. Here’s an example solution: Costas arrays …
Balanced tournament designs
Suppose you have an even number of teams that you’d like to schedule in a Round Robin tournament. This means each team plays every other team exactly once. Denote the number of teams as 2n. You’d like each team to play in each round, so you need n locations for …
Graphing Japanese Prefectures
The two previous posts looked at adjacency networks. The first used examples of US states and Texas counties. The second post made suggestions for using these networks in a classroom. This post is a continuation of the previous post using examples from Japan. Japan is divided into 8 regions and …
Classroom exercise with networks
In the previous post I looked at graphs created from representing geographic regions with nodes and connecting nodes with edges if the corresponding regions share a border. It’s an interesting exercise to recover the geographic regions from the network. For example, take a look at the graph for the continental …
Adjacency networks
Suppose you want to color a map with no two bordering regions having the same color. If this is a map on a plane, you can do this using only four colors, but maybe you’d like to use more. You can reduce the problem to coloring the nodes in a …
Shortest tours of Eurasia and Oceania
This is the final post in a series of three posts about shortest tours, solutions to the so-called traveling salesmen problem. The first was a tour of Africa. Actually two tours, one for the continent and one for islands. See this post for the Mathematica code used to create the …
Trig in hyperbolic geometry
I recently wrote posts about spherical analogs of the Pythagorean theorem, the law of cosines, and the law of sines. The corresponding formulas for hyperbolic space mostly just replace circular functions with hyperbolic functions, i.e. replace sine with hyperbolic sine and cosine with hyperbolic cosine. Triangles on a sphere or …
Eliminating a Bessel function branch cut
In an earlier post I looked in detail at a series for inverse cosine centered at 1. The function arccos(z) is multivalued in a neighborhood of 1, but the function arccos(z) / √(2 – 2z) is analytic in a neighborhood of 1. We cancel out the bad behavior of inverse …
Branch cuts for elementary functions
As far as I know, all contemporary math libraries use the same branch cuts when extending elementary functions to the complex plane. It seems that the current conventions date back to Kahan’s paper [1]. I imagine to some extent he codified existing practice, but he also settled some issues, particularly …
Literate programming to reduce errors
I had some errors in a recent blog post that might have been eliminated if I had programmatically generated the content of the post rather than writing it by hand. I rewrote the example in this post in using org-mode. My org file looked like this: #+begin_src python :session :exports …
Square root mnemonics
Here’s a cute little poem: I wish I knew The root of two. Oh charmed was he To know root three. So we now strive To find root five. The beginning of each stanza is a mnemonic for the number mentioned in the following line. √ 2 = 1.414 √ …