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-04-26 04:32
Closed-form solutions to nonlinear PDEs
The traditional approach to teaching differential equations is to present a collection of techniques for finding closed-form solutions to ordinary differential equations (ODEs). These techniques seem completely unrelated [1] and have arcane names such as integrating factors, exact equations, variation of parameters, etc. Students may reasonably come away from an introductory course with the false [...]The post Closed-form solutions to nonlinear PDEs first appeared on John D. Cook.
Choosing a Computer Language for a Project
Julia. Scala. Lua. TypeScript. Haskell. Go. Dart. Various computer languages new and old are sometimes proposed as better alternatives to mainstream languages. But compared to mainstream choices like Python, C, C++ and Java (cf. Tiobe Index)-are they worth using? Certainly it depends a lot on the planned use: is it a one-off small project, or [...]The post Choosing a Computer Language for a Project first appeared on John D. Cook.
On greedy algorithms and rodeo clowns
This weekend I ran across a blog post The Rodeo Clown Theory of Personal Development. The title comes from a hypothetical example of a goal you don't know how to achieve: becoming a rodeo clown. Let's say you decide you want to be a rodeo clown. And let's say you're me and you have no [...]The post On greedy algorithms and rodeo clowns first appeared on John D. Cook.
Finding strings in binary files
There's a little program called strings that searches for what appear to be strings inside binary file. I'll refer to it as strings(1) to distinguish the program name from the common English word strings. [1] What does strings(1) consider to be a string? By default it is a sequence of four or more bytes that [...]The post Finding strings in binary files first appeared on John D. Cook.
Extract text from a PDF
Arshad Khan left a comment on my post on the less and more utilities saying on ubuntu if I do less on a pdf file, it shows me the text contents of the pdf." Apparently this is an undocumented feature of GNU less. It works, but I don't see anything about it in the man [...]The post Extract text from a PDF first appeared on John D. Cook.
Length of a general Archimedean spiral
This post ties together the previous three posts. In this post, I said that an Archimedean spiral has the polar equation r = b 1/n and applied this here to rolls of carpet. When n = 1, the length of the spiral for running from 0 to T is approximately bT^2 with the [...]The post Length of a general Archimedean spiral first appeared on John D. Cook.
How big will a carpet be when you roll or unroll it?
If you know the dimensions of a carpet, what will the dimensions be when you roll it up into a cylinder? If you know the dimensions of a rolled-up carpet, what will the dimensions be when you unroll it? This post answers both questions. Flexible carpet: solid cylinder The edge of a rolled-up carpet can [...]The post How big will a carpet be when you roll or unroll it? first appeared on John D. Cook.
Approximating a spiral by rings
An Archimedean spiral has the polar equation r = b 1/n This post will look at the case n = 1. I may look at more general values of n in a future post. (Update: See here.) The case n = 1 is the simplest case, and it's the case I needed for the client [...]The post Approximating a spiral by rings first appeared on John D. Cook.
Hypergeometric function of a large negative argument
It's occasionally necessary to evaluate a hypergeometric function at a large negative argument. I was working on a project today that involved evaluating F(a, b; c; z) where z is a large negative number. The hypergeometric function F(a, b; c; z) is defined by a power series in z whose coefficients are functions of a, [...]The post Hypergeometric function of a large negative argument first appeared on John D. Cook.
More is less
When I first started using Unix, I used a program called more" to read files. The name makes sense because each time you press the space bar, more will show you more of your file, one screen at a time. Now everyone uses less, and more is all but forgotten. Daniel Halbert wrote more in [...]The post More is less first appeared on John D. Cook.
Precise answers to useless questions
I recently ran across a tweet from Allen Downey saying So much of 20th century statistics was just a waste of time, computing precise answers to useless questions. He's right. I taught mathematical statistics at GSBS [1, 2] several times, and each time I taught it I became more aware of how pointless some of [...]The post Precise answers to useless questions first appeared on John D. Cook.
Pairs in poker
An article by Y. L. Cheung [1] gives reasons why poker is usually played with five cards. The author gives several reasons, but here I'll just look at one reason: pairs don't act like you might expect if you have more than five cards. In five-card poker, the more pairs the better. Better here means [...]The post Pairs in poker first appeared on John D. Cook.
Solar system means
Yesterday I stumbled on the fact that the size of Jupiter is roughly the geometric mean between the sizes of Earth and the Sun. That's not too surprising: in some sense (i.e. on a logarithmic scale) Jupiter is the middle sized object in our solar system. What I find more surprising is that a systematic [...]The post Solar system means first appeared on John D. Cook.
Earth : Jupiter :: Jupiter : Sun
The size of Jupiter is approximately the geometric mean of the sizes of Sun and Earth. In terms of radii, The ratio on the left equals 9.95 and the ratio on the left equals 10.98. The subscripts are the astronomical symbols for the Sun (, U+2609), Jupiter (, U+2643), and Earth (, U+1F728). I produced [...]The post Earth : Jupiter :: Jupiter : Sun first appeared on John D. Cook.
Gravity on Jupiter
I was listening to the latest episode of the Space Rocket History podcast. The show includes some audio from a documentary on Pioneer 11 that mentioned that a man would weigh 500 pounds on Jupiter. My immediate thought was Is that all?! Is this man' a 100 pound boy?" The documentary was correct and my [...]The post Gravity on Jupiter first appeared on John D. Cook.
Are guidance documents laws?
Are guidance documents laws? No, but they can have legal significance. The people who generate regulatory guidance documents are not legislators. Legislators delegate to agencies to make rules, and agencies delegate to other organizations to make guidelines. For example [1], Even HHS, which has express cybersecurity rulemaking authority under the Health Insurance Portability and Accountability [...]The post Are guidance documents laws? first appeared on John D. Cook.
More Laguerre images
A week or two ago I wrote about Laguerre's root-finding method and made some associated images. This post gives a couple more examples. Laguerre's method is very robust in the sense that it is likely to converge to a root, regardless of the starting point. However, it may be difficult to predict which root the [...]The post More Laguerre images first appeared on John D. Cook.
A Bayesian approach to proving you’re human
I set up a GitHub account for a new employee this morning and spent a ridiculous amount of time proving that I'm human. The captcha was to listen to three audio clips at a time and say which one contains bird sounds. This is a really clever test, because humans can tell the difference between [...]The post A Bayesian approach to proving you're human first appeared on John D. Cook.
Antenna length: Another rule of 72
The famous Rule of 72 says that to find out how many years it takes an investment to double in value, divide 72 by the annual percentage rate. I'll come back to that in a little bit. This morning I read a really good article, Fifty Things you can do with a Software Defined Radio. [...]The post Antenna length: Another rule of 72 first appeared on John D. Cook.
Hallucinations of AI Science Models
AlphaFold 2, FourCastNet and CorrDiff are exciting. AI-driven autonomous labs are going to be a big deal [1]. Science codes now use AI and machine learning to make scientific discoveries on the world's most powerful computers [2]. It's common practice for scientists to ask questions about the validity, reliability and accuracy of the mathematical and [...]The post Hallucinations of AI Science Models first appeared on John D. Cook.
Double super factorial
I saw someone point out recently that 10! = 7! * 5! * 3! * 1! Are there more examples like this? What would you call the pattern on the right? I don't think there's a standard name, but here's why I think it should be called double super factorial or super double factorial. Super [...]The post Double super factorial first appeared on John D. Cook.
Laguerre’s root finding method
Edmond Laguerre (1834-1886) came up with a method for finding zeros of polynomials. Unlike Newton's method for finding zeros of general functions, Laguerre's method is specialized for polynomials. Laguerre's method converges an order of magnitude faster than Newton's method, i.e. the error is cubed on each step rather than squared. The most interesting thing about [...]The post Laguerre's root finding method first appeared on John D. Cook.
Breach Safe Harbor
In the context of medical data, Safe Harbor typically refers to the Safe Harbor provisions of the HIPAA Privacy Rule explained here. Breach Safe Harbor is a little different. It basically means you're off the hook if you breach encrypted health data. (But not necessarily. More on that below.) I'm not a lawyer, so this [...]The post Breach Safe Harbor first appeared on John D. Cook.
MD5 hash collision example
Marc Stevens gave an example of two alphanumeric strings that differ in only one byte that have the same MD5 hash value. It may seem like beating a dead horse to demonstrate weaknesses in MD5, but it's instructive to study the flaws of broken methods. And despite the fact that MD5 has been broken for [...]The post MD5 hash collision example first appeared on John D. Cook.
Distance from a point to a line
Eric Lengyel's new book Projective Geometric Algebra Illuminated arrived yesterday and I'm enjoying reading it. Imagine if someone started with ideas like dot products, cross products, and determinants that you might see in your first year of college, then thought deeply about those things for years. That's kinda what the book is. Early in the [...]The post Distance from a point to a line first appeared on John D. Cook.
Experiences with Thread Programming in Microsoft Windows
Lately I've been helping a colleague to add worker threads to his GUI-based Windows application. Thread programming can be tricky. Here are a few things I've learned along the way. Performance. This app does compute-intensive work. It is helpful to offload this very compute-heavy work to a worker thread. Doing this frees the main thread [...]The post Experiences with Thread Programming in Microsoft Windows first appeared on John D. Cook.
Accelerating Archimedes
One way to approximate is to find the areas of polygons inscribed inside a circle and polygons circumscribed outside the circle. The approximation improves as the number of sides in the polygons increases. This idea goes back at least as far as Archimedes (287-212 BC). Maybe you've tried this. It's a lot of work. [...]The post Accelerating Archimedes first appeared on John D. Cook.
How much will a cable sag? A simple approximation
Suppose you have a cable of length 2s suspended from two poles of equal height a distance 2x apart. Assuming the cable hangs in the shape of a catenary, how much does it sag in the middle? If the cable were pulled perfectly taut, we would have s = x and there would be no [...]The post How much will a cable sag? A simple approximation first appeared on John D. Cook.
Unique letter patterns in words
The word Mississippi has a unique pattern of letters. If you were solving a cryptogram puzzle and saw ZVFFVFFVCCV you might guess that the word is Mississippi. Is the pattern of letters in Mississippi literally unique or just uncommon? What is the shortest word with a unique letter pattern? The longest word? We can answer [...]The post Unique letter patterns in words first appeared on John D. Cook.
How to Organize Technical Research?
64 million scientific papers have been published since 1996 [1]. Assuming you can actually find the information you want in the first place-how can you organize your findings to be able to recall and use them later? It's not a trifling question. Discoveries often come from uniting different obscure pieces of information in a [...]The post How to Organize Technical Research? first appeared on John D. Cook.
A surprising result about surprise index
Surprise index Warren Weaver [1] introduced what he called the surprise index to quantify how surprising an event is. At first it might seem that the probability of an event is enough for this purpose: the lower the probability of an event, the more surprise when it occurs. But Weaver's notion is more subtle than [...]The post A surprising result about surprise index first appeared on John D. Cook.
Estimating an author’s vocabulary
How would you estimate the size of an author's vocabulary? Suppose you have a analyzed the author's available works and found n words, x of which are unique. Then you know the author's vocabulary was at least x, but it's reasonable to assume that the author may have know words he never used in writing, [...]The post Estimating an author's vocabulary first appeared on John D. Cook.
Detecting the language of encrypted text
Imagine you are a code breaker living a century ago. You've intercepted a message, and you go through your bag of tricks, starting with the simplest techniques first. Maybe the message has been encrypted using a simple substitution cipher, so you start with that. Simple substitution ciphers can be broken by frequency analysis: the most [...]The post Detecting the language of encrypted text first appeared on John D. Cook.
Blow up in finite time
A few years ago I wrote a post about approximating the solution to a differential equation even though the solution did not exist. You can ask a numerical method for a solution at a point past where the solution blows up to infinity, and it will dutifully give you a finite solution. The result is [...]The post Blow up in finite time first appeared on John D. Cook.
Normal subgroups are subtle
The definition of a subgroup is obvious, but the definition of a normal subgroup is subtle. Widgets and subwidgets The general pattern of widgets and subwidgets is that a widget is a set with some kind of structure, and a subwidget is a subset that has the same structure. This applies to vector spaces and [...]The post Normal subgroups are subtle first appeared on John D. Cook.
Finite differences and Pascal’s triangle
The key to solving a lot of elementary what-number-comes-next puzzles is to take first or second differences. For example, if asked what the next item in the series 14, 29, 50, 77, 110, ... the answer (or at lest the answer the person posing the question is most likely looking for) is 149. You might [...]The post Finite differences and Pascal's triangle first appeared on John D. Cook.
Archiving data on paper
This is a guest post by Ondej ertik. Ondej formerly worked at Los Alamos National Labs and now works for GSI Technologies. He is known in the Python community for starting the SymPy project and in the Fortran community for starting LFortran. - John I finally got to experiment a bit with archiving data [...]The post Archiving data on paper first appeared on John D. Cook.
Emails moved to Substack
Until recently I used two email services: one to send out daily blog post announcements and another for monthly blog highlights. I've combined these into one Substack account for weekly blog highlights. Apparently readers really like this move. Daily and monthly email subscriptions flatlined some time ago, but Substack subscriptions are going up steadily. Substack [...]The post Emails moved to Substack first appeared on John D. Cook.
What’s the Best Code Editor?
Emacs, vi, TextEdit, nano, Sublime, Notepad, Wordpad, Visual Studio, Eclipse, etc., etc.-everyone's got a favorite. I used Visual Studio previously and liked the integrated debugger. Recently I started using VS again and found the code editing windows rather cluttered. Thankfully you can tone this down, if you can locate the right options. Eclipse for Java [...]The post What's the Best Code Editor? first appeared on John D. Cook.
Bounding the perimeter of a triangle between circles
Suppose you have a triangle and you know the size of the largest circle that can fit inside (the incircle) and the size of the smallest circle that can fit outside (the circumcircle). How would you estimate the perimeter of the triangle? In terms of the figure below, if you know the circumference of the [...]The post Bounding the perimeter of a triangle between circles first appeared on John D. Cook.
Music of the spheres
The idea of music of the spheres" dates back to the Pythagoreans. They saw an analogy between orbital frequency ratios and musical frequency ratios. HD 110067 is a star 105 light years away that has six known planets in orbital resonance. The orbital frequencies of the planets are related to each other by small integer [...]The post Music of the spheres first appeared on John D. Cook.
The Real Book
I listened to the 99% Invisible podcast about The Real Book this morning and thought back to my first copy. My first year in college I had a jazz class, and I needed to get a copy of The Real Book, a book of sheet music for jazz standards. The book that was illegal at [...]The post The Real Book first appeared on John D. Cook.
Substack replacing email subscription
The service that sent out my email to blog subscribers stopped working a couple weeks ago, and I'm trying out Substack as a replacement. You can find my Substack account here. My plan for now is to use this account to make blog post announcements, maybe once a week, with a little introductory commentary for [...]The post Substack replacing email subscription first appeared on John D. Cook.
Determinant of an infinite matrix
What does the infinite determinant mean and when does it converge? The determinant D above is the limit of the determinants Dn defined by If all the as are 1 and all the bs are -1 then this post shows that Dn = Fn, the nth Fibonacci number. The Fibonacci numbers obviously don't converge, so [...]The post Determinant of an infinite matrix first appeared on John D. Cook.
Area of quadrilateral as a determinant
I've written several posts about how determinants come up in geometry. These determinants often look similar, having columns related to coordinates and a column of ones. You can find several examples here along with an explanation for this pattern. If you have three points z1, z2, and z3 in the complex plane, you can find [...]The post Area of quadrilateral as a determinant first appeared on John D. Cook.
A very accurate logarithm approximation
The previous post looked at an efficient way to approximate nth roots of fractions near 1 by hand. This post does the same for logarithms. As before, we assume x = p/q and define s = p + q d = p - q Because we're interested in values of x near 1, d is [...]The post A very accurate logarithm approximation first appeared on John D. Cook.
Handy approximation for roots of fractions
This post will discuss a curious approximation with a curious history. Approximation Let x be a number near 1, written as a fraction x = p / q. Then define s and d as the sum and difference of the numerator and denominator. s = p + q d = p - q Since we [...]The post Handy approximation for roots of fractions first appeared on John D. Cook.
Uncovering names masked with stars
Sometimes I'll see things like my name partially concealed as J*** C*** and think a lot of good that does." Masking letters reveals more than people realize. For example, when you see that someone's first name is four letters and begins with J, there's about a 70% chance they're male and there's a 44% chance [...]The post Uncovering names masked with stars first appeared on John D. Cook.
Almost ASCII
I was working recently with a gigabyte file that had a dozen non-ASCII characters. This is very common. The ASCII character set is not quite big enough for a lot of tasks. Of course it's completely inadequate if you're writing Japanese, but it's almost enough for documents written in English and a few other languages. [...]The post Almost ASCII first appeared on John D. Cook.
A knight’s tour of an infinite chessboard
Let ^2 be the lattice of points in the plane with integer coordinates. You could think of these points as being the centers of the squares in a chessboard extending to infinity in every direction. Cantor tells us that the points in ^2 are countable. What's more surprising is that you could count the points [...]The post A knight's tour of an infinite chessboard first appeared on John D. Cook.
12345678910...