Given a pair of coprime odd positive integers, define the function
It can be seen that , , and for all strictly between and .
Given two such pairs and , paths of infinitesimal width traverse the unit cube internally through every point such that . Remarkably, it can be shown that the point is always connected to the opposite corner . Furthermore, with the additional condition , 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 -plane, with corresponding 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 to .
Define to be the sum of the absolute changes in height (or -coordinate) over all uphill and downhill sections of the path from to . In the first example above, the path climbs over eleven uphill sections, and descends over ten downhill sections, giving . You are also given .
Let be the sum of over all pairs of primes, . You are given .
Find giving your answer rounded to five digits after the decimal point.