Dogs may not be the smartest animals on the block, but they certainly know their math. That is, at least according to a recent study, which suggests that sheepdogs use the perfect mathematical pattern to herd their wooly charges.

The study was recently published in the Journal of the Royal Society Interface, and details how sheepdogs use two simple rules to herd more than 100 individual sheep with precision.

To determine this, Andrew King of Swansea University and the Natural Environment Research Council (NERC) fitted a practiced sheepdog and its entire flock of sheep with exceptionally accurate global positioning satellite (GPS) devices.

Everyday roundups for the shepherding dog, combined with ideal simulations, allowed the researchers to develop a complex model that describes ideal shepherding strategies.

"We had to think about what the dog could see to develop our model. It basically sees white, fluffy things in front of it," King explained in a NERC release. "If the dog sees gaps between the sheep, or the gaps are getting bigger, the dog needs to bring them together."

"At every time step in the model, the dog decides if the herd is cohesive enough or not. If not cohesive, it will make it cohesive, but if it's already cohesive the dog will push the herd towards the target," added Daniel Strömbom, of Uppsala University, who helped create the model.

And that's pretty much it; the secret of sheepdogs is just to weave when the fluffy things aren't together, push when they are. Simple.

Kings adds that other models developed that looked good on paper, but which the dogs don't actually employ, did not work out as well as expected in practice.

"Other models don't appear to be able to herd really big groups - as soon as the number of individuals gets above 50 you start needing multiple shepherds or sheepdogs," he explained.

Still, practiced sheepdogs seem to have known this secret long before it took a team of human mathematicians to figure it out.

"If you watch sheepdogs rounding up sheep, the dog weaves back and forth behind the flock in exactly the way that we see in the [ideal] model," added King. "There are numerous applications for this knowledge, such as crowd control, cleaning up the environment, herding of livestock, keeping animals away from sensitive areas and collecting or guiding groups of exploring robots."