← Complete problem index

PROJECT EULER · #0975

A Winding Path

Statement only · UnsolvedOriginal problem ↗

Given a pair (a,b) of coprime odd positive integers, define the function Ha,b(x)=1212(a+b)(bcos(aπx)+acos(bπx))It can be seen that Ha,b(0)=0, Ha,b(1)=1, and 0<Ha,b(x)<1 for all x strictly between 0 and 1.

Given two such pairs (a,b) and (c,d), paths of infinitesimal width traverse the unit cube internally through every point (x,y,z)[0,1]3 such that z=Ha,b(x)=Hc,d(y). Remarkably, it can be shown that the point (0,0,0) is always connected to the opposite corner (1,1,1). Furthermore, with the additional condition gcd(a+b,c+d){2,4}, it can be shown that there is exactly one path connecting the two points.

0975_examples.png

Shown above are two examples, as viewed from above the cube. That is, we see the paths projected onto the xy-plane, with corresponding z values indicated with varying colour. In the second example some paths are coloured grey to indicate that, while they exist, they do not form part of the path from (0,0,0) to (1,1,1).

Define F(a,b,c,d) to be the sum of the absolute changes in height (or z-coordinate) over all uphill and downhill sections of the path from (0,0,0) to (1,1,1). In the first example above, the path climbs 4.00886 over eleven uphill sections, and descends 3.00886 over ten downhill sections, giving F(3,5,3,7)7.01772. You are also given F(7,17,9,19)26.79578.

Let G(m,n) be the sum of F(p,q,p,2qp) over all pairs (p,q) of primes, mp<qn. You are given G(3,20)463.80866.

Find G(500,1000) giving your answer rounded to five digits after the decimal point.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.