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 04:47
Mentally calculating the day of the week
In my previous post I mentioned John Conway’s Doomsday rule for calculating the day of the week for any date. This method starts off very simple, but gets more complicated when you actually use it. This post will present an alternative method that’s easier to use in practice and can be described more succinctly. Here’s […]The post Mentally calculating the day of the week first appeared on John D. Cook.
John Conway and mental exercise rituals
John Horton Conway (1937–2020) came up with an algorithm in 1973 for mentally calculating what day of the week a date falls on. His method, which he called the “Doomsday rule” starts from the observation that every year, the dates 4/4. 6/6, 8/8, 10/10, 12/12, 5/9, 9/5, 7/11, and 11/7 fall on the same day […]The post John Conway and mental exercise rituals first appeared on John D. Cook.
Quartal melody: Star Trek fanfare
Intervals of a fourth, such as the interval from C to F, are common in western music, but consecutive intervals of this size are not. Quartal harmony is based on intervals of fourths, and quartal melodies use a lot of fourths, particularly consecutive fourths. Maybe the most famous quartal melody is the opening fanfare to […]The post Quartal melody: Star Trek fanfare first appeared on John D. Cook.
Why target ads at pregnant women
I’m listening to a podcast interviewing Neil Richards, the author of Why Privacy Matters. Richards makes a couple interesting points about the infamous example of Target figuring out which women were pregnant based on their purchase history. First, pregnancy is a point at which women are open to trying new things. So if a company […]The post Why target ads at pregnant women first appeared on John D. Cook.
Curiously simple approximations
As I’ve written about here and elsewhere, the following simple approximations are fairly accurate. log10 x ≈ (x-1)/(x+1) loge x ≈ 2 (x – 1)/(x + 1) log2 x ≈ 3(x – 1)/(x + 1) It’s a little surprising that each is as accurate as it is, but it’s also surprising that the approximations for […]The post Curiously simple approximations first appeared on John D. Cook.
Calculating where projective lines intersect
A couple days ago I wrote about homogeneous coordinates projective planes. I said that the lines y = 5 and y = 6 intersect in a point “at infinity.” In projective geometry any two distinct lines intersect in exactly one point, and you can compute that intersection point the same way, whether the intersection is […]The post Calculating where projective lines intersect first appeared on John D. Cook.
Random Blaschke products and Mathematica binding
A Blaschke product is a function that is the product of Blaschke factors, functions of the form b(z; a) = |a| (a – z) / a (1 – a*z) where the complex number a lies inside the unit circle and a* is the complex conjugate of a. I wanted to plot Blaschke products with random […]The post Random Blaschke products and Mathematica binding first appeared on John D. Cook.
Projective duality
The previous post explained how to define a projective plane over a field F. Now let’s look at how we do geometry in a projective plane. Definitions We have a definition of points from the other post: a point is a triple (a, b, c) of elements of F, with not all elements equal to […]The post Projective duality first appeared on John D. Cook.
Finite projective planes
Given a field F, finite or infinite, you can construct a projective plane over F by starting with pairs of elements of F and adding “points at infinity,” one point for each direction. Motivation: Bézout’s theorem A few days ago I mentioned Bézout’s theorem as an example of a simple theorem that rests on complex […]The post Finite projective planes first appeared on John D. Cook.
Fixed points of bilinear transformations
Introduction I was puzzled the first time I saw bilinear transformations, also known as Möbius transformations. I was in a class where everything had been abstract and general, and suddenly thing got very concrete and specific. I wondered why we had changed gears, and I wondered how there could be much to say about something […]The post Fixed points of bilinear transformations first appeared on John D. Cook.
Partitioning complexity
This post looks at how to partition complexity between definitions and theorems, and why it’s useful to be able to partition things more than one way. Quadratic equations Imagine the following dialog in an algebra class. “Quadratic equations always have two roots.” “But what about (x – 5)² = 0. That just has one root, […]The post Partitioning complexity first appeared on John D. Cook.
French palindromes and Morse code
I got an email from a student in France who asked about a French counterpart to my post on Morse code palindromes, and this post is a response to that email. Palindromes A palindrome is a word that remains the same when the letters are reversed, like kayak. A Morse code palindrome is a word […]The post French palindromes and Morse code first appeared on John D. Cook.
Blaschke factors
Blaschke factors are complex functions with specified zeros inside the unit disk. Given a complex number a with |a| < 1, the Blaschke factor associated with a is the function Notice the semicolon in b(z; a). This is a convention that a few authors follow, and that I wish more would adopt. From a purely […]The post Blaschke factors first appeared on John D. Cook.
Inversion in a circle
Inversion in the unit circle is a way of turning the circle inside-out. Everything that was inside the circle goes outside the circle, and everything that was outside the circle comes in. Not only is the disk turned inside-out, the same thing happens along each ray going out from the origin. Points on that ray […]The post Inversion in a circle first appeared on John D. Cook.
How flat is a normal mixture on top?
Male and female heights both have a standard deviation of about 3 inches, with means of 70 inches and 64 inches. That’s a good first-pass model using round numbers. If you ask what the height of an average adult is, not specifying male or female, you get a mixture of two normal distributions. If we […]The post How flat is a normal mixture on top? first appeared on John D. Cook.
Hilbert transform and Fourier series
A few days ago I wrote about the Hilbert transform and gave as an example that the Hilbert transform of sine is cosine. We’ll bootstrap that example to find the Hilbert transform of any periodic function from its Fourier series. The Hilbert transform of a function f(t) is a function fH(x) defined by where the […]The post Hilbert transform and Fourier series first appeared on John D. Cook.
Logarithms yearning to be free
I got an evaluation copy of The Best Writing on Mathematics 2021 yesterday. One article jumped out as I was skimming the table of contents: A Zeroth Power Is Often a Logarithm Yearning to Be Free by Sanjoy Mahajan. Great title. There are quite a few theorems involving powers that have an exceptional case that […]The post Logarithms yearning to be free first appeared on John D. Cook.
Circular slide rule
I explained the basics of how a slide rule works in the previous post. But how does a circular slide rule work? Apparently the prop Mr. Spock is holding is an E6B aircraft slide rule. It includes a circular slide rule and more functionality. Start with an ordinary straight slide rule, with each bar labeled […]The post Circular slide rule first appeared on John D. Cook.
Why a slide rule works
Suppose you have two sticks. The length of one is log x, and the length of the other is log y. If you put the two sticks end to end, the combined length is log x + log y = log xy. That’s the basic idea behind a slide rule. The simplest slide rule consists […]The post Why a slide rule works first appeared on John D. Cook.
Hilbert transform and Mathematica
The Hilbert transform of a function f(t) is a function fH(x) defined [1] by The integral must be interpreted in the sense of the Cauchy principal value: The integrand is not absolutely integrable because of the singularity at x and so the value of the integral depends on how you handle the singularity. The Cauchy […]The post Hilbert transform and Mathematica first appeared on John D. Cook.
Visual integration
The plot below is of a meromorphic function f(z). That is, the function f(z) is analytic except possibly at poles, and the colors represent the phase angles, the values of θ if you write the function values in polar form. What is the value of the integral where C is the perimeter of the square? […]The post Visual integration first appeared on John D. Cook.
Regular expressions and successive approximation
Regular expressions can do a lot of tasks in practice that they cannot do in theory. That’s because a particular application of regular expressions comes with context and with error tolerance. For example, much has been said about how regular expressions cannot parse HTML. This is strictly true, but it says nothing about how well […]The post Regular expressions and successive approximation first appeared on John D. Cook.
Sum the zeros of an analytic function without finding them first
A couple days ago I wrote about how Vieta’s formulas let you sum the zeros of a polynomial without having to first compute the zeros. This is especially handy for high-order polynomials since there is no explicit formula for the zeros. Most functions that arise in applications are not polynomials. How could you find the […]The post Sum the zeros of an analytic function without finding them first first appeared on John D. Cook.
Bounding zeros of an analytic function
The previous post looked at the problem of finding the zeros of a cubic polynomial. Assuming we’re going to use a numerical method to calculate the zero, the hard part is knowing where to tell the numerical method to look. That post showed how to use a change of variables to guarantee that the polynomial […]The post Bounding zeros of an analytic function first appeared on John D. Cook.
Numerically finding roots of a cubic
The analog of the quadratic formula for cubic equations is cumbersome. A lot of people naturally say “Forget all that. If I need to find the roots of a cubic, I’ll just use a numerical method like Newton’s method.” Sounds good. Where to start? But how do you know where to look for the roots? […]The post Numerically finding roots of a cubic first appeared on John D. Cook.
Mathematics and piano tuning
The following is a slightly edited version of a Twitter thread on @AlgebraFact. The lowest C on a piano is called C1 in scientific pitch notation. The C one octave up is C2 and so forth. Middle C is C4. The frequency of Cn is approximately 2n+4 Hz. This would be exact if C0 were […]The post Mathematics and piano tuning first appeared on John D. Cook.
Computing functions of roots without computing roots
Once in a while it’s necessary to calculate some function of the roots of a polynomial, and it may be possible to do this without first calculating the roots. Quadratics The quadratic formula gives explicit solutions to the equation The two solutions for x are where The awkward part is taking the square root of […]The post Computing functions of roots without computing roots first appeared on John D. Cook.
FWHM for a quadratic
This post contains a derives a result I needed recently. The derivation is simple but a little tedious, so I wanted to save it in case I need it again. Full width half maximum A common way to measure the width of a function peak in a function f(x) is to find the place x0 […]The post FWHM for a quadratic first appeared on John D. Cook.
Number slang and numbered lists
Here’s a list of five numbers used as slang in various contexts. Location (CB and police radio) End of column (journalism) Best wishes (ham radio) All aircraft in area (US Navy) I love you (text messages) The motivation for this post was an article Those HTML attributes you never use. I wanted to make a […]The post Number slang and numbered lists first appeared on John D. Cook.
Oscillations in RLC circuits
Electrical and mechanical oscillations satisfy analogous equations. This is the basis of using the word “analog” in electronics. You could study a mechanical system by building an analogous circuit and measuring that circuit in a lab. Mass, dashpot, spring Years ago I wrote a series of four posts about mechanical vibrations: Free, undamped vibrations Free, […]The post Oscillations in RLC circuits first appeared on John D. Cook.
How is portable AM radio possible?
The length of antenna you need to receive a radio signal is proportional to the signal’s wavelength, typically 1/2 or 1/4 of the wavelength. Cell phones operate at gigahertz frequencies, and so the antennas are small enough to hide inside the phone. But AM radio stations operate at much lower frequencies. For example, there’s a […]The post How is portable AM radio possible? first appeared on John D. Cook.
Applications of continued fractions
At first glance, continued fractions look more like a curiosity than like useful mathematics. And yet they come up surprisingly often in applications. For an irrational number x, the numbers you get by truncating the infinite continued fraction for x are the optimal rational approximations to x given the size of their denominators. For example, […]The post Applications of continued fractions first appeared on John D. Cook.
Smoothed step function
I mentioned smoothed step functions in the previous post. What would you do if you needed to concretely use a smoothed step function and not just know that one exists? We’ll look at smoothed versions of the signum function sgn(x) = x / |x| which equals -1 for negative x and +1 for positive x. […]The post Smoothed step function first appeared on John D. Cook.
Partitions of unity, smooth ramps, and CW clicks
Partitions of unity are a handy technical device. They’re seldom the focus of attention but rather are buried in the middle of proofs. The name sounds odd, but it’s descriptive. A partition of unity is a set of smooth functions into the interval [0, 1] that add up to 1 at every point. The functions […]The post Partitions of unity, smooth ramps, and CW clicks first appeared on John D. Cook.
Looking for the next prime
Suppose you start with some large number x and want to find a prime number at least as big as x. First you test whether x is prime. Then you test whether x + 1 is prime. Then you test whether x + 2 is prime, and so on until you find a prime. Of […]The post Looking for the next prime first appeared on John D. Cook.
Seed vault, but for code
I had heard of the Svalbard Global Seed Vault, but I hadn’t heard of the nearby Arctic World Archive until today. The latter contains source code preserved on film, a format that should last at least 500 years.The post Seed vault, but for code first appeared on John D. Cook.
Series for π
Here’s a curious series for π that I ran across on Math Overflow. In case you’re unfamiliar with the notation, n!! is n double factorial, the product of the positive integers up to n with the same parity as n. More on that here. When n is 0 or -1, n!! is defined to be […]The post Series for π first appeared on John D. Cook.
Morse code numbers and abbreviations
Numbers in Morse code seem a little strange. Here they are: |-------+-------| | Digit | Code | |-------+-------| | 1 | .---- | | 2 | ..--- | | 3 | ...-- | | 4 | ....- | | 5 | ..... | | 6 | -.... | | 7 | --... | | 8 […]The post Morse code numbers and abbreviations first appeared on John D. Cook.
Multiple Frequency Shift Keying
A few days ago I wrote about Frequency Shift Keying (FSK), a way to encode digital data in an analog signal using two frequencies. The extension to multiple frequencies is called, unsurprisingly, Multiple Frequency Shift Keying (MFSK). What is surprising is how MFSK sounds. When I first heard MFSK I immediately recognized it as an […]The post Multiple Frequency Shift Keying first appeared on John D. Cook.
Dial tone and busy signal
Henry Lowengard left a comment on my post Phone tones in musical notation mentioning dial tones and busy signals, so I looked these up. Tones According to this page, a dial tone in DTMF [1] is a chord of two sine waves at 350 Hz and 440 Hz. In musical notation: According to the same […]The post Dial tone and busy signal first appeared on John D. Cook.
Solar declination
This post expands on a small part of the post Demystifying the Analemma by M. Tirado. Apparent solar declination given δ by δ = sin-1( sin(ε) sin(θ) ) where ε is axial tilt and θ is the angular position of a planet. See Tirado’s post for details. Here I want to unpack a couple things […]The post Solar declination first appeared on John D. Cook.
Reverse engineering Fourier conventions
The most annoying thing about Fourier analysis is that there are many slightly different definitions of the Fourier transform. One time I got sufficiently annoyed that I creates a sort of Rosetta Stone of Fourier theorems under eight different conventions. Later I discovered that Mathematica supports these same eight definitions, but with slightly different notation. […]The post Reverse engineering Fourier conventions first appeared on John D. Cook.
Dividing an octave into 14 pieces
Keenan Pepper left a comment on my previous post saying that the DTMF tones used by touch tone phones “are actually quite close to 14 equal divisions of the octave (rather than the usual 12).” Let’s show that this is right using a little Python. import numpy as np freq = np.array([697, 770, 852, 941, […]The post Dividing an octave into 14 pieces first appeared on John D. Cook.
Phone tones in musical notation
The sounds produced by a telephone keypad are a combination of two tones: one for the column and one for the row. This system is known as DTMF (dual tone multiple frequency). I’ve long wondered what these tones would be in musical terms and I finally went to the effort to figure it out when […]The post Phone tones in musical notation first appeared on John D. Cook.
Frequency shift keying (FSK) spectrum
This post will look encoding digital data as an analog signal using frequency shift keying (FSK), first directly and then with windowing. We’ll look at the spectrum of the encoded signal and show that basic FSK uses much less bandwidth than direct encoding, but more bandwidth than FSK with windowing. Square waves The most natural […]The post Frequency shift keying (FSK) spectrum first appeared on John D. Cook.
Approximating the range of normal samples
On Monday I wrote a blog post that showed you can estimate the standard deviation of a set of data by first computing its range and then multiplying by a constant. The advantage is that it’s easy to compute a range, but computing a standard deviation in your head would be tedious to say the […]The post Approximating the range of normal samples first appeared on John D. Cook.
Order statistics for normal distributions
The last couple posts have touched on order statistics for normal random variables. I wrote the posts quickly and didn’t go into much detail, and more detail would be useful. Given two integers n ≥ r ≥ 1, define E(r, n) to be the rth order statistic of n samples from standard normal random variables. […]The post Order statistics for normal distributions first appeared on John D. Cook.
Range trick for larger sample sizes
The previous post showed that the standard deviation of a sample of size n can be well estimated by multiplying the sample range by a constant dn that depends on n. The method works well for relatively small n. This should sound strange: typically statistical methods work better for large samples, not small samples. And […]The post Range trick for larger sample sizes first appeared on John D. Cook.
Estimating standard deviation from range
Suppose you have a small number of samples, say between 2 and 10, and you’d like to estimate the standard deviation σ of the population these samples came from. Of course you could compute the sample standard deviation, but there is a simple and robust alternative Let W be the range of our samples, the […]The post Estimating standard deviation from range first appeared on John D. Cook.
Varicode
Varicode is a way of encoding text and control characters into binary using code words of variable length. It was developed as part of the PSK31 protocol for digital communication over amateur radio. In the spirit of Morse code, it uses short code words for common characters and longer code words for less common characters […]The post Varicode first appeared on John D. Cook.
...14151617181920212223...