I'm trying to find an approximation for the optimal path for a material point, minimizing the integral associated with the total energy.

I managed to write the exact formula for the energy along a path covering the points $(x,y(x))$, which should be:

$$ E(y) = \int_{x_0}^{x_f} \sqrt{a-by(x)}\sqrt{1+(y^\prime(x))^2} \ \ \mathrm{d}x $$

Where $a$ and $b$ are constants related to mass, initial position and speed, and gravitational constant.

If I knew the path, numerically computing the integral would be trivial, but I don't know any methods to estimate $$ y = \arg\min_{z} J(z) $$

I suppose that $y$ should be at least a $\mathcal{C}^1$ function (possibly $\mathcal{C}^\infty$?), but the only way to approach the problem in a general way that I can think about is to use a (linear) spline function, replacing differentiation with incremental ratios.

I could start with a straight line path, split it in $n$ parts and find a greedy optimization for each segment of the spline, moving the node $(x_1,y_1)$ upwards or downwards along the $y$-axis until an approximate minimum is found, then repeating the same with the node $(x_2,y_2)$, but this is obviously not going to work: .

I could instead try to move all the nodes at once (except the starting and ending ones, fixed at $(x_0,y_0)$ and $(x_f,y_f)$), but this seems too computationally intensive to pursue when using a finer grid.

Is there an efficient method to find an optimal path?