Project Euler Lab - Problem 576

#576 - Irrational Jumps

● ResearchOfficial difficulty: 78%ApproximationTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

A bouncing point moves counterclockwise along a circle with circumference \(1\) with jumps of constant length \(l \lt 1\), until it hits a gap of length \(g \lt 1\), that is placed in a distance \(d\) counterclockwise from the starting point. The gap does not include the starting point, that is \(g+d \lt 1\).

Let \(S(l,g,d)\) be the sum of the length of all jumps, until the point falls into the gap. It can be shown that \(S(l,g,d)\) is finite for any irrational jump size \(l\), regardless of the values of \(g\) and \(d\).
Examples:
\(S(\sqrt{\frac 1 2}, 0.06, 0.7)=0.7071 \cdots\), \(S(\sqrt{\frac 1 2}, 0.06, 0.3543)=1.4142 \cdots\) and
\(S(\sqrt{\frac 1 2}, 0.06, 0.2427)=16.2634 \cdots\).

Let \(M(n, g)\) be the maximum of \( \sum S(\sqrt{\frac 1 p}, g, d)\) for all primes \(p \le n\) and any valid value of \(d\).
Examples:
\(M(3, 0.06) =29.5425 \cdots\), since \(S(\sqrt{\frac 1 2}, 0.06, 0.2427)+S(\sqrt{\frac 1 3}, 0.06, 0.2427)=29.5425 \cdots\) is the maximal reachable sum for \(g=0.06\).
\(M(10, 0.01)=266.9010 \cdots\)

Find \(M(100, 0.00002)\), rounded to \(4\) decimal places.

This problem is taken from Project Euler, Problem 576.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=576. Published Saturday, 29th October 2016, 04:00 pm. Solved by 266 members at time of mirroring.

Why this is useful

Numerical Computing. Precision, conditioning, and numerical iteration transfer directly to pricing engines and model calibration (Phases 5, 13, 15).

We classify relevance honestly - not every Euler problem is a trading application.

Learning mode

Pick how much scaffolding you want. Your choice is remembered per problem.

Scratchpad

Mathematical notes, formulas, pseudocode, hypotheses, complexity notes. Saved automatically with your progress.

Python workbench

Tier C - reduced scale in browser; full scale in notebook
Browser runs a reduced, clearly-labelled educational scale; the original scale is provided in a local notebook.

Real Python (Pyodide) in a sandboxed Web Worker - no network, no filesystem, no DOM access. Ctrl/Cmd+Enter runs. Escape leaves the editor. Stop terminates the worker.

Python runtime not loaded (it boots on first run - a one-time local load).

Check your answer

Answers are checked against a salted hash held in a separate file - not printed in this page. This prevents accidental spoilers; it is not cryptographic protection (see the build notes).

Progressive hints

Confidence

Low confidence schedules this problem for spaced review, even if you solved it.

Reference solution

Spoiler
The complete original explanation (interpretation, naive approach, insight, proof, complexity, Python implementation, tests, common mistakes, alternatives) is hidden and lazy-loaded. Reveal it only after a meaningful attempt - the struggle is where the learning happens.