gait analysis

Horses, like all animals, have a number of different gaits. But how can they perform these complicated leg movements without having to stop and think? And why do they switch to a new gait when they want to go faster? Mathematics can shed some light on these questions.