We could hypothesize dogs are working out calculus problems, or we could just hypothesize that the dog tried it one way, then another, and eventually over the course of its lifetime works out how to get to the ball the most quickly, which in comparison to the difficulty of manipulating all of its dozens of muscles to perform the running optimally in the first place is a frankly insignificant challenge. Or, to put it into a human reference frame, we do not do calculus problems to catch things. We "just" catch them. Neurons are built to solve this problem.
We could hypothesize that the ants have a simple pheromone-based optimization system that naturally mathematically converges on the same solution as Snell's Law when, after all, faced with the same problem, but... uh... actually it's not at all clear to me how the article manages to make this sound mysterious after what is a fairly effective solution to the problem. If nothing else, the ants taking the most optimal path will make more to-and-from trips than other ants, thus laying thicker trails; that plus an initial shotgun approach are adequate to explain.
This is particularly egregious since none of the math here is very complicated, and it is completely unsurprising that when the same problem is given to several optimizing agents in several domains that the same solution pops out. There is not very many bits of information in this problem.