mcwashik.dev

Skipping straight to the even Fibonacci numbers

The even Fibonacci terms occur three places apart. For Project Euler’s even-Fibonacci sum, a recurrence for these terms skips the odd numbers entirely:

Ek=4Ek−1+Ek−2

Starting with 2 and 8 gives 34, 144, 610, and so on. Each step produces another even term, with no parity check needed.

Read the full derivation (PDF)

The closest point on a plane

Lagrange multipliers give a compact formula for the point on a plane nearest to a given point. In vector notation, the geometry is straightforward: move along the plane’s normal until you reach the plane.

For a plane n·p=d with a nonzero normal n, the point closest to p0 is:

p=p0-n·p0-d‖n‖2n

For the unit-normal form, set n^=n‖n‖ and d^=d‖n‖, so the plane equation becomes n^·p=d^. The closest point is then:

p=p0−(n^·p0−d^)n^

Here d^ is the plane’s signed distance from the origin in the unit normal’s direction. The quantity in parentheses is the point’s signed perpendicular displacement from the plane. Subtracting that displacement along the unit normal gives the closest point on the plane.

Read the full derivation (PDF)