In the dark basement of the Field Museum of Natural History, my graduate student Marguerite Matherne carefully lifted the elephant’s tail. The elephant’s skin sat in a rumpled heap in the center of the room, like a stiff gray carpet that had been folded several times. Peeking out of the corner of the heap was the tail. It was 4.3 feet long, and before it had been deboned and dried, it weighed 25 pounds. The end of the tail was flat and as big as Marguerite’s hand. Radiating from each side were hundreds of thick black hairs. She touched one and winced. They were sharp and stiff. The tail looked like an ancient weapon. What was it used for?

For the last few months, Marguerite and I had been on a search to solve the mystery of the elephant’s tail. What was the purpose of the tails of large mammals, from elephants to giraffes to zebras? These tails appeared similar—they were all long, thin and tipped with black hairs, and they were perpetually swinging back and forth. The prevailing idea among biologists was that swinging served to deter flies, but exactly how did the tail do that? To tackle this project, I turned to Marguerite, the only mechanical engineer in my department that was also a mammal tail expert.

Before Marguerite was an engineer, she was an equestrian. She spent the hot Louisiana summers leaping over fences and galloping through open fields, thoughts of school and responsibilities far behind her. After a day of riding, she would take her horse, Sweet as Pye, to his stable to cool down and clean off. This meant standing next to him, lifting up his legs one by one, and cradling his hoof while removing mud and embedded pebbles. When she worked on Pye’s front hooves, he neighed and nuzzled her hands, searching for the treats she always had for him—apples and carrots and the peppermints from restaurants. But when she was at his rear, Pye grew nervous and started flicking his tail like a whip. He often hit Marguerite in the face. That’s when she learned to respect the horse’s tail.

Besides teaching Marguerite a lesson, the horse’s tail had other important duties. In the hottest part of summer, the air hung like a shroud, and biting insects were everywhere. Every horse owner has a can of fly spray handy because without it, the horse was in misery. His ears flicked, his head shook, his mane bounced wildly. He took nips at his own flanks and stomped his feet. But nothing moved more frantically than the horse’s tail. It swished and it swayed, it swatted and it slapped.

The tail has an important role to play. In just one day, a horse can lose a cup of blood to biting insects such as mosquitoes. Not only do the mosquitoes take blood, but they also give disease. Malaria, Zika virus, dengue fever are just a few of them. Keeping even a fraction of the mosquitoes away could have a big impact on a horse’s health. This war against the insects isn’t waged by the horse alone. Every large mammal, from zebra to giraffe to elephant, attracts clouds of insects. The bigger the animal, the bigger the cloud.

While an elephant and a horse may look different, they both have a swinging tail. Could both of them simply be shooing away mosquitoes?

To answer that question, Marguerite filmed every mammal tail she saw at the local park and the Atlanta Zoo. Luckily, zoo animals like to face their butts to the crowds, so she had no trouble getting enough data. Soon she had 12 animals, from giraffes to elephants to zebras. While videos of animals’ butts may seem mundane to most people, I couldn’t wait to see her footage.

This is the part about being a mechanical engineer that I love. Even a horse’s tail shouts out secrets, and engineering gives us the language to understand them.

When Marguerite and I look at a tail, we see a pendulum, the same kind as in a grandfather clock. In fact, pendulums have been used for timekeeping since Galileo studied them in the 1600s. What fascinated Galileo was the regularity of a pendulum. Every pendulum, from a chandelier to a horse’s tail, swings at a rate that depends only on the length of the pendulum, a rate called the pendulum’s natural frequency. It is this natural frequency that make the pendulum an extremely reliable source for telling time. It is also this natural frequency, this motion at resonance, that allows a grandfather clock to use so little energy. A single winding keeps a clock running for days. Since animals are swinging their tails nearly all their waking hours, I expected that they would want to swing them at their natural frequency to save energy.

The problem was that both horses and elephants swing their tails once per second. These rates are three times faster than the expected natural frequencies based on their tail length. It turns out natural frequency doesn’t really occur in nature—at least not in a horse’s tail!

I was shocked. By swinging his tail three times faster than his natural frequency, Pye needed to expend 27 times more energy than necessary. Why did he and all the other animals want to expend so much energy?

Perhaps it had to do with the old lore that a horse’s tail shoos away flies. But that idea had been around for years. We had to be convincing if we wanted to show it was really the case.

Marguerite bought a whip made from a real horse’s tail. She got some looks when she said she was going to use it for research. She then borrowed 100 mosquitoes from the Centers for Disease Control. She released the mosquitoes in my lab, and for an entire afternoon, she tried to hit the mosquitoes with the whip. She found it was an impossible task, but for a very interesting reason. Mosquitoes are extremely lightweight. A mosquito weighs two milligrams, or one fourth a chicken feather. As a result, every time the whip drew near, the mosquito would be blown away.

Based on her results, Marguerite decided to build a tail simulator, a device that could measure how moving tails can deter mosquitoes. It looked like a big hollow jar affixed with cameras. A motorized plastic tail rotated beneath the lid of the jar. Mosquitoes were released into the container, where they flew about. They had trouble landing on the curved walls and had a natural tendency to fly towards the ceiling of the jar. By rotating the tail at different speeds, she could see what motion best deterred the mosquitoes.

When the tail was stationary, the mosquitoes flew past it easily and landed on the ceiling. But when the tail moved at the frequency of horse tails, the mosquitoes behaved entirely differently. As they flew towards the tail, they suddenly took a U-turn as they got within a few centimeters of it. Although the air generated from a tail may feel negligible to us, it is a big deal to a mosquito. The air speeds generated were sufficient to repel up to 50 percent of the mosquitoes in the jar.

So why do animals swing their tails so quickly? It’s because they have to generate winds that are comparable to a mosquito flight speed. That’s about one meter per second or two miles per hour.

We hope that this study might have an impact on the treatment of horses. Many people who raise draft horses partake in the brutal practice of tail-docking, in which a horse’s tailbones are severed, mostly for aesthetic reasons. Our work shows that a horse’s tail isn’t just an ornament. It’s their main line of defense against biting insects.