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-21 21:48
Quasiperiodic functions
This post will distinguish between periodic, almost periodic, and quasiperiodic functions, and give examples of the latter. Definitions A function f is periodic with period T if f(x + T) = f(x) for all x. For example, trig functions are periodic. A function f is almost periodic with period T if f(x + T) ≈ […]The post Quasiperiodic functions first appeared on John D. Cook.
Rotating multiples of 37
If a three-digit number is divisible by 37, it remains divisible by 37 if you rotate its digits. For example, 148 is divisible by 37, and so are 814 and 481. This rotation property could make it easier to recognize multiples of 37 or easier to carry out trial division. Before proving the theorem, I’ll […]The post Rotating multiples of 37 first appeared on John D. Cook.
Recognizing squares
Suppose you’re given a number and you’d like to tell whether its a square, or at least you’d like to be able to determine quickly if it’s not a square. This post began as a thread I wrote on Twitter. For starters, the last digit of a square in base 10 must be 0, 1, […]The post Recognizing squares first appeared on John D. Cook.
Hénon’s dynamical system
This post will reproduce a three plots from a paper of Hénon on dynamical systems from 1969 [1]. Let α be a constant, and pick some starting point in the plane, (x0, y0), then update x and y according to xn+1 = xn cos α − (yn − xn²) sin α yn+1 = xn sin […]The post Hénon’s dynamical system first appeared on John D. Cook.
Mediant approximation trick
Suppose you are trying to approximate some number x and you’ve got it sandwiched between two rational numbers: a/b < x < c/d. Now you’d like a better approximation. What would you do? The obvious approach would be to take the average of a/b and c/d. That’s fine, except it could be a fair amount […]The post Mediant approximation trick first appeared on John D. Cook.
Lagrange multiplier setup: Now what?
Suppose you need to optimize, i.e. maximize or minimize, a function f(x). If this is a practical problem and not a textbook exercise, you probably need to optimize f(x) subject to some constraint on x, say g(x) = 0. Hmm. Optimize one function subject to a constraint given by another function. Oh yeah, Lagrange multipliers! […]The post Lagrange multiplier setup: Now what? first appeared on John D. Cook.
Avoid having to integrate by parts twice
Suppose f(x) and g(x) are functions that are each proportional to their second derivative. These include exponential, circular, and hyperbolic functions. Then the integral of f(x) g(x) can be computed in closed form with a moderate amount of work. The first time you see how such integrals are computed, it’s an interesting trick. I wrote […]The post Avoid having to integrate by parts twice first appeared on John D. Cook.
Good autocomplete
I’m not sure whether automatic text completion on a mobile device is a net good. It sometimes saves a few taps, but it seems like it’s at least as likely to cause extra work. Although I’m ambivalent about autocomplete on my phone, I like it in my text editor. The difference is that in my […]The post Good autocomplete first appeared on John D. Cook.
Small-scale automation
Saving keystrokes is overrated, but maintaining concentration is underrated. This post is going to look at automating small tasks in order to maintain concentration, not to save time. If a script lets you easily carry out some ancillary task without taking your concentration off your main task, that’s a big win. Maybe the script only […]The post Small-scale automation first appeared on John D. Cook.
Remove algorithmic filters from what you read
I typically announce new blog posts from my most relevant twitter account: data science from @DataSciFact, algebra and miscellaneous math from @AlgebraFact, TeX and typography from @TeXtip, etc. If you’d like to be sure that you’re notified of each post, regardless of what algorithms Twitter applies to your feed, you can subscribe to this blog […]The post Remove algorithmic filters from what you read first appeared on John D. Cook.
Number of bits in a particular integer
When I think of bit twiddling, I think of C. So I was surprised to read Paul Khuong saying he thinks of Common Lisp (“CL”). As always when working with bits, I first doodled in SLIME/SBCL: CL’s bit manipulation functions are more expressive than C’s, and a REPL helps exploration. I would not have thought […]The post Number of bits in a particular integer first appeared on John D. Cook.
Lemniscate of Bernoulli
The lemniscate of Bernoulli came up in a post a few days ago. This shape is a special case of a Cassini oval: ((x + a)² + y²) ((x – a)² + y²) = a4. Here’s another way to arrive at the lemniscate. Draw a hyperbola (blue in the figure below), then draw circles centered […]The post Lemniscate of Bernoulli first appeared on John D. Cook.
Van Aubel’s theorem
Van Aubel’s theorem is analogous to Napoleon’s theorem, though not a direct generalization of it. Napoleon’s theorem says to start with any triangle and draw equilateral triangles on each side. Connect the centers of the three new triangles, and you get an equilateral triangle. Now suppose you start with a quadrilateral and draw squares on […]The post Van Aubel’s theorem first appeared on John D. Cook.
Pythagorean triangles with side 2023
Can a Pythagorean triangle have one size of length 2023? Yes, one possibility is a triangle with sides (2023, 6936, 7225). Where did that come from? And can we be more systematic, listing all Pythagorean triangles with a side of length 2023? Euclid’s formula generates Pythagorean triples by sticking integers m and n into the […]The post Pythagorean triangles with side 2023 first appeared on John D. Cook.
Heat equation and the normal distribution
The density function of a normal distribution with mean 0 and standard deviation √(2kt) satisfies the heat equation. That is, the function satisfies the partial differential equation You could verify this by hand, or if you’d like, here’s Mathematica code to do it. u[x_, t_] := PDF[NormalDistribution[0, Sqrt[2 k t]], x] Simplify[ D[u[x, t], {t, […]The post Heat equation and the normal distribution first appeared on John D. Cook.
Airfoils
Here’s something surprising: You can apply a symmetric function to a symmetric shape and get something out that is not symmetric. Let f(z) be the average of z and its reciprocal: f(z) = (z + 1/z)/2. This function is symmetric in that it sends z and 1/z to the same value. It’s also symmetric in […]The post Airfoils first appeared on John D. Cook.
Oval orbits?
Johannes Kepler thought that planetary orbits were ellipses. Giovanni Cassini thought they were ovals. Kepler was right, but Cassini wasn’t far off. In everyday speech, people use the words ellipse and oval interchangeably. But in mathematics these terms are distinct. There is one definition of an ellipse, and several definitions of an oval. To be […]The post Oval orbits? first appeared on John D. Cook.
Cassini ovals
An ellipse can be defined as the set of points such that the sum of the distances to two fixed points, the foci, has a constant value. A Cassini oval is the set of points such that the product of the distances to two foci has a constant value. You can write down an equation […]The post Cassini ovals first appeared on John D. Cook.
Bounds on power series coefficients
Let f be an analytic function on the unit disk with f(0) = 0 and derivative f ′(0) = 1. If f is one-to-one (injective) then this puts a strict limit on the size of the series coefficients. Let an be the nth coefficient in the power series for f centered at 0. If f is one-to-one […]The post Bounds on power series coefficients first appeared on John D. Cook.
Probability problem with Pratt prime proofs
In the process of creating a Pratt certificate to prove that a number n is prime, you have to find a number a that seems kinda arbitrary. As we discussed here, a number n is prime if there exists a number a such that an-1 = 1 mod n and a(n-1)/p ≠ 1 mod n […]The post Probability problem with Pratt prime proofs first appeared on John D. Cook.
Factoring b^n + 1
The previous post illustrated a technique for finding factors of number of the form bn – 1. This post will look at an analogous, though slightly less general, technique for numbers of the form bn + 1. There is a theorem that says that if m divides n then bm + 1 divides bn + […]The post Factoring b^n + 1 first appeared on John D. Cook.
Factoring b^n – 1
Suppose you want to factor a number of the form bn – 1. There is a theorem that says that if m divides n then bm – 1 divides bn – 1. Let’s use this theorem to try to factor J = 22023 – 1, a 609-digit number. Factoring such a large number would be more difficult if it didn’t have […]The post Factoring b^n – 1 first appeared on John D. Cook.
Converting between barycentric and trilinear coordinates
Barycentric coordinates describe the position of a point relative to the three vertices of a triangle. Trilinear coordinates describe the position of a point relative to the three sides of a triangle. It’s surprisingly simple to convert from one to the other. Why should this be surprising? Because the distance from a point to a […]The post Converting between barycentric and trilinear coordinates first appeared on John D. Cook.
Special primality proofs
I’ve written lately about two general ways to prove that a number is prime: Pratt certificates for moderately-large primes and elliptic curve certificates for very large primes. If you can say more about the prime you wish to certify, there may be special forms of certificates that are more efficient. In particular, there are efficient […]The post Special primality proofs first appeared on John D. Cook.
Zeta sum vs zeta product
The Riemann zeta function ζ(s) is given by an infinite sum and an infinite product for complex numbers s with real part greater than 1 [*]. The infinite sum is equal to the infinite product, but which would give you more accuracy: N terms of the sum or N terms of the product? We’ll take […]The post Zeta sum vs zeta product first appeared on John D. Cook.
Approximating pi with Bernoulli numbers
In a paper on arXiv Simon Plouffe gives the formula which he derives from an equation in Abramowitz and Stegun (A&S). It took a little while for me to understand what Plouffe intended. I don’t mean my remarks here to be criticism of the author but rather helpful hints for anyone else who might have […]The post Approximating pi with Bernoulli numbers first appeared on John D. Cook.
Reverse engineering options
This weekend I saw a sign in the window of a Burger King™ that made me think of an interesting problem. If you know the number of possibilities like this, how would you reverse engineer what the options that created the possibilities? In the example above, there are 211,184 = 213×33 possible answers, and so […]The post Reverse engineering options first appeared on John D. Cook.
Foreshadowing Page Rank
Douglas Hofstadter, best known as the author of Godel, Escher, Bach, wrote the foreword to Clark Kimberling’s book Triangle Centers and Central Triangles. Hofstadter begins by saying that in his study of math he “sadly managed to sidestep virtually all of geometry” and developed an interest in geometry, specifically triangle centers, much later. The ancient […]The post Foreshadowing Page Rank first appeared on John D. Cook.
Third order ordinary differential equations
Most applied differential equations are second order. This probably has something to do with the fact that Newton’s laws are second order differential equations. Higher order equations are less common in application, and when they do pop up they usually have even order, such as the 4th order beam equation. What about 3rd order equations? […]The post Third order ordinary differential equations first appeared on John D. Cook.
Proof of optimization
Suppose you hire me to solve an optimization problem for you. You want me to find the value of x that minimizes f(x). I go off and work on finding the best value of x. I report back what I found, and you might say “Thanks, That’s a good value of x. But how do […]The post Proof of optimization first appeared on John D. Cook.
Elliptic curve primality certificates
I’ve written recently about a simple kind of primality certificates, Pratt certificates. These certificates are easy to understand, and easy to verify, but they’re expensive to produce. In order to produce a Pratt certificate that n is a prime you have to factor n-1, and that can take a long time if n is large […]The post Elliptic curve primality certificates first appeared on John D. Cook.
Primes with two non-zero bits
Suppose a number n written in binary has two 1s and all the rest of its bits are zeros. If n is prime, then the 1s must be the first and last bits of n. The first bit is 1 because the first bit of every positive integer is 1. The last bit is 1 […]The post Primes with two non-zero bits first appeared on John D. Cook.
Certified sonnet primes
Last week I wrote about primailty certificates. These certificates offer a way to verify that a number is prime using less computation than was used to discover than the number was prime. This post gives a couple more examples of primality certificates using sonnet primes. As described here, These are primes of the form ababcdcdefefgg, […]The post Certified sonnet primes first appeared on John D. Cook.
Self-documenting software
The electricity went out for a few hours recently, and because the power was out, the internet was out. I was trying to do a little work on my laptop, but I couldn’t do what I intended to do because I needed a network connection to access some documentation. I keep offline documentation for just […]The post Self-documenting software first appeared on John D. Cook.
Approximating 1/Γ(x)
A few days ago a comment that a graph looked like a Maxwell-Boltzman density lead to an approximation of 1/Γ(x), possibly a useful approximation. Approximating Γ(x) is a well-known problem, and for large x the solution is to use Stirling’s approximation or a few more terms from the asymptotic series that Stirling’s approximation is a […]The post Approximating 1/Γ(x) first appeared on John D. Cook.
Euler line
The previous post discussed the circumcenter and orthocenter of a triangle. Euler proved that the centroid, circumcenter, and orthocenter all fall on a common line, now called the Euler line. The centroid is the center of mass of a triangle. If you draw lines from each vertex to the midpoint of the opposite side, the […]The post Euler line first appeared on John D. Cook.
Relating circumcenter and orthocenter
The previous post mentioned that the law of sines gives you the diameter of a circle through the vertices of a triangle. How would you find the center of this circle, the blue dot in the image above? If the angles of the triangle are α. β, and γ, then the trilinear coordinates of the […]The post Relating circumcenter and orthocenter first appeared on John D. Cook.
Computing inscribed radius and circumscribed radius
A few days ago I wrote about the law of cotangents. This law says that if we label the sides of a triangle a, b, c and label the angles opposite each side α. β, γ, then where s is the semi-parameter, i.e. and r is the radius of the incircle, the largest circle that […]The post Computing inscribed radius and circumscribed radius first appeared on John D. Cook.
Maxwell-Boltzmann and Gamma
When I shared an image from the previous post on Twitter, someone who goes by the handle Nonetheless made the astute observation that image looked like the Maxwell-Boltzmann distribution. That made me wonder what 1/Γ(x) would be like turned into a probability distribution, and whether it would be approximately like the Maxwell-Boltzmann distribution. (Here I’m […]The post Maxwell-Boltzmann and Gamma first appeared on John D. Cook.
Visualizing convergence of an infinite product
A little while ago I wrote a post looking at how the infinite product for sine converges. The plot of the error terms is both mathematically and aesthetically interesting. This post will look at similar plots for the reciprocal of the gamma function. The reciprocal of the gamma function is an entire function, i.e. is […]The post Visualizing convergence of an infinite product first appeared on John D. Cook.
Rational Trigonometry
Rational trigonometry is a very different way of looking at geometry. At its core are two key ideas. First, instead of distance, do all your calculations in terms of quadrance, which is distance squared. Second, instead of using angles to measure the separation between lines, use spread., which turns out to be the square of […]The post Rational Trigonometry first appeared on John D. Cook.
Hidden messages in music
Geoff Lindsey contacted me recently to ask whether he could use the sheet music from one of my blog posts in a video he was making on Morse code snippets hidden in music. The sheet music appears about a minute into the video. After watching the video, his previious video played, a video about words […]The post Hidden messages in music first appeared on John D. Cook.
Law of cotangents
The previous post commented that the law of tangents is much less familiar than the laws of sines and cosines. The law of cotangents is even more obscure. If you ask Google’s Ngram viewer to plot occurrences of “law of cotangents” over time, it will return “Ngrams not found: law of cotangents.” What is this […]The post Law of cotangents first appeared on John D. Cook.
Law of tangents
I would have thought that the laws of sines, cosines, and tangents were all about equally familiar, but apparently that is not the case. Here’s a graph from Google’s Ngram viewer comparing the frequencies of law of sines, law of cosines, and law of tangents. As of 2019, the number of references to the laws […]The post Law of tangents first appeared on John D. Cook.
Pratt Primality Certificates
The previous post implicitly asserted that J = 8675309 is a prime number. Suppose you wanted proof that this number is prime. You could get some evidence that J is probably prime by demonstrating that 2J-1 = 1 mod J. You could do this in Python by running the following [1]. >>> J = 8675309 […]The post Pratt Primality Certificates first appeared on John D. Cook.
Quadratic reciprocity algorithm
The quadratic reciprocity theorem addresses the question of whether a number is a square modulo a prime. For an odd prime p, the Legendre symbol is defined to be 0 if a is a multiple of p, 1 if a is a (non-zero) square mod p, and -1 otherwise. It looks like a fraction, but […]The post Quadratic reciprocity algorithm first appeared on John D. Cook.
Groups of order 2023
How many groups are there with 2023 elements? There’s obviously at least one: Z2023, the integers mod 2023. Now 2023 = 7 × 289 = 7 × 17 × 17 and so we could also look at Z7 + Z17 + Z17 where + denotes direct sum. An element of this group has the form […]The post Groups of order 2023 first appeared on John D. Cook.
Sinc approximation to Bessel function
The Bessel functions Jn for even n look something like the sinc function. How well can you approximate the former by sums of the latter? To make things concrete, we’ll approximate J2. Here’s a plot of J2. And here’s a plot of sinc(x) = sin(πx)/πx. The sinc approximation for a function f(x) is given by […]The post Sinc approximation to Bessel function first appeared on John D. Cook.
A dozen magic square posts
Chess-related A knight’s tour magic square A king’s tour magic square Language-related Alphamagic squares in English Alphamagic squares in French Alphamagic squares in Spanish Planet-related Mars Jupyter More mathematical Magic square of squares Magic square of primes Magic squares as matrices Magical permutations Greco-Latin squares and magic squaresThe post A dozen magic square posts first appeared on John D. Cook.
Airport abbreviation origins
It doesn’t take much imagination to understand why DEN is the IATA abbreviation for the Denver airport, but the abbreviation MCO for the Orlando airport is more of a head scratcher. Here is a list of the busiest airports in the US along with a brief indication of the reason behind their abbreviations. Some require […]The post Airport abbreviation origins first appeared on John D. Cook.
...891011121314151617...