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-05-19 10:31
Trading generalized derivatives for classical ones
Generalized functions have generalized derivatives. This is how we make sense of things like delta “functions” that are not functions, or functions that are not differentiable satisfying a differential equation. More on that here. A major theme in the modern approach to partial differential equations is to first look for solutions in a space of […]The post Trading generalized derivatives for classical ones first appeared on John D. Cook.
The view from a Galilean moon
The Galilean moons are the four largest moons of Jupiter, first observed by Galileo, contra Stigler’s law of eponymy. This post shows what the Jovian system look like from the perspective of each of these moons, a sort of pre-Copernican perspective in a Jovian context. The view from Io Here’s what Europa would look like […]The post The view from a Galilean moon first appeared on John D. Cook.
What if Copernicus had been a Martian?
The genius of Copernicus was to realize that this plot becomes this plot under a clever change of coordinates. The first plot is the apparent motion of Mars, Jupiter, and Saturn as viewed from Earth over the course of 30 years. Of course Copernicus knew of Mercury and Venus as well, but I’ve omitted them […]The post What if Copernicus had been a Martian? first appeared on John D. Cook.
How the orbit of one planet appears from another
This post shows how the orbits some planets appear from other planets. I’ve give a few of my favorite examples and include a Python program you could use to create your own plots. We will assume the planets move in circles around the sun. They don’t exactly—they don’t exactly move in ellipses either—but their orbits […]The post How the orbit of one planet appears from another first appeared on John D. Cook.
Using Python as a statistical calculator
This post is for someone unfamiliar with SciPy who wants to use Python to do basic statistical calculations. More specifically, this post will look at working with common families of random variables—normal, exponential, gamma, etc.—and how to calculate probabilities with these. All the statistical functions you need will be in the stats subpackage of SciPy. […]The post Using Python as a statistical calculator first appeared on John D. Cook.
Eccentricity, Flattening, and Aspect Ratio
There are at least three common ways to describe the shape of an ellipse: eccentricity e, flattening f, and aspect ratio r. Each is a number between 0 and 1. (Flattening is also called ellipticity, which is a descriptive name, but unfortunately it sounds a lot like eccentricity.) Although converting between these three descriptions is […]The post Eccentricity, Flattening, and Aspect Ratio first appeared on John D. Cook.
Planetary orbits are very nearly circular
If a science book shows you obviously elliptical orbits of planets, it is literally stretching the truth. I was taught that our benighted ancestors insisted that planetary orbits are circles for philosophical reasons. In fact, they insisted planetary orbits are circular because they very nearly are. Here’s a plot of the orbits of all nine […]The post Planetary orbits are very nearly circular first appeared on John D. Cook.
Saving money on big queries
I was surprised the first time a client told me that a query would cost them $100,000 to run. If you think about querying a database on your laptop, a long query would take a minute, and what’s the cost of a minute’s worth of electricity? Too small to meter. But some of my clients […]The post Saving money on big queries first appeared on John D. Cook.
The Pluto-Charon orbit
The Moon doesn’t orbit the center of the Earth; it orbits the center of mass of the Earth-Moon system, which is inside the Earth. The distinction matters for designing satellite orbits, but it cannot be seen on a plot to scale. We’ll quantify this below. Pluto’s moon Charon, however, is so large relative to Pluto […]The post The Pluto-Charon orbit first appeared on John D. Cook.
Shape of moon orbit around sun
The earth’s orbit around the sun is nearly a circle, and the moon’s orbit around the earth is nearly a circle, but what is the shape of the moon’s orbit around the sun? You might expect it to be bumpy, bending inward when the moon is between the earth and the sun and bending output […]The post Shape of moon orbit around sun first appeared on John D. Cook.
A more direct approach to series solutions
In the previous post we found a solution to using operator calculus, i.e. treating the differential operator D like a number and doing tricks with it. See the earlier post for a justification of why we can get away with unorthodox manipulations. We can generalize the method of the previous post to say that a […]The post A more direct approach to series solutions first appeared on John D. Cook.
Operator calculus
Students who take a course in differential equations don’t really learn how to solve differential equations. The problems whose solutions they reproduce were solved over 300 years ago. The methods taught in undergraduate ODE classes are in some sense mnemonics, a way to remember a solution discovered long ago. Abandon hope of originality The more […]The post Operator calculus first appeared on John D. Cook.
Writing math with Unicode
A LaTeX document looks better than an HTML document, but an HTML document looks better than an awkward hybrid of HTML and inline images created by LaTeX. My rule is to only use LaTeX-generated images for displayed equations and not for math symbols in the middle of a sentence. This works pretty well, but it’s […]The post Writing math with Unicode first appeared on John D. Cook.
Cicadas and Chicken Nuggets
Yesterday I wrote about the Chicken McNugget problem: if Chicken McNuggets are sold in boxes of 6, 9, and 20, what’s the largest number of nuggets you cannot buy? That post showed that the solution was 43. The technical name for these kinds of problems is numerical monoids. The method of solution in the previous […]The post Cicadas and Chicken Nuggets first appeared on John D. Cook.
The Chicken McNugget Monoid
When McDonalds first introduced Chicken McNuggets, you could buy McNuggets in boxes of 6, 9, or 20. The Chicken McNugget problem is to determine which numbers of McNuggets you can and cannot buy. A number n is a McNugget number if it is possible to buy exactly that many McNuggets (using the original boxes). There […]The post The Chicken McNugget Monoid first appeared on John D. Cook.
Efficiently testing a black box
Suppose you have a black box that takes three bits as input and produces one bit as output. You could think of the input bits as positions of toggle switches, and the output bit as a light attached to the box that is either on or off. Full factorial design Now suppose that only one […]The post Efficiently testing a black box first appeared on John D. Cook.
Which one is subharmonic?
The Laplace operator Δ of a function of n variables is defined by If Δ f = 0 in some region Ω, f is said to be harmonic on Ω. In that case f takes on its maximum and minimum over Ω at locations on the boundary ∂Ω of Ω. Here is an example of a […]The post Which one is subharmonic? first appeared on John D. Cook.
Ideograph numerals
This post is a follow on to my previous post on Unicode numbers. I always welcome feedback from readers, but I especially welcome it here because I’m walking into an area I know next to nothing about. Consecutive code points Unicode generally assigns code points to number-like things in consecutive order. For example, the Python […]The post Ideograph numerals first appeared on John D. Cook.
Unicode numbers
There are 10 digits in ASCII, and I bet you can guess what they are. In ASCII, a digit is a decimal is a number. Things are much wilder in Unicode. There are hundreds of decimals, digits, and numeric characters, and they’re different sets. The following Python code loops through all possible Unicode characters, extracting […]The post Unicode numbers first appeared on John D. Cook.
Regex to match ICD-11 code
ICD codes are diagnostic codes created by the WHO. (Three TLAs in just the opening paragraph!) The latest version, ICD-11, went into effect in January of this year. A few countries are using ICD-11 now; it’s expected to be at least a couple years before the US moves from ICD-10 to ICD-11. (I still see […]The post Regex to match ICD-11 code first appeared on John D. Cook.
The Very Model of a Professor Statistical
The last chapter of George Box’s book Improving Almost Anything contains the lyrics to “I Am the Very Model of a Professor Statistical,” to be sung to the tune of “I Am the Very Model of a Modern Major General” by Gilbert & Sullivan. Here’s the original: The original song has a few funny math-related […]The post The Very Model of a Professor Statistical first appeared on John D. Cook.
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. So, for example, if you look […]The post Sum of squares mod n uniformly distributed first appeared on John D. Cook.
Quirks in Mathematica’s administrative division data for Mexico
If you ask Mathematica for a list of Mexican states via CountryData["Mexico", "RegionNames"] you will get a list of strings: "Aguascalientes", "Baja California", ..., "Zacatecas"} However, when you try to turn this into a list of objects representing these states via states = Entity["AdministrativeDivision", {#, "Mexico"}] & /@ CountryData["Mexico", "RegionNames"] something strange happens. Some items […]The post Quirks in Mathematica’s administrative division data for Mexico first appeared on John D. Cook.
Visualizing Swedish vowels
A few days ago I wrote a post comparing English and Japanese vowel sounds in a 2D chart. In this post I’d like to do something similar for English and Swedish. As before the data come from [1]. A friend of mine who learned Swedish would joke about how terribly he had to contort his […]The post Visualizing Swedish vowels first appeared on John D. Cook.
A traveling salesman tour of Canada
Here is a Traveling Salesman tour of Canada’s provinces and territories created by Mathematica. This is the shortest path connecting the geographic centers of the regions. Here is a much larger (4.5 MB) PDF file of the same map with higher resolution. Starting in the northwest, the tour is Yukon Northwest Territories Nunavut Quebec Newfoundland […]The post A traveling salesman tour of Canada first appeared on John D. Cook.
Ligatures for Logic
A ligature in typesetting is a way of presenting two (or more) consecutive characters differently the individual characters would be displayed. For example, “fi” is often rendered with the top of the ‘f’ dotting the ‘i’. Here’s an example from Computer Modern, the default font in LaTeX. Usually the difference is subtle—ordinarily readers are not […]The post Ligatures for Logic first appeared on John D. Cook.
Visualizing English and Japanese vowels
Vowel sounds can be visualized in a two-dimensional space according to tongue position. The vertical axis is runs from open down to closed, and the horizontal runs from front to back. See a linguistics textbook for far more detail. English has five vowel letters, but a lot more than five vowel sounds. Scholars argue about […]The post Visualizing English and Japanese vowels first appeared on John D. Cook.
Preventing characters from displaying as emoji
I rarely intentionally use emoji, and yet I often run into them unbidden. This is because some Unicode characters double as emoji. For example, the zodiac symbol for Aries is used both in celestial navigation and in astrology. The latter is much more common, and so when some software sees U+2648 it interprets the character […]The post Preventing characters from displaying as emoji first appeared on John D. Cook.
Day of the year
It’s necessary now and then to find the day of the year for a date. 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 post Day of the year first appeared on John D. Cook.
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 every other team exactly once, […]The post The original Room square first appeared on John D. Cook.
Visualizing correlations with graphs
Yesterday I found a statistics textbook for geologists [1] for $1 at a library book sale. 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 the thickness of rock formations and the edges are labeled […]The post Visualizing correlations with graphs first appeared on John D. Cook.
Katakana, Hiragana, and Unicode
I figured out something that I wasn’t able to find by searching, so I’m posting it here in case other people have the same question and the same difficulty finding an answer. I’m sure other people have written about this, but I couldn’t find it. Maybe lots of people have written about this in Japanese […]The post Katakana, Hiragana, and Unicode first appeared on John D. Cook.
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 each cell so that each […]The post Room squares and Tournaments first appeared on John D. Cook.
HCPCS (“hick pics”) codes
HCPCS stands for Healthcare Common Procedure Coding System. HCPCS codes are commonly pronounced like “hick pics.” I was curious/afraid to see what DALL-E would create with the prompt “HCPCS hick pics” and was pleasantly surprised that it produced the image above. More on that latter. Searching for medical codes I occasionally need to search for […]The post HCPCS (“hick pics”) codes first appeared on John D. Cook.
Dominoes in Unicode
I was spelunking around in Unicode and found that there are assigned characters for representing domino tiles and that the characters are enumerated in a convenient order. Here is the code chart. There are codes for representing tiles horizontally or vertically. And even though, for example, the 5-3 is the same domino as the 3-5, […]The post Dominoes in Unicode first appeared on John D. Cook.
Raging against the machine
Ran across a great quote from Liv Boeree recently: The problem with raging against the machine is that the machine has learned to feed off rage. Someone appropriately replied with a screenshot from an episode of Star Trek TOS, Day of the Dove, about a being that feeds off anger, like contemporary media.The post Raging against the machine first appeared on John D. Cook.
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 generally over any finite field, […]The post Field of order 9 first appeared on John D. Cook.
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 earlier post for more details. […]The post Costas arrays in Mathematica first appeared on John D. Cook.
Two-letter vs Three-letter Country Abbreviations
The ISO 3166-1 standard defines three codes for each country: a 2-letter abbreviation, a 3-letter abbreviation, and a 3-digit code. The 2-letter abbreviations may be familiar because it is very often (but not always [1]) also the country code top-level domain (ccTLD). For example, AU is the ISO abbreviation for Australia, and .au is the […]The post Two-letter vs Three-letter Country Abbreviations first appeared on John D. Cook.
Finding similar world flags with Mathematica
A week ago I posted some pairs of similar flags on Twitter, and later I found that Mathematica’s CountryData database contains flag descriptions. So I thought I’d use the flag descriptions to see which flags Mathematica things are similar. For example, the FlagDescription attribute for Chad in Mathematica is Three equal vertical bands of blue […]The post Finding similar world flags with Mathematica first appeared on John D. Cook.
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 In this post we’re going […]The post Costas arrays first appeared on John D. Cook.
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 the games to be played. […]The post Balanced tournament designs first appeared on John D. Cook.
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 47 prefectures. Here is a […]The post Graphing Japanese Prefectures first appeared on John D. Cook.
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 United States. It’s easy to […]The post Classroom exercise with networks first appeared on John D. Cook.
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 graph. Each node corresponds to […]The post Adjacency networks first appeared on John D. Cook.
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 tours. The second was about […]The post Shortest tours of Eurasia and Oceania first appeared on John D. Cook.
Three tours of the Americas
The previous post looked at an optimal tour of continental Africa. This post will give analogous tours of continental North America, North American Islands, and South America. The next post looks at Eurasia and Oceania. North American Continent Here’s the North American continental tour. The order of the tour is as follows. Canada United States […]The post Three tours of the Americas first appeared on John D. Cook.
A traveling salesman tour of Africa
Suppose you’d like to tour Africa, visiting each country once, then returning to your starting point, minimizing the distance traveled. Here’s my first attempt at a solution using Mathematica, based on an example in the documentation for FindShortestTour. africa = CountryData["Africa"] FindShortestTour[africa] GeoGraphics[{Thick, Red, GeoPath[africa[[%[[2]]]]]}] This produced the following map: Hmm. Maybe I should have […]The post A traveling salesman tour of Africa first appeared on John D. Cook.
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 on a hyperbolic space like […]The post Trig in hyperbolic geometry first appeared on John D. Cook.
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 cosine at 1 by dividing […]The post Eliminating a Bessel function branch cut first appeared on John D. Cook.
...9101112131415161718...