First, this is quite clearly in the wrong area, as gap_j has pointed out. That said, the answer lies in calculus -- you'll have to set the derivative equal to zero and identify the minimum(s). Based on the dimensions you've provided and an inference or two, the box is 5 units on the x-axis, 4 units on the y-axis, and 3 units on the z-axis. This means that, as you note, the shortest distance by traveling first up the z-axis would be 9.40 units:
p(z) = z + sqrt(x2 + y2)
There are two other options, with respect to traveling directly along an axis first; x-first and y-first:
p(x) = x + sqrt(y2 + z2)
p(y) = y + sqrt(x2 + z2)
These paths have values of 10 (exactly) and 9.83, respectively.
In order to achieve the p = 8.6
given in the problem, there would have to be some distance a along the x-axis such that:
p(a) = sqrt((x - a)2 + z2) + sqrt(y2 + a2)
else some distance b along the y-axis such that:
p(b) = sqrt((y - b)2 + z2) + sqrt(x2 + b2)
and the values p(a)
or p(b)
must be less than traveling directly along an axis. There are myriad such values for p(a)
.
Since this is presumably a homework problem for a calculus class, I'll leave finding the derivative to you, but the formulas are as provided. There is only one variable, so this shouldn't be particularly difficult. These can be generalized, of course, and it's a fairly simple task to calculate the results and identify the shorter path.