Sheepdogs are surprisingly mathematical in their approach to herding sheep, according to a new study in the Journal of the Royal Society.