Project Euler Lab - Problem 144

#144 - Laser Beam Reflections

● AppliedOfficial difficulty: 23%PolynomialsTier B - browser, with the efficient algorithmNot viewed
↖ Euler Lab

In laser physics, a "white cell" is a mirror system that acts as a delay line for the laser beam. The beam enters the cell, bounces around on the mirrors, and eventually works its way back out.

The specific white cell we will be considering is an ellipse with the equation \(4x^2 + y^2 = 100\).

The section corresponding to \(-0.01 \le x \le +0.01\) at the top is missing, allowing the light to enter and exit through the hole.

The light beam in this problem starts at the point \((0.0,10.1)\) just outside the white cell, and the beam first impacts the mirror at \((1.4,-9.6)\).

Each time the laser beam hits the surface of the ellipse, it follows the usual law of reflection "angle of incidence equals angle of reflection." That is, both the incident and reflected beams make the same angle with the normal line at the point of incidence.

In the figure on the left, the red line shows the first two points of contact between the laser beam and the wall of the white cell; the blue line shows the line tangent to the ellipse at the point of incidence of the first bounce.

The slope \(m\) of the tangent line at any point \((x,y)\) of the given ellipse is: \(m = -4x/y\).

The normal line is perpendicular to this tangent line at the point of incidence.

The animation on the right shows the first \(10\) reflections of the beam.

How many times does the beam hit the internal surface of the white cell before exiting?

This problem is taken from Project Euler, Problem 144.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=144. Published Friday, 9th March 2007, 05:00 pm. Solved by 7,247 members at time of mirroring.

Why this is useful

General Problem Solving. Builds computational thinking, decomposition, and debugging discipline - transferable, without a specific financial application.

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

Prerequisites

Lessons that prepare you:
1.1 Sets, Functions, and Relations · 2.1 Functions, Limits, and Continuity · 4.2 Linear Maps, Matrices, Rank, and the Null Space

Recommended stepping-stone problems: #719 · #110 · #820

Concepts: algebra

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 B - browser, with the efficient algorithm
Runs in the browser only with the intended efficient algorithm; a naive loop will hit the timeout.

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.