Showing posts with label video. Show all posts
Showing posts with label video. Show all posts

Monday, 9 March 2026

The Feigenbaum Constant Revisited

It was in January of 2017 that I made my first and only post about one of the two Feigenbaum constants 4.66920160910299067185320382... The YouTube video that I included in that post is still active and I've embedded it in this post as well. Watching that will explain the significance of this constant. Here is a link to another video by Veritasium that covers the same ground.


It's not that I was avoiding this constant. It's just that, as far as I'm aware, it hasn't been appeared in reference to any number associated with my diurnal age since then. Today, as I turned \( \textbf{28099} \) days old, I noticed that the constant was mentioned in OEIS A257809:


A257809
  Lexicographically largest strictly increasing sequence of primes for which the continued square root map produces Feigenbaum's constant delta = 4.6692016... (A006890).


The progression of primes is as follows:

13, 67, 97, 139, 293, 661, 1163, 1657, 2039, 3203, 3469, 5171, 6361, 6661, 7393, 7901, 8969, 9103, 9137, 11971, 12301, 13487, 14083, 14699, 15473, 19141, 21247, \( \text{28099} \), 31039, 35423, 39047, 49223, 58427, 61493, 62171, 67699, 71971, 75869, 78857, 81533, 88007, 93199

In the OEIS comments, PARI code was provided and I got Gemini to change that into SageMath code. I've included the code below together with the commentary:

Computing a Prime Sequence using Feigenbaum's Constant in SageMath

Here is the complete SageMath code for generating a sequence of primes dictated by deeply nested square roots, incorporating Feigenbaum's constant. A highly precise value for $\delta$ is provided to ensure the sequence evaluates correctly, as nested square root calculations can be sensitive to floating-point precision.

The SageMath Code

# Force 500 bits of precision (approx 150 decimal digits)
R = RealField(500)

# Feigenbaum's constant delta extended to 100 decimal digits
delta = R("4.6692016091029906718532038204662016172581855774757686327456513430041343302113147371386897440239480138")

def CSR(v, s=0):
    # Ensure our running sum uses the 500-bit precision field
    s = R(s)
    for x in reversed(v):
        s = R(x + s).sqrt()
    return s

a = [13]

for n in range(50):
    print(a[-1], end=", ")
    
    i = prime_pi(a[-1]) + 1
    
    while True:
        next_primes = [nth_prime(i + j) for j in range(1, 10)]
        v_test = a + next_primes
        
        if CSR(v_test) >= delta:
            a.append(nth_prime(i))
            break
            
        i += 1
13, 67, 97, 139, 293, 661, 1163, 1657, 2039, 3203, 3469, 5171, 6361, 6661, 7393, 7901, 8969, 9103, 9137, 11971, 12301, 13487, 14083, 14699, 15473, 19141, 21247, 28099, 31039, 35423, 39047, 49223, 58427, 61493, 62171, 67699, 71971, 75869, 78857, 81533, 88007, 93199, 99611, 103183, 123031, 128603, 132499, 134807, 156139, 159293, ...

The Mathematical Context

Feigenbaum's constant $\delta \approx 4.6692016$ is a universal mathematical constant that arises in chaos theory and non-linear dynamics. Specifically, it describes the rate at which period-doubling bifurcations occur as a system approaches chaotic behavior.

While the constant was originally discovered in the context of the logistic map and population dynamics, in this code, it acts purely as a strict numeric threshold. The algorithm tests candidate prime numbers by nesting them inside a Continued Square Root (CSR) function. The sequence only accepts a new prime when the deeply nested square root expression of the sequence exceeds this chaotic boundary.

Because the sequence uses 9 lookahead primes and deeply nested roots, SageMath's RR (which defaults to 53 bits of precision) is perfectly suited to handle the threshold check rapidly without getting bogged down by the computational weight of exact symbolic algebra.


Step-by-Step Manual Trace

To understand the progression, we have to look at how Feigenbaum's constant dictates the threshold at each layer. Squaring $\delta$ gives us our initial internal target: $\delta^2 \approx 21.80144$.

Iteration 1

  • Current sequence: [13]
  • The Condition: To append a new prime, the algorithm requires the nested root of the sequence plus a 9-prime lookahead to cross the threshold:
    $$\sqrt{13 + \sqrt{p_1 + \dots}} \ge 4.6692016$$
  • Unpacking the Math: Squaring both sides and subtracting 13 strips away the outer layer:
    $$\sqrt{p_1 + \dots} \ge 8.80144$$
    Squaring once more gives the approximate threshold the lookahead primes must reach:
    $$p_1 + \dots \ge 77.465$$
  • The Search:
    • If the script tests the 18th prime (61), its lookahead sequence starts with 67. The continued square root of this lookahead evaluates to $\approx 8.72$, which falls short of the 8.80144 requirement.
    • When the script tests the 19th prime (67), the lookahead sequence starts with 71. The continued square root of this sequence evaluates to $\approx 8.95$, successfully crossing the threshold.
  • Result: The 19th prime is appended.
  • New Sequence: [13, 67]

Iteration 2

  • Current sequence: [13, 67]
  • The Condition: The nested expression is now one layer deeper:
    $$\sqrt{13 + \sqrt{67 + \sqrt{p_1 + \dots}}} \ge 4.6692016$$
  • Unpacking the Math: We already know from Iteration 1 that to satisfy the outer layer, the inner contents must exceed 8.80144:
    $$\sqrt{67 + \sqrt{p_1 + \dots}} \ge 8.80144$$
    Squaring this and subtracting 67 strips the second layer:
    $$\sqrt{p_1 + \dots} \ge 10.4654$$
    Squaring again shows what the next lookahead sequence must achieve:
    $$p_1 + \dots \ge 109.52$$
  • The Search:
    • Testing the 24th prime (89) uses a lookahead starting at 97, yielding a root of $\approx 10.37$ (too small).
    • Testing the 25th prime (97) uses a lookahead starting at 101, yielding a root of $\approx 10.56$.
  • Result: The 25th prime is appended.
  • New Sequence: [13, 67, 97]

Iteration 3

  • Current sequence: [13, 67, 97]
  • The Condition: The expression adds another layer:
    $$\sqrt{13 + \sqrt{67 + \sqrt{97 + \sqrt{p_1 + \dots}}}} \ge 4.6692016$$
  • Unpacking the Math: Relying on the unpacked threshold from Iteration 2:
    $$\sqrt{97 + \sqrt{p_1 + \dots}} \ge 10.4654$$
    Squaring and subtracting 97 gives the new inner requirement:
    $$\sqrt{p_1 + \dots} \ge 12.525$$
    Squaring this dictates the next lookahead target:
    $$p_1 + \dots \ge 156.88$$
  • The Search:
    • Testing the 33rd prime (137) yields a lookahead root of $\approx 12.3$.
    • Testing the 34th prime (139) uses a lookahead starting at 149, yielding a root of $\approx 12.7$.
  • Result: The 34th prime is appended.
  • New Sequence: [13, 67, 97, 139]

Asymptotic Growth Rate Script

Because of the nested square roots, the values required to maintain the threshold grow extremely quickly. The following script calculates the sequence, analyzes its growth rate, and visualizes the results on a logarithmic scale.

# Feigenbaum's constant delta
delta = 4.66920160910299067185320382

def CSR(v, s=0):
    for x in reversed(v):
        s = RR(x + s).sqrt()
    return s

a = [13]
growth_rates = []

# Generate the first 15 terms (kept smaller as it grows massively)
for n in range(15):
    i = prime_pi(a[-1]) + 1
    
    while True:
        next_primes = [nth_prime(i + j) for j in range(1, 10)]
        v_test = a + next_primes
        
        if CSR(v_test) >= delta:
            new_prime = nth_prime(i)
            # Calculate the ratio between the new prime and the square of the previous
            if len(a) > 0:
                growth_rates.append(RR(new_prime) / RR(a[-1]^2))
            
            a.append(new_prime)
            break
            
        i += 1

print("Sequence:", a)
print("Growth ratios (a_n / a_{n-1}^2):", [round(g, 4) for g in growth_rates])

# Plotting the sequence on a logarithmic scale
list_plot(a, scale='semilogy', axes_labels=['Index (n)', 'Prime Value (Log Scale)'], 
          title="Asymptotic Growth of the Sequence", color='blue', size=30)

Asymptotic Growth of the Sequence

The Asymptotic Analysis

When dealing with deeply nested square roots, the dominant mathematical constraint acting on the sequence is the squaring required to "unpeel" each layer.

If we approximate the relationship between two adjacent terms $a_n$ and $a_{n+1}$ to maintain a constant threshold $k$, the equation simplifies to:

$$\sqrt{a_n + \sqrt{a_{n+1} + \dots}} \approx k$$

Squaring both sides and isolating the inner root gives:

$$\sqrt{a_{n+1} + \dots} \approx k^2 - a_n$$

To keep the right side of the equation positive and stable, the next term in the sequence, $a_{n+1}$, must scale quadratically with respect to the current term $a_n$. This means the relationship is roughly:

$$a_{n+1} \approx (a_n)^2$$

Because each term is the square of the previous term, the sequence exhibits double exponential growth. The general closed-form asymptotic behavior for a sequence of this nature is:

$$a_n \sim C^{2^n}$$

where $C$ is a constant defined by the initial conditions of the system. In standard exponential growth, a variable increases by a fixed percentage. In double exponential growth, the number of digits in the number increases exponentially, which is why generating terms of this specific sequence requires significant computational power and highly optimized floating-point arithmetic.

Monday, 12 January 2026

Bogey Numbers


Video based on blog content, generated by NotebookLM

In a darts match, once you reach a score of between 170 and 2 inclusive, you can defeat your opponent with one, two or three darts provided you score doesn't correspond to one of the so-called "bogey numbers". These numbers are:

  • \(169 =13^2 \)
  • \(168=2^3 \times 3 \times 7 \)
  • \(166=2 \times 83 \)
  • \(165=3 \times 5 \times 11\)
  • \(163 \text{ is prime} \)
  • \(162 = 2 \times 3^4\)
  • \(159 = 3 \times 53\)
The maximum of score of 170 can be finished with two consecutive treble 20s followed by 50 (the red of the bullseye equivalent to 2 x 25). With a score of 2, you finish the match off with a single dart directed at double 1.

With my 77th birthday fast approaching, I wanted to consider how many ways there are to finish off a darts match from a score of 77. It turns out that there are 905 different ways (permalink) using two or three darts. Here are the possible two dart finishes:

  • 2-Darts: T9, DBull
  • 2-Darts: T13, D19
  • 2-Darts: T15, D16
  • 2-Darts: T17, D13
  • 2-Darts: T19, D10
The other 900 ways involve three darts, for example:  S1, D13, DBull. Figure 1 shows a plot of the total numbers of ways to finish for scores between 2 and 170. Click to enlarge. A score of 58 offers the largest number of ways to check out, 1404.


Figure 1: permalink

Of course professional darts players only choose from a very narrow selection out of all these possibilities as Gemini explains.

You have hit on the fundamental difference between the math of darts (which is what the code calculates) and the art of darts (which is what pros play).

While Python might find 50 ways to check out a score, a professional like Michael van Gerwen or Luke Littler might only ever consider one or two of them.


Infographic based on blog content
generated by NotebookLM


Here is the breakdown of the logic top players use to filter those thousands of possibilities down to the "correct" shot.

1. The Principle of "Splitting the Double" (The Safety Net)

This is the single most important rule in professional darts. Pros prioritize doubles that can be halved (split) and still remain a double if they miss into the single segment.

  • The "King" Double is D16 (32):

    • If you aim for D16 (32) and hit Single 16, you have 16 left. That is D8.

    • If you aim for D8 and miss into S8, you have 4 left (D2).

    • If you aim for D2 and miss into S2, you have 2 left (D1).

    • Result: You have 4 layers of safety. You can miss your double 3 times and still be on a finish without needing a "setup" dart to get back to an even number.

  • The Problem with D20 (Tops):

    • D20 is popular, but less safe. If you miss D20 (40) and hit S20, you have 20 left (D10).

    • If you miss D10 (20) and hit S10, you have 10 left (D5).

    • D5 is an odd number. You cannot finish on 5. You must now waste a dart hitting a Single 1 to leave D2.

The Decision: If a pro has a choice between leaving D20 or D16, they will almost always maneuver to leave D16.

2. "Percentage Darts" (Managing the Miss)

Pros assume they might miss the Triple and hit a Single. They choose routes where a "bad" throw (a single) still leaves a finishable score.

  • Example: You have 61 points left with 2 darts.

    • The "Amateur" Math Route: Triple 15 (45) leaves D8 (16).

      • Risk: If you miss T15 and hit S15, you have 46 left. You have 1 dart remaining. You cannot check out 46 with 1 dart. Turn over.

    • The "Pro" Route: Single 25 (Outer Bull) leaves D18 (36).

      • Safety: If you miss the Bull and hit S25, you have 36 left (D18). If you miss widely and hit S11 (a common neighbor to the bull), you have 50 left (Double Bull). You still have a shot at a double.

The Decision: The pro chooses the route where a miss keeps the turn alive.

3. Avoiding the "Bogey" Singles (Odd vs. Even)

The goal is to get to an even number as fast as possible.

  • If you are on an odd number (e.g., 17, 33, 45), you must hit an odd segment to get to an even finish.

  • If you are on an even number, you must hit an even segment (or a Triple even) to stay even.

Pros hate finishing on odd doubles (D19, D17, D15, etc.) because if they hit the single, they are stuck on an odd number again.

  • Bad: Aiming for D19 (38). Hit S19. Left with 19. Now you need S3 to leave D8. It's messy.

  • Good: Aiming for D18 (36). Hit S18. Left with 18 (D9). Still messy, but D18 is physically close to D4 and D1, making the recovery easier.

4. Board Management (Staying in Rhythm)

Dart players rely heavily on muscle memory. They prefer routes that require minimal movement around the board.

  • Example: 82 left.

    • Option A: Bull (50) + D16 (32). (Requires moving from center to right edge).

    • Option B (Pro Preference): D20 (40) + S10 + D16? No.

    • Option C (The "Top" Route): T14 (42) leaves D20 (40).

    • The "Phil Taylor" Route: Bull (50) leaves D16. (Some pros love the Bull because it fixes "messy" math instantly).

5. The "Matchplay" Factor (Aggressive vs. Conservative)

Finally, the choice depends on what the opponent is doing.

  • Scenario A: Opponent is way back (on 300 points).

    • Strategy: Go safe. Don't try a risky T20-T20-D20 finish. Just hit big scores to get down to D16 reliably. Use 3 darts to set up the perfect number.

  • Scenario B: Opponent is on a finish (e.g., 32).

    • Strategy: Aggressive. You must check out this turn. If you have 170, you must go T20-T20-Bull. You don't care about safety; you care about possibility.

Summary: The "Pro" Algorithm

If you were to program a "Pro Bot" rather than a "Math Bot," the logic would look like this:

  1. Can I finish this turn?

  2. If yes: Pick the route where a single (missed triple) leaves a finish for the next dart.

  3. If no: Pick the route that leaves 32 (D16) or 40 (D20) for the next turn.

  4. Avoid: Any route that leaves an odd number remainder.

Gemini created a program that will calculate the better choices when considering checking out. Figure 2 shows what it suggests for 77 (permalink).


Figure 2