Error correcting codes are most simply described in terms of the errors they can certainly correct. For example, the Hadamard code used for the Mariner 9 probe to Mars encoded each 6-bit pixel to a 32-bit codeword in such a way that the original pixel could be recovered if no more than 7 bits were [ ] The post Probability of correcting errors first appeared on John D. Cook .
Hadamard matrices are in the news following the recent announcement of a newly discovered Hadamard matrix. I ve written three posts on Hadamard matrices recently, one as a sort of introduction and two on applications: the error correcting code used in the Mariner 9 probe and constructing sphere packings. A Hadamard matrix is an orthogonal matrix [ ] The post Compressing a Hadamard matrix first…
Yesterday Levent Alpöge announced that he and his colleagues had discovered a new Hadamard matrix using Claude AI. That motivated a post I wrote this morning on how to construct Hadamard matrices. I mentioned in that post that these matrices arise in applications. This evening I gave an example, describing how NASA used a Hadamard [ ] The post Hadamard Codes and Sphere Packing first appeared on…
NASA set Mariner 9 to photograph Mars in 1971. The images had to be encoded for transmission using an error-correcting code, otherwise they would be significantly corrupted when they were received on Earth. The images were encoded for transmission using a code based on Hadamard matrices, specifically a (32, 6, 16) Hadamard code. This means [ ] The post How NASA’s Mariner 9 probe encoded images…
A Hadamard matrix is an orthogonal matrix whose entries are all either 1 or − 1. For example is a Hadamard matrix of order 2. True to Stigler s law of eponymy, James Joseph Sylvester investigated Hadamard matrices before Jacques Hadamard. Sylvester saw how to bootstrap the example above into more examples. If H is a [ ] The post Constructing Hadamard matrices first appeared on John D. Cook .
Suppose you ve never worked at the command line and you re reading a book about the bash shell. You read that !$ is a shortcut to refer to the last word of the previous command. That little fact will almost certainly not stick in your head for a couple reasons. First, you probably see no need [ ] The post Cryptic but consistent first appeared on John D. Cook .
I was reading a blog post on boat names because it was on Hacker News this morning. The post contained a link to a data set on dog names in NYC and I poked around the data a little. The top names were not at all what I expected, but then again this is limited [ ] The post Dogs and fat tails first appeared on John D. Cook .
Suppose you were able to go back in time, to an era before computers, and give someone contemporary cryptography. Encryption methods that are essentially unbreakable now would certainly be unbreakable then. But there s a catch: not only do attackers not have computers, neither do users. Manual cryptography If you told someone about RSA encryption, for [ ] The post Manually unbreakable cryptography…
The following extraordinary paragraph comes from Knuth s TAOCP Volume 4A, right before the last set of exercises. Many of the exercises below ask a modern reader to find and/or to correct errors in the literature of bygone days. The point is not to gloat over how smart we are in the 21st century; the point [ ] The post Learning from historical mistakes first appeared on John D. Cook .
In science and engineering classes, you might describe a system using Newton s laws and end up with a differential equation. You then solve the differential equation, analytically or numerically, to see how the solutions behave. You might also do the opposite, especially in a mathematics class: look at what differential equation a set of functions [ ] The post Inverse differential equations first…
I was reading a book on the history of the discovery of the structure of DNA [1] and was surprised by a few passing references to Bessel functions. According to Claude, When X-rays are diffracted by a helical structure, the resulting diffraction pattern breaks into a series of horizontal layer lines. Cochran, Crick, and Vand [ ] The post DNA and Bessel functions first appeared on John D. Cook .
At the end of my post on how not to calculate cosine I said that the first step in calculating cosine, particularly cosine of a large number, would be to do range reduction. This post will present a simple range reduction method by Cody and Waite that is adequate for moderately large arguments. If you [ ] The post A simple range reduction method first appeared on John D. Cook .
I have a program that shares files between my laptop and my phone. It works well, except for apostrophes. When I type an apostrophe ' on my laptop, it becomes ’ on my phone. And when I type 's on my phone, it becomes 痴 on my laptop. Apparently the phone turns the apostrophe (U+0027) [ ] The post Corrupted apostrophes first appeared on John D. Cook .
Calculus professors with no experience in numerical computing will tell students that computers calculate trig functions with power series. They don t. I worked on the implementation of trig functions in hardware, and I can assure you we didn t just use power series. Power series are an excellent way to calculate functions near the center of [ ] The post How not to calculate cosine first appeared…
In a footnote to the previous post, I said that Python s math library can calculate the logarithm of extremely large numbers but not the cosine. This post will expand on that comment. In this post I ll use n = 200! as my example rather than 1000! because this value of N is larger than the [ ] The post cos(200!) first appeared on John D. Cook .
The previous post pointed out that the following code such as the following unexpectedly works. from math import log, factorial log(factorial(1000)) 5912.128178488163 If you don t find this unexpected, note that if you replace math.log with numpy.log the code will fail [1]. Functions like natural logarithm operate on real numbers. Real numbers are represented [ ] The post Calculating log(1000!)…
Last week I wrote a post on hiding cryptographic keys in decks of cards. I wrote some code for that post that shouldn t work, but before fixing I noticed that it in fact did work. The code computes logarithms for integers larger than the largest representable float. For example, the largest float is on the [ ] The post The code that didn’t break first appeared on John D. Cook .
A few days ago I wrote a post on counting rooted trees. That post looked at the sequence c(n) which counts the number of rooted trees with n nodes. Here one node is distinguished as the root, but the nodes below the root are not distinguished from each other; all that matters is how the [ ] The post Enumerating trees and circles first appeared on John D. Cook .
After writing the previous post about metallic ratios, I thought about the analogy to alchemy and the attempt to make precious metals out of base metals. When can you make one metallic ratio out of another? Can you make the golden ratio out of the lead ratio? Before we can make gold out of lead, [ ] The post Mathematical alchemy first appeared on John D. Cook .
The golden ratio is the first and best known of the metallic ratios. I ve written about the silver ratio a few times, most recently here. And I ve mentioned the bronze ratio a couple times. The metallic ratios after bronze don t have standard names. The nth metallic ratio M(n) is the number whose continued fraction representation [ ] The post Ratio of metallic ratios first appeared on John D. Cook…
Yesterday I wrote that a lot of the special functions that pop up in mathematical physics are solutions to second order linear differential equations with polynomial coefficients. More generally, holonomic functions are defined to be those functions that are the solutions to linear differential equations, of any order, with polynomial coefficients. Most special functions are [ ] The post Holonomic…
In this post I mentioned two series which I denoted t(n) and c(n). The former is the number of unlabeled rooted trees with n nodes. The latter is the cumulative sum of the former, i.e. The sequence c(n) is also the number of constraints on an n-step Runge-Kutta method; that s how I became interested in it. Now the t(n) sequence [ ] The post Estimating a cumulative sum first appeared on John D.…
Second order linear differential equations with polynomial coefficients form their own area of study. This seems like a narrow class of equations, but it s very important in applications. This class of equations seems like a mathematically natural topic, but why is it so important in applications? I did a PhD in differential equations without ever [ ] The post Why polynomial coefficients? first…
Combinatorial problems can be interesting for their own sake, but they are more interesting when there is a connection to a problem outside combinatorics, and the more unexpected the connection the better. Counting the number of unlabeled rooted trees [1] with n nodes is a pure mathematics problem. Designing numerical methods for solving differential equations [ ] The post Counting rooted trees…
The textbook version of the Runge-Kutta method for solving differential equations has 4 stages and has 4th order error. For lower order versions of RK the number of stages s also matches the order of the error p. But in order to achieve error on the order of p ≥ 5, you need more than p [ ] The post Runge-Kutta order versus stages first appeared on John D. Cook .
I was digging into the Runge-Kutta method for solving differential equations and a line from [1] piqued my curiosity. These calculations, which are not reproduced in Kutta s paper (they are however in Huen (1900)), are very tedious. The calculations are a set of eight constraints that the parameters of a fourth-order Runge-Kutta method must satisfy. [ ] The post Solving the RK4 design equations…
A couple years ago I wrote about how to compute the inverse of factorial. I used that code in writing the previous post because the post required solving the equation ⌊log2(n!)⌋ ≥ b given b. That is, given a number of bits b, find the smallest value of n such that n! ≥ 2b. What the [ ] The post Inverse factorial improved first appeared on John D. Cook .
The previous post looked at the idea of storing a cryptographic key in the order of a deck of cards. A deck of 52 cards can store 225 bits of data because ⌊log2(52!)⌋ = 225. Here ⌊x⌋ is x rounded down to the nearest integer. If we want to store bigger keys, we re going to need [ ] The post Cryptographic Keys and Decks of Cards first appeared on John D. Cook .
The latest issue of Paged Out! has an article by Stephen Hewitt An off-line backup of your cryptographic key using playing cards. The idea is to use a deck of 52 to store a 128-bit cryptographic key. To erase the key, shuffle the deck. Hewitt gives his algorithm for embedding a key, one that can [ ] The post Hiding data in permutations first appeared on John D. Cook .
My post from yesterday on permutation roots ends with a Mathematica code for finding the probability that a permutation of n elements has a kth root. This is done by finding the coefficient of xn in the generating function I wanted to say more about this, and look at implementing the same code in SymPy. [ ] The post Counting permutations with roots first appeared on John D. Cook .