The principle of least action states that, of all possible paths a particle, such as a photon, could take, it will take the one with minimal integrated energy. Analogous optimization principles are used in software that finds the best route from place A to place B, finds the best price for a concert ticket, or finds the most likely interpretation of data.