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 2025-04-19 13:31
Sum of divisor powers
The function σk takes an integer n and returns the sum of the kth powers of divisors of n. For example, the divisors of 14 are 1, 2, 4, 7, and 14. If we set k = 3 we get σ3(n) = 1³ + 2³ + 4³ + 7³ + 14³ = 3096. A couple […]The post Sum of divisor powers first appeared on John D. Cook.
An almost integer pattern in many bases
A few days ago I mentioned a passing comment in video by Richard Boucherds. This post picks up on another off-hand remark from that post. Boucherds was discussing why exp(π √67) and exp(π √163) are nearly an integer. exp(π √67) = 147197952744 – ε1 exp(π √163) = 262537412640768744 – ε2 where ε1 and ε2 and […]The post An almost integer pattern in many bases first appeared on John D. Cook.
Org entities
This morning I found out that Emacs org-mode has its own markdown entities, analogous to HTML entities or LaTeX commands. Often they’re identical to LaTeX commands. For example, \approx is the approximation symbol ≈, exactly as in LaTeX. So what’s the advantage of org-entities? In fact, how does Emacs even know whether \approx is a […]The post Org entities first appeared on John D. Cook.
How big is the monster?
Symmetries are captured by mathematical groups. And just as you can combine kinds symmetry to form new symmetries, you can combine groups to form new groups. So-called simple groups are the building blocks of groups as prime numbers are the building blocks of integers [1]. Finite simple groups have been fully classified, and they fall […]The post How big is the monster? first appeared on John D. Cook.
Square waves and cobwebs
This is a follow-up to yesterday’s post. In that post we looked at iterates of the function f(x) = exp( sin(x) ) and noticed that even iterations of f converged to a square wave. Odd iterates also converge to a square wave, but a different one. The limit of odd iterations is the limit of […]The post Square waves and cobwebs first appeared on John D. Cook.
Unexpected square wave
Last night a friend from Vanderbilt, Father John Rickert, sent me a curious math problem. (John was a PhD student in the math department while I was a postdoc. He went on to be a Catholic priest after graduating.) He said that if you look at iterates of f(x) = exp( sin(x) ) the plots […]The post Unexpected square wave first appeared on John D. Cook.
Not quite going in circles
Sometimes you feel like you’re running around in circles, not making any progress, when you’re on the verge of a breakthrough. An illustration of this comes from integration by parts. A common example in calculus classes is to integrate ex sin(x) using integration by parts (IBP). After using IBP once, you get an integral similar […]The post Not quite going in circles first appeared on John D. Cook.
Transliterating Hebrew
Yesterday I wrote about cjhebrew, a LaTeX package that lets you insert Hebrew text by using a sort of transliteration scheme. That reminded me of unidecode, a Python package for transliterating Unicode to ASCII, that I wrote about before. I wondered how the two compare, and so this post will answer that question. Transliteration is […]The post Transliterating Hebrew first appeared on John D. Cook.
Permutable polynomials
Two polynomials p(x) and q(x) are said to be permutable if p(q(x)) = q(p(x)) for all x. It’s not hard to see that Chebyshev polynomials are permutable. First, Tn(x) = cos (n arccos(x)) where Tn is the nth Chebyshev polyomial. You can take this as a definition, or if you prefer another approach to defining […]The post Permutable polynomials first appeared on John D. Cook.
Including a little Hebrew in an English LaTeX document
I was looking up how to put a little Hebrew inside a LaTeX document and ran across a good answer on tex.stackexchange. Short answer: use the cjhebrew package. In a nutshell, you put your Hebrew text between \< and > using the cjhebrew package’s transliteration. You write left-to-right, and the text will appear right-to-left. For […]The post Including a little Hebrew in an English LaTeX document first appeared on John D. Cook.
All English vowel sounds in one sentence
Contrary to popular belief, English has more than five or ten vowel sounds. The actual number is disputed because of disagreements over when two sounds are sufficiently distinct to be classified as separate sounds. I’ve heard some people say 15, some 17, some over 20. I ran across a podcast episode recently that mentioned a […]The post All English vowel sounds in one sentence first appeared on John D. Cook.
Three notations by Iverson
The floor of y is the greatest integer less than or equal to y and is denoted ⌊y⌋. Similarly, the ceiling of y is the smallest integer greater than or equal to y and is denoted ⌈y⌉. Both of these notations were introduced by Kenneth Iverson. Before Iverson’s notation caught on, you might see [x] for […]The post Three notations by Iverson first appeared on John D. Cook.
Entering symbols in Emacs
Emacs has a relatively convenient way to add accents to letters or to insert a Unicode character if you know the code point for the value. See these notes. But usually you don’t know the Unicode values of symbols. Then what do you do? TeX commands You enter symbols by typing their corresponding TeX commands […]The post Entering symbols in Emacs first appeared on John D. Cook.
Adding phase-shifted sine waves
Suppose you have two sinusoidal functions with the same frequency ω but with different phases and different amplitudes: f(t) = A sin(ωt) and g(t) = B sin(ωt + φ). Then their sum is another sine wave with the same frequency h(t) = C sin(ωt + ψ). Note that this includes cosines as a special case […]The post Adding phase-shifted sine waves first appeared on John D. Cook.
A different kind of computational survival
Last year I wrote a post about being a computational survivalist, someone able to get their work done with just basic command line tools when necessary. This post will be a different take on the same theme. I just got a laptop from an extremely security-conscious client. I assume it runs Windows 10 and that […]The post A different kind of computational survival first appeared on John D. Cook.
Multiply, divide, and floor
Let n be a positive integer and x any real number. If you multiply x by n, then divide by n, of course you get x back. Now suppose you multiply x by n, round down, then divide by n, and round down again. Do you get x back? Not necessarily. The last step rounds down […]The post Multiply, divide, and floor first appeared on John D. Cook.
Continued fractions with period 1
A while back I wrote about continued fractions of square roots. That post cited a theorem that if d is not a perfect square, then the continued fraction representation of d is periodic. The period consists of a palindrome followed by 2⌊√d⌋. See that post for details and examples. One thing the post did not […]The post Continued fractions with period 1 first appeared on John D. Cook.
A bevy of ones
Take any positive integer d that is not a multiple of 2 or 5. Then there is some integer k such that d × k has only 1’s in its decimal representation. For example, take d = 13. We have 13 × 8457 = 111111. Or if we take d = 27, 27 × 4115226337448559670781893 = […]The post A bevy of ones first appeared on John D. Cook.
Symbol pronunciation
I was explaining to someone this evening that I’m in the habit of saying “bang” rather than “exclamation point.” Here’s a list of similar nicknames for symbols. These nicknames could complement the NATO phonetic alphabet if you needed to read symbols out loud, say over the phone. You might, for example, pronounce “HL&P” as “Hotel […]
Is there a zip code that equals its population?
I noticed yesterday that the population in a zip code near me is roughly equal to the zip code itself. So I wondered: Does any zip code equal its population? Yes, it’s a silly question. A zip code isn’t a quantity. Populations are always changing. Zip code boundaries are always changing. Etc. The answer, according […]
Fibonacci numbers and ingrown bark
The previous post looked at the images of concentric circles under functions defined by power series. The terms of these series have the form zθ(n) / θ(n) where θ(n) is a rapidly increasing function of n. These series are thin (technically, lacunary) because all the terms between values of θ(n) are missing. The previous post […]
Concentric circle images go wild
HAKMEM Item 123 gives two plots, both images of concentric circles under functions given by power series with rapidly thinning terms [1]. The first is the function and the second is The lower limits of summation are not given in the original. I assumed at first the sums began at n = 0, but my […]
Accelerating an alternating series
This post looks at an algorithm by Cohen et al [1] to accelerate the convergence of an alternating series. This method is much more efficient than the classical Euler–Van Wijngaarden method. For our example, we’ll look at the series which converges slowly to -π²/12. The first algorithm in [1] for approximating using up to the […]
Compact form of the Lagrange inversion formula
The Lagrange inversion formula can be used to find the power series for the inverse of a function. I wrote about a different approach this problem a couple years ago, that time using Bell polynomials. This time I’ll give a formula that is more direct and easier to remember. Suppose we have a function A(x) […]
Continued fractions of square roots
Let’s look at the continued fraction representation for √14. If we were to take more terms, the sequence of denominators would repeat: 1, 2, 1, 6, 1, 2, 1, 6, 1, 2, 1, 6, … We could confirm this with Mathematica: In: ContinuedFraction[Sqrt[14], 13] Out: {3, 1, 2, 1, 6, 1, 2, 1, 6, 1, […]
Conceptual vs Numerical
One of the things that makes numerical computation interesting is that it often reverses the usual conceptual order of things, using advanced math to compute things that are introduced earlier. Here’s an example I recently ran across [1]. The hyperbolic functions are defined in terms of the exponential function: But it may be more efficient […]
Time spent on the moon
This post will illustrate two things: the amount of time astronauts have spent on the moon, and how to process dates and times in Python. I was curious how long each Apollo mission spent on the lunar surface, so I looked up the timelines for each mission from NASA. Here’s the timeline for Apollo 11, […]
Monthly blog highlights
Once a month I publish a brief newsletter highlighting the top posts from the blog that month. Occasionally I’ll also say something about what I’ve been up to. If you’re interested, you can subscribe here. The same page has links to subscribe to the blog via RSS or email. If you’d like to hear from […]
Hexadecimal floating point
Programming language support for hexadecimal integers is very common. Support for hexadecimal floating point numbers is not. It’s a common convention to put 0x in front of a number to indicate that it is an integer written as an integer literal. For example, 0x12 is not a dozen, but a dozen and a half. The […]
Cesàro summation
There’s more than one way to sum an infinite series. Cesàro summation lets you compute the sum of series that don’t have a sum in the classical sense. Suppose we have an infinite series The nth partial sum of the series is given by The classical sum of the series, if it exists, is defined […]
The worst tool for the job
I don’t recall where I read this, but someone recommended that if you need a tool, buy the cheapest one you can find. If it’s inadequate, or breaks, or you use it a lot, then buy the best one you can afford. (Update: Thanks to Jordi for reminding me in the comments that this comes […]
Not even close
Very often what cannot be done exactly can be done approximately. For example, most integrals cannot be computed in closed form, but they can be calculated numerically as closely as you’d like. But sometimes things are impossible, and you can’t even come close. An impossible assignment When I was in college, I had a friend […]
Overview of NIST post-quantum encryption finalists
If and when large-scale quantum computing becomes practical, most public key encryption algorithms currently in use would be breakable. Cryptographers have known this since Peter Shor published his quantum factoring algorithm in 1994. In 2017 researchers submitted 69 algorithms to the NIST Post-Quantum Cryptography Standardization Process. In 2019 NIST chose 26 of these algorithms to […]
Banned math book
Courant & Hilbert is a classic applied math textbook, still in print nearly a century after the first edition came out. The actual title of the book is Methods of Mathematical Physics, but everyone calls it Courant & Hilbert after the authors, Richard Courant and David Hilbert. I was surprised to find out recently that […]
Hadamard’s upper bound on determinant
For an n by n real matrix A, Hadamard’s upper bound on determinant is where aij is the element in row i and column j. See, for example, [1]. How tight is this upper bound? To find out, let’s write a little Python code to generate random matrices and compare their determinants to Hadamard’s bounds. […]
Cosine power approximation to normal
Ten years ago I wrote about how cosine makes a decent approximation to the normal (Gaussian) probability density. It turns out you get a much better approximation if you raise cosine to a power. If we normalize cosk(t) by dividing by its integral we get an approximation to the density function for a normal distribution […]
Expressiveness
Programmers like highly expressive programming languages, but programing managers do not. I wrote about this on Twitter a few months ago. Q: Why do people like Lisp so much? A: Because Lisp is so expressive. Q: Why don’t teams use Lisp much? A: Because Lisp is so expressive. Q: Why do programmers complain about Java? […]
From shell to system
Routine computer tasks and system programming require different tools, though I’m not entirely sure why. Many people have thought about how inconsistent shells and system programming languages are and tried to unite them. Wouldn’t it be nice to use one language for everything? But attempts to bring system languages down to the shell, or to […]
A warped perspective on math history
Yesterday I posted on @TopologyFact The uniform limit of continuous functions is continuous. John Baez replied that this theorem was proved by his “advisor’s advisor’s advisor’s advisor’s advisor’s advisor.” I assume he was referring to Christoph Gudermann. The impressive thing is not that Gudermann was able to prove this simple theorem. The impressive thing is […]
Decomposing functions of many variables to functions of one variable
Suppose you have a computer that can evaluate and compose continuous functions of one real variable and can do addition. What kinds of functions could you compute with it? You could compute functions of one variable by definition, but could you bootstrap it to compute functions of two variables? Here’s an example that shows this […]
Eliminating polynomial terms
The first step in solving a cubic equation is to apply a change of variables to reduce an equation of the form x³ + bx² + cx + d = 0 to one of the form y³ + py + q = 0. This process can be carried further through Tschirnhausen transformations, a generalization of […]
Leapfrog integrator
The so-called “leapfrog” integrator is a numerical method for solving differential equations of the form where x is a function of t. Typically x is position and t is time. This form of equation is common for differential equations coming from mechanical systems. The form is more general than it may seem at first. It […]
Counterexample to Dirichlet principle
Let Ω be an open set in some Euclidean space and v a real-valued function on Ω. Dirichlet principle Dirichlet’s integral for v, also called the Dirichlet energy of v, is Among functions with specified values on the boundary of Ω, Dirichlet’s principle says that minimizing Dirichlet’s integral is equivalent to solving Laplace’s equation. In […]
Software analysis and synthesis
People who haven’t written large programs think that writing software is easy. All you have to do is break a big problem into smaller problems until you have something so small that it’s easy to program. The problem is putting the pieces back together. If you’ve only written small programs, you haven’t had many pieces […]
COVID19 mortality per capita by state
Here’s a silly graph by Richard West with a serious point. States with longer names tend to have higher covid19 mortality. Of course no one believes there’s anything about the length of a state’s name that should impact the health of its residents. The correlation is real, but it’s a coincidence. The variation between mortality […]
Morse code golf
You can read the title of this post as ((Morse code) golf) or as (Morse (code golf)). Morse code is a sort of approximate Huffman coding of letters: letters are assigned symbols so that more common letters can be transmitted more quickly. You can read about how well Morse code achieves this design objective here. […]
Squircle corner radius
I’ve written several times about the “squircle,” a sort of compromise between a square and a circle. It looks something like a square with rounded corners, but it’s not. Instead of having flat sizes (zero curvature) and circular corners (constant positive curvature), the curvature varies continuously. A natural question is just what kind of circle […]
Triple words
A couple days ago I wrote a post about some doubled words I found on my site. Someone asked about triple words, so I looked. Here are some of the things I found. One example was a post where I commented on a song from Fiddler on the Roof where Teva sings If I were […]
Kissing circle
Curvature is a measure of how tightly a curve bends. A circle of radius r has curvature 1/r. So a small circle has high curvature and a big circle has small curvature. In general the curvature of a curve at a point is defined to be the curvature of the circle that best fits at […]
Double words
Double words such as “the the” are a common source of writing errors. On the other hand, some doubled words are legitimate. You might, for example, find “had had” or “that that” in a grammatically correct sentence. I’ve been looking through my web site to purge erroneous double words, and found a few doubles that […]
...27282930313233343536...