The principle applies to waves in general, including (e.g.) sound waves in fluids and elastic waves in solids. In a modified form, it even works for matter waves : in quantum mechanics, the classical path of a particle is obtainable by applying Fermat's principle to the associated wave – except that, because the frequency may vary with the path, the stationarity is in the phase shift (or number of cycles) and not necessarily in the time.