Why may geodesic not be the shortest path on a surface?

The point is that local minimization does not imply global minimization. Local minimization says there is no nearby path that is shorter. That does not guarantee that there is no shorter path. Two comments give examples where you can find a local minimum in the sense that no nearby path is shorter, but if you are clever enough to find a very different path you will find it shorter. It is similar to the failures of greedy algorithms. In the path case, we assume that the path we want is reachable with small perturbations of the path we have. The examples show where that is not the case. In failures of a greedy algorithm, early choices constrain the global solution, and a later choice may show that the early choice was not correct.


Attach a image example for the above explanation, The geodesic between A and B longer than the curve from A to B:

enter image description here