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 06:31
Catenary kiln
Will Buckner sent me an email with the following question recently. (I’m sharing this with permission.) I am building a kiln using a catenary arch. The rear wall and front wall/door will be vertical and fill in the space under the arch, which has the dimensions of 41″W x 39.5″H. I need the area within […]The post Catenary kiln first appeared on John D. Cook.
Connecting powers of two and decibels
Colin Wright pointed out a pattern in my previous post that I hadn’t seen before. He wrote about it here a couple years ago. Start with the powers of 2 from the top of the post: 21 = 2 22 = 4 23 = 8 24 = 16 25 = 32 26 = 64 27 […]The post Connecting powers of two and decibels first appeared on John D. Cook.
100 digits worth memorizing
I was thinking today about how people memorize many digits of π, and how it would be much more practical to memorize a moderate amount of numbers to low precision. So suppose instead of memorizing 100 digits of π, you memorized 100 digits of other numbers. What might those numbers be? I decided to take […]The post 100 digits worth memorizing first appeared on John D. Cook.
Morse code in musical notation
Maybe this has been done before, but I haven’t seen it: Morse code in musical notation. Here’s the Morse code alphabet, one letter per measure; in practice there would be less space between letters [1]. A dash is supposed to be three times as long as a dot, so a dot is a sixteenth note […]The post Morse code in musical notation first appeared on John D. Cook.
Find log normal parameters for given mean and variance
Earlier today I needed to solve for log normal parameters that yield a given mean and variance. I’m going to save the calculation here in case I needed in the future or in case a reader needs it. The derivation is simple, but in the heat of the moment I’d rather look it up and […]The post Find log normal parameters for given mean and variance first appeared on John D. Cook.
Q codes in Seveneves
The first time I heard of Q codes was when reading the novel Seveneves by Neal Stephenson. These are three-letter abbreviations using in Morse code that all begin with Q. Since Q is always followed by U in native English words, Q can be used to begin a sort of escape sequence [1]. There are […]The post Q codes in Seveneves first appeared on John D. Cook.
Algorithms at Work
Brian Christian and Tom Griffiths have just published a new book, Algorithms at Work. You can hear me talking about queues in Episode 2. More on queueing theory What happens when you add a new teller? Queueing and economies of scale Upper bound on wait timesThe post Algorithms at Work first appeared on John D. Cook.
What use is mental math in 2022?
Now that most people are carrying around a powerful computer in their pocket, what use is it to be able to do math in your head? Here’s something I’ve noticed lately: being able to do quick approximations in mid-conversation is a superpower. When I’m on Zoom with a client, I can’t say “Excuse me a […]The post What use is mental math in 2022? first appeared on John D. Cook.
Missing Morse codes
Morse codes for Latin letters are sequences of between one and four symbols, where each symbol is a dot or a dash. There are 2 possible sequences with one symbol, 4 with two symbols, 8 with three symbols, and 16 with four symbols. This makes a total of 30 sequences with up to four symbols. […]The post Missing Morse codes first appeared on John D. Cook.
Almost periodic functions
When you see the word “almost” in a mathematical context, it might be used informally, but often it has a precise meaning. I wrote about this before in the post Common words that have a technical meaning. Often the technical meaning of “almost” is “within any finite tolerance.” That’s how it is used in the […]The post Almost periodic functions first appeared on John D. Cook.
2s, 5s, and decibels
Last night I ran across a delightful Twitter thread by Nathan Mishra-Linger that starts out by saying It’s nice that 2^7 ≈ 5^3, because that lets you approximate any integer valued decibel quantity as a product of powers of 2 and 5. The observation that 27 ≈ 53, is more familiar if you multiply both […]The post 2s, 5s, and decibels first appeared on John D. Cook.
A Bayesian approach to pricing
Suppose you want to determine how to price a product and you initially don’t know what the market is willing to pay. This post outlines some of the things you might think about, and how Bayesian modeling might help. This post is not the final word on the subject, or even my final word on […]The post A Bayesian approach to pricing first appeared on John D. Cook.
Chaos in the frequency domain
Solutions to the non-linear differential equation x ″ + 0.25x ′ + x(x² – 1) = 0.3 cos t are chaotic. It’s more common to see plots of chaotic systems in the time domain, so I wanted to write a post looking at the power spectrum in the frequency domain. The following plot was created by solving […]The post Chaos in the frequency domain first appeared on John D. Cook.
The tent map
Yesterday I said that Lyapunov exponents can’t be calculated exactly except in the case of toy problems. One such toy model is the tent map. The graph of function on the right hand side looks a tent. It’s zero at x = 0 and at x = 1 and rises to a height of r […]The post The tent map first appeared on John D. Cook.
Aliasing in a nutshell
Suppose you have a sine wave with frequency f0 Hz. We’re going to discretize this signal by sampling it fs times per second. That is, we’re going to evaluate S at integer multiples of The result is the sequence where n runs through the integers. Next, let k be an integer and consider the sine […]The post Aliasing in a nutshell first appeared on John D. Cook.
Lyapunov exponents
Chaotic systems are unpredictable. Or rather chaotic systems are not deterministically predictable in the long run. You can make predictions if you weaken one of these requirements. You can make deterministic predictions in the short run, or statistical predictions in the long run. Lyapunov exponents are a way to measure how quickly the short run […]The post Lyapunov exponents first appeared on John D. Cook.
Self-orthogonal vectors and coding
One of the surprising things about linear algebra over a finite field is that a non-zero vector can be orthogonal to itself. When you take the inner product of a real vector with itself, you get a sum of squares of real numbers. If any element in the sum is positive, the whole sum is […]The post Self-orthogonal vectors and coding first appeared on John D. Cook.
Ternary Golay code in Python
Marcel Golay discovered two “perfect” error-correcting codes: one binary and one ternary. These two codes stick out in the classification of perfect codes [1]. The ternary code is a linear code over GF(3), the field with three elements. You can encode a list of 5 base-three digits by multiplying the list as a row vector […]The post Ternary Golay code in Python first appeared on John D. Cook.
A closer look at zero spacing
A few days ago I wrote about Kneser’s theorem. This theorem tells whether the differential equation u ″(x) + h(x) u(x) = 0 will oscillate indefinitely, i.e. whether it will have an infinite number of zeros. Today’s post will look at another theorem that gives more specific information about the spacing of the zeros. Kneser’s theorem […]The post A closer look at zero spacing first appeared on John D. Cook.
Associahedron
The previous post looked at ways of associating a product of four things. This post will look at associating more things, and visualizing the associations. The number of ways to associate a product of n+1 things is the nth Catalan number, defined by The previous post looked at products of 4 things, and there are […]The post Associahedron first appeared on John D. Cook.
Non-associative multiplication
There are five ways to parenthesize a product of four things: ((ab)c)d (ab)(cd) (a(b(cd)) (a(bc))d (a((bc)d) In a context where multiplication is not associative, the five products above are not necessarily the same. Maybe all five are different. This post will give two examples where the products above are all different: octonions and matrix multiplication. […]The post Non-associative multiplication first appeared on John D. Cook.
Slowing oscillations
Consider the second order linear differential equation You could think of y as giving the height of a mass attached to a spring at time t where k is the stiffness of the spring. The solutions are sines and cosines with frequency √k. Think about how the solution depends on the spring constant k. If […]The post Slowing oscillations first appeared on John D. Cook.
Mental math trick and deeper issues
I’d like to do two things in this post. I’ll present a fun bit of mental math, then use it to illustrate a few deeper points. The story starts with a Twitter thread I wrote on @AlgebraFact. The Strait of Gibraltar is 13 km wide. How wide is that in miles? You can convert km […]The post Mental math trick and deeper issues first appeared on John D. Cook.
Information in a discretized normal
Here’s a problem that came up in my work today. Suppose you have a normal random variable X and you observe X in n discrete bins. The first bin is the left α tail, the last bin is the right α tail, and the range between the two tails is divided evenly into n-2 intervals. […]The post Information in a discretized normal first appeared on John D. Cook.
A general theory of sub-things
When I took my first abstract algebra course, we had a homework question about subgroups. Someone in the class whined that the professor hadn’t told us yet what a subgroup was. My immediate thought was “I bet you could guess. Sub things are all the same. A sub-X is an X contained inside another X. […]The post A general theory of sub-things first appeared on John D. Cook.
How to subscribe
I so despise pop-ups asking me to subscribe to a site’s newsletter that I’ve probably erred on the side of making it too hard to find out how to subscribe to this blog. At the bottom of the “writing” menu is a subscribe link. You can subscribe three different ways: Subscribe to posts via RSS […]The post How to subscribe first appeared on John D. Cook.
Non-equivalent floating point numbers
Here’s an interesting paragraph from Handbook of Floating Point Arithmetic by Jean-Michel Muller et al. Many common transformations of a code into some naively equivalent code become impossible if one takes into account special cases such as NaNs, signed zeros, and rounding modes. For instance, the expression x + 0 is not equivalent to the expression x […]The post Non-equivalent floating point numbers first appeared on John D. Cook.
Temporal and polymodal logics
My posts on modal logic have mostly been about monomodal logic, logic with one modal operator. This may not seem accurate because I’ve talked about □ (“box”) and ◇ (“diamond”). But these are really just one mode: you can define either in terms of the other. ◇p = ¬ □ ¬p □p = ¬ ◇ […]The post Temporal and polymodal logics first appeared on John D. Cook.
Permutations at the command line
Yesterday I wrote about how you could use the tr utility to find the dual of a modal logic expression. Today I’ll show how you could use tr to work with permutations. This post is a hack, and that’s the fun of it. In the logic post we were using tr to swap characters. More […]The post Permutations at the command line first appeared on John D. Cook.
Look up HTML entity or Unicode
Fairly often I want to find out whether there is an HTML entity for a given Unicode character, or given an HTML entity I want to look up its Unicode value. For example, ∃ has Unicode value U+2203. I might want to look up whether there is an HTML entity for this. There is, and […]The post Look up HTML entity or Unicode first appeared on John D. Cook.
Complex analysis calendar
My recent post Reading plots of a complex function was based on ideas from a book by Elias Wegert. Thanks to a comment on that post I discovered that Wegert and his colleagues have put out a 2022 calendar with images created from plots of complex functions. This year’s calendar, and previous calendars going back […]The post Complex analysis calendar first appeared on John D. Cook.
Dual axioms in modal logic
Axioms in modal logic often say that one sequence of boxes and diamonds in front of a proposition p implies another sequence of boxes and diamonds in front of p. For example, Axiom 4 says □ p → □□ p and Axiom 5 says ◇p → □◇p. Every axiom has a dual form. The dual […]The post Dual axioms in modal logic first appeared on John D. Cook.
Word problems, logic, and regular expressions
Word problems Suppose you have a sequence of symbols and a set of rewriting rules for replacing some patterns of symbols with others. Now you’re given two such sequences. Can you tell whether there’s a way to turn one of them into the other? This is known as the word problem, and in general it’s […]The post Word problems, logic, and regular expressions first appeared on John D. Cook.
Modal axioms and rules for interplanetary travel
The previous post pointed out the analogy between models for modal logic (i.e. Kripke semantics) and science fiction. Rules for relationships between points in a Kripke model are analogous to rules for interplanetary travel in a fictional universe. This post will expand on this last point. The following cube shows the relationships between eight different […]The post Modal axioms and rules for interplanetary travel first appeared on John D. Cook.
Modal Logic and Science Fiction
Modal logic extends classical logic by adding one or more modes. If there’s only one mode, it’s usually denoted □. Curiously, □ can have a wide variety of interpretations, and different interpretations motivate different axioms for how □ behaves. Modal logic is not one system but an infinite number of systems, depending on your choice […]The post Modal Logic and Science Fiction first appeared on John D. Cook.
Reading plots of a complex function
This post is about understanding the following plot. If you’d like to read more along these lines, see [1]. The plot was made with the following Mathematica command. ComplexPlot[HankelH1[3, z], {z, -8 - 4 I, 4 + 4 I}, ColorFunction -> "CyclicArg", AspectRatio -> 1/2] The plot uses color to represent the phase of the […]The post Reading plots of a complex function first appeared on John D. Cook.
Glasser’s function
I recently ran across an article on MathWorld about Glasser’s function. The function is defined by Here’s a plot of G(x) along with its asymptotic value 2√(x/π). This plot was made with the following Mathematica commands. G[x_] := NIntegrate[Sin[t Sin[t]], {t, 0, x}] Plot[{G[x], 2 Sqrt[x/Pi]}, {x, 0, 20}] According to MathWorld, The integral cannot […]The post Glasser’s function first appeared on John D. Cook.
Upper bound on wait time for general queues
The previous post presented an approximation for the steady-state wait time in queue with a general probability distribution for inter-arrival times and for service times, i.e. a G/G/s queue where s is the number of servers. This post will give an upper bound for the wait time. Let σ²A be the variance on the inter-arrival […]The post Upper bound on wait time for general queues first appeared on John D. Cook.
Multiserver queues with general probability distributions
Textbook presentations of queueing theory start by assuming that the time between customer arrivals and the time to serve a customer are both exponentially distributed. Maybe these assumptions are realistic enough, but maybe not. For example, maybe there’s a cutoff on service time. If someone takes too long, you tell them there’s no more you […]The post Multiserver queues with general probability distributions first appeared on John D. Cook.
Queueing and Economies of Scale
If a single server is being pushed to the limit, adding a second server can drastically reduce wait times. This is true whether the server is a human serving food or a computer serving web pages. I first wrote about this here and I give more details here. What if you add an extra server […]The post Queueing and Economies of Scale first appeared on John D. Cook.
Linear logic arithmetic
Linear logic has connectives not used in classical logic. The connectives ⊗and & are conjunctions, ⊕ and ⅋ are disjunctions, and ! and ? are analogous to the modal operators ◻ and ◇ (necessity and possibility). Another way to classify the connectives is to say ⊕ and & are called additive, ⊗ and ⅋ are […]The post Linear logic arithmetic first appeared on John D. Cook.
Self-Orthogonal Latin Squares
The other day I wrote about orthogonal Latin squares. Two Latin squares are orthogonal if the list of pairs of corresponding elements in the two squares contains no repeats. A self-orthogonal Latin square (SOLS) is a Latin square that is orthogonal to its transpose. Here’s an example of a self-orthogonal Latin square: 1 7 6 […]The post Self-Orthogonal Latin Squares first appeared on John D. Cook.
Better parts, worse system
There’s a rule of systems thinking that improving part of a system can often make the system as a whole worse. One example of this is Braess’ Paradox that adding roads can make traffic worse, and closing roads can improve traffic. Another example is the paradox of enrichment: Increasing the food available to an ecosystem […]The post Better parts, worse system first appeared on John D. Cook.
Queueing theory equations
A blog post about queueing theory that I wrote back in 2008 continues to be popular. The post shows that when a system is close to capacity, adding another server dramatically reduces the wait time. In that example, going from one teller to two tellers doesn’t make service twice as fast but 93 times as […]The post Queueing theory equations first appeared on John D. Cook.
Swanson’s rule of thumb
Swanson’s rule of thumb [1] says that the mean of a moderately skewed probability distribution can be approximated by the weighted average of the 10th, 50th, and 90th percentile, with weights 0.3, 0.4, and 0.3 respectively. Because it is based on percentiles, the rule is robust to outliers. Swanson’s rule is used in the oil […]The post Swanson’s rule of thumb first appeared on John D. Cook.
Random sampling to save money
I was stunned when my client said that a database query that I asked them to run would cost the company $100,000 per year. I had framed my question in the most natural way, not thinking that at the company’s scale it would be worth spending some time thinking about the query. Things have somewhat […]The post Random sampling to save money first appeared on John D. Cook.
Greco-Latin squares and magic squares
Suppose you create an n × n Latin square filled with the first n letters of the Roman alphabet. This means that each letter appears exactly once in each row and in each column. You could repeat the same exercise only using the Greek alphabet. Is it possible to find two n × n Latin […]The post Greco-Latin squares and magic squares first appeared on John D. Cook.
Latin squares and 3D chess
In a n×n Latin square, each of the numbers 1 through n appears exactly once in each row and column. For example, the 5 × 5 square below is a Latin square. If we placed a rook on each square numbered 1, the rooks would not attack each other since no two rooks would be […]The post Latin squares and 3D chess first appeared on John D. Cook.
New R book
Five years ago I recommended the book Learning Base R. Here’s the last paragraph of my review: Now there are more books on R, and some are more approachable to non-statisticians. The most accessible one I’ve seen so far is Learning Base R by Lawrence Leemis. It gets into statistical applications of R—that is ultimately why […]The post New R book first appeared on John D. Cook.
Computational asceticism
A while back I wrote about computational survivalism, being prepared to work productively in a restricted environment. The first time I ran into computational survivalism was when someone said to me “I prefer Emacs, but I use vi because I only want to use tools I can count on being installed everywhere.” I thought that […]The post Computational asceticism first appeared on John D. Cook.
...15161718192021222324...