It's natural to be upset, even angry, when a vending machine fails us. We often react with profanity, followed by kicking, jostling and other emotional outbursts.

Squirrels deal with this scenario in a similar way, according to a 2016 study, flicking their tails in frustration before testing new strategies such as biting or shoving the deadbeat food dispenser. Not only is this an amusing glimpse into the mind of an irked squirrel, but it also suggests frustration can help fuel the resourceful rodents' legendary problem-solving skills — possibly while also scaring away competitors.

"Our results demonstrate the universality of emotional responses across species," says lead author Mikel Delgado, a Ph.D. student in psychology at the University of California-Berkeley, in a statement. "After all, what do you do when you put a dollar in a soda machine and don't get your soda? Curse and try different tactics."

Many tree squirrels are already known for emotional transparency, as seen in the chattering tirades they deliver after being treed by a dog, for example. Tails are also a big part of these displays, and as the new study reports, a specific swooping motion known as a tail flag — along with other "aggressive signals" — is especially common when some squirrels find themselves in a frustrating situation.

Published online in the Journal of Comparative Psychology, this is "thought to be among the first studies of frustration in free-ranging animals," according to the researchers. It focused on 22 wild fox squirrels inhabiting the UC-Berkeley campus, whose regular experience around humans made them easier study subjects. The researchers trained them to open a box for food reinforcement (a walnut), then tested them in one of four conditions: a normal transaction with the expected reward, a different reward (a piece of dried corn), an empty box or a locked box.

Watch how the squirrels dealt with disappointment:

In the control condition, squirrels performed fewer tail flags as well as fewer tail twitches (a distinct, less conspicuous motion). They used more "aggressive signals" when their snack was thwarted, including specific behaviors like tail flags and biting the box. The more frustrated they became — particularly if the container was locked — the more they flagged their tails, the researchers report.

That may seem like a waste of energy, and it is worth noting that one study of 22 squirrels hardly vindicates tantrums in general. Unchecked annoyance often leads people to do dumb things, and likely has mixed results in other animals, too. Acts of frustration have been documented in a variety of species, including chimpanzees, pigeons and fish, but we don't know much about what function they serve.

In the study, however, locked-up food didn't just prompt symbolic gestures of irritation. It also seemed to conjure a kind of angry persistence, with the squirrels trying new strategies such as biting, flipping and dragging the box rather than adopting a more conservative, sour-grapes apathy. And even if their efforts didn't open the box, they may still shed light on the emotional fuel that does help squirrels pull off feats like invading sealed attics or raiding squirrel-proof bird feeders.

"This study shows that squirrels are persistent when facing a challenge," Delgado says. "When the box was locked, rather than giving up, they kept trying to open it, and tried multiple methods to do so."

Not all squirrels think alike

Eastern gray squirrels first arrived in the U.K. from North America in the 19th century. (Photo: Sharon Day/Shutterstock)

And it appears some squirrels are better at problem solving than others.

A 2017 study in the U.K. shows that invasive eastern gray squirrels are more adept at solving complex problems than native Eurasian red squirrels. Recent statistics show they outnumber red squirrels 15 to one.

"Our research shows problem-solving could be another key factor for the success of grays," researcher Pizza Ka Yee Chow told the Guardian. "This may be especially important for an invasive species like gray squirrels, as they have evolved elsewhere and have to adapt to their surroundings."

In a controlled test, gray squirrels were more successful at a complex task of pushing and puling levers to open a container holding hazelnuts. Ninety-one percent of gray squirrels solved the problem, compared with only 62 percent of red squirrels. There is some good news for red squirrels, though. For the ones that did solve the difficult task, they solved it more quickly than the grays.

Researchers aren't sure, however, why gray squirrels are better at problem solving overall.

“It is not yet clear whether gray squirrels are born better problem solvers, or whether they work harder because they’re an invasive species living outside their natural environment," Chow told the Guardian.

Eurasian red squirrels are being outcompeted in parts of the U.K. by invasive American grays. (Photo: Ashley Buttle [CC BY 2.0]/Flickr)

More research is needed to understand annoyance in animals, and it's still unclear how much we can extrapolate from fox squirrels to other species, especially our own. Based on these findings, though, the 2016 study's authors suspect acts of frustration may be a helpful, even necessary step in the process of problem solving.

"Animals in nature likely face situations that are frustrating in that they cannot always predict what will happen," Delgado says. "Their persistence and aggression could lead them to try new behaviors while keeping competitors away.

"While not a direct intelligence test," she adds, "we think these findings demonstrate some of the key building blocks to problem-solving in animals — persistence, and trying multiple strategies."