Project Euler Lab - Problem 450

#450 - Hypocycloid and Lattice Points

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

A hypocycloid is the curve drawn by a point on a small circle rolling inside a larger circle. The parametric equations of a hypocycloid centered at the origin, and starting at the right most point is given by:

\[x(t) = (R - r) \cos(t) + r \cos(\frac {R - r} r t)\] \[y(t) = (R - r) \sin(t) - r \sin(\frac {R - r} r t)\]

Where \(R\) is the radius of the large circle and \(r\) the radius of the small circle.

Let \(C(R, r)\) be the set of distinct points with integer coordinates on the hypocycloid with radius R and r and for which there is a corresponding value of t such that \(\sin(t)\) and \(\cos(t)\) are rational numbers.

Let \(S(R, r) = \sum_{(x,y) \in C(R, r)} |x| + |y|\) be the sum of the absolute values of the \(x\) and \(y\) coordinates of the points in \(C(R, r)\).

Let \(T(N) = \sum_{R = 3}^N \sum_{r=1}^{\lfloor \frac {R - 1} 2 \rfloor} S(R, r)\) be the sum of \(S(R, r)\) for R and r positive integers, \(R\leq N\) and \(2r < R\).

You are given:

\(C(3, 1)\)=\(\{(3, 0), (-1, 2), (-1,0), (-1,-2)\}\)
\(C(2500, 1000)\)=\(\{(2500, 0), (772, 2376), (772, -2376), (516, 1792), (516, -1792), (500, 0), (68, 504), (68, -504),\)
 \((-1356, 1088), (-1356, -1088), (-1500, 1000), (-1500, -1000)\}\)

Note: \((-625, 0)\) is not an element of \(C(2500, 1000)\) because \(\sin(t)\) is not a rational number for the corresponding values of \(t\).

\(S(3, 1) = (|3| + |0|) + (|-1| + |2|) + (|-1| + |0|) + (|-1| + |-2|) = 10\)

\(T(3) = 10; T(10) = 524; T(100) = 580442; T(10^3) = 583108600\).

Find \(T(10^6)\).

This problem is taken from Project Euler, Problem 450.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=450. Published Sunday, 15th December 2013, 07:00 am. Solved by 240 members at time of mirroring.

Why this is useful

Optimization. The transferable skill is replacing infeasible enumeration with a mathematical reduction - the core move in calibration and large-scale computation (Phases 10, 13).

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.