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 new 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 new 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."

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 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."

Russell McLendon ( @russmclendon ) writes about humans and other wildlife.