Problem 975
A Winding Path
Given a pair $(a,b)$ of coprime odd positive integers, define the function
$$H_{a,b}(x)=\frac{1}{2}-\frac{1}{2(a+b)}\Bigl(b\cos(a\pi x)+a\cos(b\pi x)\Bigr)$$
It can be seen that $H_{a,b}(0)=0$, $H_{a,b}(1)=1$, and $0 < H_{a,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)\in [0,1]^3$ such that $z=H_{a,b}(x)=H_{c,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)\in\{2,4\}$, it can be shown that there is exactly one path connecting the two points.

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 $\approx4.00886$ over eleven uphill sections, and descends $\approx3.00886$ over ten downhill sections, giving $F(3,5,3,7)\approx7.01772$. You are also given $F(7,17,9,19)\approx 26.79578$.
Let $G(m, n)$ be the sum of $F(p,q,p,2q-p)$ over all pairs $(p,q)$ of primes, $m\leq p < q\leq n$. You are given $G(3, 20)\approx463.80866$.
Find $G(500,1000)$, giving your answer rounded to five digits after the decimal point.
蜿蜒小径
给定一对互质的正奇数$(a,b)$,定义函数
$$H_{a,b}(x)=\frac{1}{2}-\frac{1}{2(a+b)}\Bigl(b\cos(a\pi x)+a\cos(b\pi x)\Bigr)$$
可以验证$H_{a,b}(0)=0$,$H_{a,b}(1)=1$,且对于所有严格介于$0$和$1$之间的$x$有$0 < H_{a,b}(x) < 1$。
给定两对这样的数$(a,b)$和$(c,d)$,在单位立方体内部所有满足$z=H_{a,b}(x)=H_{c,d}(y)$的点$(x,y,z)\in [0,1]^3$将构成无限细的路径。值得注意的是,立方体的顶点$(0,0,0)$总能沿着路径与其对角顶点$(1,1,1)$相连。此外,若$\gcd(a+b,c+d)\in\{2,4\}$,则连接这两点的路径恰好只有一条。

如上图以立方体俯视图的形式展示了两个例子;也就是说,我们看到的是路径在$xy$平面上的投影,对应的$z$值则用不同颜色表示。在第二个例子中,一部分路径被标记为灰色,表示它们虽然存在,但并不属于从$(0,0,0)$到$(1,1,1)$的路径的一部分。
定义$F(a, b, c, d)$为从$(0,0,0)$到$(1,1,1)$的路径上所有上坡段和下坡段的高度(即$z$坐标)绝对变化量之和。在上面的第一个例子中,路径在$11$个上坡段攀升了$\approx4.00886$,在$10$个下坡段下降了$\approx3.00886$,因此$F(3,5,3,7)\approx7.01772$;此外还已知$F(7,17,9,19)\approx 26.79578$。
记$G(m, n)$为所有满足$m\leq p < q\leq n$的质数对$(p,q)$所对应的$F(p,q,p,2q-p)$之和。已知$G(3, 20)\approx463.80866$。
求$G(500,1000)$,并四舍五入保留五位小数作为你的答案。