News

johndcook.com
johndcook.com > blog > 03/01/2026 > tilde-dash

Shell variable ~-

2+ hour, 28+ min ago  (213+ words) After writing the previous post, I poked around in the bash shell documentation and found a handy feature I'd never seen before, the shortcut ~-. I frequently use the command cd - to return to the previous working directory, but didn't know…...

johndcook.com
johndcook.com > blog > 02/28/2026 > file-extensions-bash

file extensions in bash scripts | shell parameter expansion

1+ day, 2+ hour ago  (155+ words) I've never been good at shell scripting. I'd much rather write scripts in a general purpose language like Python. But occasionally a shell script can do something so simply that it's worth writing a shell script. Sometimes a shell scripting…...

johndcook.com
johndcook.com > blog > 02/25/2026 > trig-of-inverse-trig

Trig of inverse trig

4+ day, 9+ hour ago  (291+ words) I ran across an old article [1] that gave a sort of multiplication table for trig functions and inverse trig functions. Here's my version of the table. I made a few changes from the original. First, I used LaTeX, which didn't…...

johndcook.com
johndcook.com > blog > 02/24/2026 > a-curious-trig-identity

A curious trig identity

4+ day, 21+ hour ago  (258+ words) Here is an identity that doesn't look correct but it is. For real'x and'y, I found the identity in [1]. The author's proof is short. First of all, Taking square roots completes the proof. Now note that the statement at the…...

johndcook.com
johndcook.com > blog > 02/21/2026 > big-certified-fibonacci

Computing big, certified Fibonacci numbers

1+ week, 1+ day ago  (296+ words) I've written before about computing big Fibonacci numbers, and about creating a certificate to verify a Fibonacci number has been calculated correctly. This post will revisit both, giving a different approach to computing big Fibonacci numbers that produces a certificate…...

johndcook.com
johndcook.com > blog > 02/16/2026 > hodograph

Orbital hodograph | Plotting velocity of Keplerian orbit

1+ week, 5+ day ago  (414+ words) The shape of a planet's orbit around a star is an ellipse. To put it another way, a plot of the position of a planet's orbit over time forms an ellipse. What about the velocity? Is it's plot also an…...

johndcook.com
johndcook.com > blog > 02/14/2026 > wagons-algorithm-in-python

Wagon’s algorithm in Python

2+ week, 21+ hour ago  (241+ words) The last three posts have been about Stan Wagon's algorithm for finding x and y satisfying x" + y" = p where p is an odd prime. The first post in the series gives Gauss' formula for a solution, but shows why…...

johndcook.com
johndcook.com > blog > 02/14/2026 > square-root-minus-1-mod-p

Finding a square root of -1 mod p

2+ week, 22+ hour ago  (218+ words) If p is an odd prime, there is a theorem that says x" = "1 mod p has a solution if and only if p = 1 mod 4. When a solution'x exists, how do you find it? The previous two posts have discussed Stan…...

johndcook.com
johndcook.com > blog > 02/12/2026 > pythagorean-primes

Expressing a prime as the sum of two squares

2+ week, 2+ day ago  (445+ words) I saw where Elon Musk posted Grok's answer to the prompt "What are the most beautiful theorems." I looked at the list, and there were no surprises, as you'd expect from a program that works by predicting the most likely…...

johndcook.com
johndcook.com > blog > 02/11/2026 > orthogonal-procrustes

Aligning one matrix with another

2+ week, 4+ day ago  (335+ words) Suppose you have two'n " n matrices, A and B, and you would like to find a rotation matrix " that lines up'B with'A. That is, you'd like to find " such that This is asking too much, except in the trivial case…...