Sign up

John D. Cook

Not verified No WebSub updates No webmention support Not yet validated

Applied Mathematics Consulting

Public lists
davewiner/hackerNewsStars
Fetched

John D. Cook
• John

When will the decimals in a/b repeat?

The previous post looked at how many digits are in the reduced fraction for the nth harmonic number. I was curious about how long the cycle of digits in a harmonic number might be. I wrote about the period length for the digits of fractions almost a decade ago. This post includes code so I can […]

The post When will the decimals in a/b repeat? first appeared on John D. Cook.

John D. Cook
• John

Height of harmonic numbers

The previous post looked at writing the harmonic numbers as reduced fractions and estimating the number of digits in the numerator and denominator based on asymptotics. This is a follow up post with plots. We’ll choose our base b to be 2. And we’ll look at the total number of bits in both the numerator and […]

The post Height of harmonic numbers first appeared on John D. Cook.

John D. Cook
• John

Writing down harmonic numbers

The nth harmonic number is the sum of the reciprocals of the first n positive integers. Hn = 1 + 1/2 + 1/3 + 1/4 + … + 1/n The product of all the denominators is n!, so you could write Hn as a fraction Hn = p/q where p = n! Hn is an integer and q = n!. While […]

The post Writing down harmonic numbers first appeared on John D. Cook.

John D. Cook
• John

Hart’s theorem

Hart’s theorem says If a triangle be formed by the arcs of three circles, the inscribed and the three escribed circles are all tangent to a new circle or line. Here “triangle” means a three-sided figure whose sides are portions of a circle. The inscribed circle is the largest circle that can fit inside the […]

The post Hart’s theorem first appeared on John D. Cook.

John D. Cook
• John

Incircles and Excircles of Pythagorean triangles

This post will reveal the connection between my two previous posts: one on the Star Trek lemma and one on Pythagorean triples. In the process of writing the latter, I looked at the Wikipedia article on Pythagorean triples and noticed this curious paragraph. In every Pythagorean triangle, the radius of the incircle and the radii of the […]

The post Incircles and Excircles of Pythagorean triangles first appeared on John D. Cook.

John D. Cook
• John

Consecutive Pythagorean triangle sides

In this post we find all Pythagorean triples that contain consecutive numbers, all Pythagorean triples (a, b, c) such that a + 1 = b or b + 1 = c. a + 1 = b George Osborne wrote a paper [1] addressing the question of when the squares of two consecutive numbers is also a square. Geometrically this is asking […]

The post Consecutive Pythagorean triangle sides first appeared on John D. Cook.

John D. Cook
• John

The Star Trek lemma

I was reading an article this evening and saw a footnote to a book by Arthur Baragar [1]. This caught my eye because he was my officemate at UT for a year. I found his book on Archive.org and was surprised to see “The Star Trek Lemma” in the table of contents. What could this […]

The post The Star Trek lemma first appeared on John D. Cook.

John D. Cook
• John

Regular expressions that work “everywhere”

The most frustrating aspect of regular expressions is that implementations vary. Features supported in one tool may not be supported at all in another tool, or they may be supported with slightly different syntax. I learned regular expressions in the context Perl, a maximalist regex environment. This led to frustration when features I expect to […]

The post Regular expressions that work “everywhere” first appeared on John D. Cook.

John D. Cook
• John

Lobachevsky’s integral formula

Let f be an even function with period π. Then the following remarkable theorem by Lobachevsky holds. This theorem is useful in Fourier analysis and signal processing. It’s useful to know even in the special case f(x) = 1. For a “jinc” analog, see this paper. *** Every time I see the name Lobachevsky I […]

The post Lobachevsky’s integral formula first appeared on John D. Cook.

John D. Cook
• John

Queens on a prime order board

The n queens problem is to place on an n × n chessboard n queens so that none attacks any other. This means there is only one queen on every horizontal, vertical, and diagonal line. When n is a prime number ≥ 5, it is sufficient to place the queens on a line that has slope 2, 3, 4, …, […]

The post Queens on a prime order board first appeared on John D. Cook.

John D. Cook
• John

All pieces on a 6 by 5 board

I’ve written a couple posts lately on getting an LLM to generate code to solve chess problems. The first used Claude to generate Prolog and the second used ChatGPT to generate Prolog. This post will use Claude to generate Z3/Python code. The puzzle is one I’ve written about before: Place all the pieces—king, queen, two […]

The post All pieces on a 6 by 5 board first appeared on John D. Cook.

John D. Cook
• John

Formalizing a ring theorem with Lean 4 and Claude

I’ve been testing Claude’s ability to generate Lean 4 code to prove theorems. I’ve written about a couple experiments that verified calculations. I did not write about my failed attempt to get Claude to formalize a proof of the pqr theorem for seminorms. This time I asked Claude to formally prove the theorem from the […]

The post Formalizing a ring theorem with Lean 4 and Claude first appeared on John D. Cook.

John D. Cook
• John

Partial fraction decomposition

Nearly everyone who has seen partial fraction decomposition was introduced to it as a way to compute integrals. If P(x) and Q(x) are polynomials, then you can break their ratio P(x)/Q(x) into a sum of terms that can each be integrated in closed form. As with most topics in a calculus class, partial fractions go by in […]

The post Partial fraction decomposition first appeared on John D. Cook.

John D. Cook
• John

Three examples suffice

You can’t prove a theorem by just checking a few examples. Except sometimes you can. A few weeks ago I wrote Pentagonal numbers are truncated triangular numbers. In a nutshell, if the pentagonal numbers are defined by Pn = (3n² − n)/2 and the triangular numbers by Tn = (n² + n)/2 then Pn = T2n − 1 − Tn − 1. Here’s a visualization […]

The post Three examples suffice first appeared on John D. Cook.

John D. Cook
• John

Testing pentagonal numbers

The nth pentagonal number Pn is the number of dots in diagrams like those below with n concentric pentagons. We have the formula Pn = (3n² − n)/2 where n is a positive integer. If n is an integer but not positive, the equation above defines a generalized pentagonal number. If you’re given an n, you can easily compute Pn. […]

The post Testing pentagonal numbers first appeared on John D. Cook.

John D. Cook
• John

Quaternion Rotations, Claude, and Lean

I got an email message this afternoon reporting a typo in a blog post from about a year ago on converting between quaternions and rotation matrices [1]. The email said exactly where the typo was, but I decided to see whether Claude would find it. Specifically, I prompted Sonnet 4.6 Medium with the following. Write […]

The post Quaternion Rotations, Claude, and Lean first appeared on John D. Cook.

John D. Cook
• John

Writing Prolog with ChatGPT

A few days ago I wrote about using Claude to solve a chess puzzle by writing Prolog code. This morning I tried a similar chess puzzle with ChatGPT. The task is to place a queen, king, rook, bishop, and knight on a 4 by 4 chessboard so no piece attacks another. Of course there’s not […]

The post Writing Prolog with ChatGPT first appeared on John D. Cook.

John D. Cook
• John

RSA munitions T-shirt

Back when the US government classified strong encryption as “munitions,” RSA public key cryptography was illegal to export. In 1995, Adam Back protested this by creating a terse, obfuscated implementation of RSA in Perl code and used it as an email signature. The code was also printed on T-shirts. The shirt was classified as munitions […]

The post RSA munitions T-shirt first appeared on John D. Cook.

John D. Cook
• John

Solving a chess puzzle with Claude and Prolog

Prolog is the original logic programming language. The name comes from programming in logic. More specifically, the name comes from programmation en logique because the inventor of the language, Philippe Roussel, is French. Prolog has its advantages and disadvantages. One of the advantages is that the language represents logical problems directly. One of the disadvantages […]

The post Solving a chess puzzle with Claude and Prolog first appeared on John D. Cook.

John D. Cook
• John

Formally proving a calculation with Claude and Lean

I ran an experiment today to see whether Claude [1] could generate Lean code to prove a calculation at the bottom of this post, six lines of calculus. I started with this prompt This page contains a mathematical proof that a Fourier coefficient, a_n, is given in terms of a Bessel function. The LaTeX source […]

The post Formally proving a calculation with Claude and Lean first appeared on John D. Cook.

John D. Cook
• John

Pulling on a thread

Often there’s a thread running through a sequence of my posts. Sometimes I make this explicit and sometimes I don’t. The latest thread started with this post commenting on a tweet that observed that exp(−x²) ≈ (1 + cos(sin(x) + x))/2. Some people said online that that the approximation is simply due to the first […]

The post Pulling on a thread first appeared on John D. Cook.