I have a surface defined by a known function $f(x,y)$. Given a starting point $(x_0, y_0)$ I want to step along the surface in the direction of the gradient vector until I reach a maximum value (in other words taking the locally optimal path to the maximum). I know there is only one interior extreme value for my function on the region of interest. Is there a way to determine the length of that optimal path in the $xy$ plane? Meaning that I do not care about the length of the path along the surface itself, I want to know the length of the path taken below the surface in the $xy$ plane.
My computational approach to this problem is to take small steps in the direction of the gradient vector from $f(x_0,y_0)$ to $f(x_0 + a, y_0 + b)$ where $(a, b)$ are the components of $h\dfrac{\nabla f(x_0, y_0)}{||\nabla f(x_0, y_0)||}$ and $h$ is some small value like $0.01$. Iterate that process until $\nabla f = 0$ and compute my step size $h$ times the number of steps $n$.
It feels like there is some obvious theorem that applies here so sorry if this is a repost; I'm a little rusty on this topic and couldn't figure out a phrasing of this question that gave useful results when I searched.