Is the U.S. as great as U.S. athletes are?

Pessimism has flavored this election campaign. America is in decline. The country is on the wrong track. We’re getting our clocks cleaned in global trade deals. We’re still suffering from the humiliation of Iraq.

The share of Americans who say that democracy is a “fairly bad” or “very bad” system of government is rising sharply. A quarter of young Americans feel that way, according to data drawn from the World Values Survey. A majority of young Americans believe that the United States should stay out of world affairs, according to a Chicago Council on Global Affairs report.

Yet while watching the Olympics, we didn’t seem like some sad-sack country in terminal decline. If anything, the coverage got a little boring because we were always winning! And the winners have such amazingly American stories and personality types (Biles, Ledecky and, yes, Lochte).

American Olympic performance has been astoundingly consistent over the recent decades. With rare exceptions, we can be counted on to win between 101 and 110 medals Olympiad after Olympiad. The 2016 team had made that mark before the weekend and finished with an astounding 121 medals, 46 of them gold.

Never miss a local story.

Sign up today for unlimited digital access to our website, apps, the digital newspaper and more.

We’re not great when measured by medals per capita (New Zealand, Denmark, Hungary, Australia and Britain are the big winners there), but America does have more medals than any other nation in history, and that lead is widening.

Moreover, America doesn’t win because we have better athletes (talent must be distributed equally). America does well because it has such great systems for preparing athletes. Medals are won by institutions as much as by individuals. The Germans have a great system for training kayakers, equestrians and throwers — the discus or javelin. The U.S. has amazing institutions to prepare jumpers, swimmers, basketball players, gymnasts, runners and decathletes.

The big question is: Is the greatness of America’s sports institutions reflective of the country’s strong institutions generally, or is it more like the Soviet Union’s sports greatness, a Potemkin show masking national rot?

Well, if you step outside the pall of the angry campaign rhetoric, you see that America’s institutions are generally quite strong. Over the past decades, some developing countries, like Brazil, India and China, posted glitzy economic growth numbers. But those countries are now all being hampered by institutional weakness and growth is plummeting.

But America’s economic success is like our Olympic success, writ large. The nation’s troubles are evident, but our country has sound fundamentals. The American dollar is by far the world’s currency. The Food and Drug Administration is the benchmark for medical standards. The American patent system is the most important in the world.

Nine of Forbes’ 10 most valuable brands are American (Apple, Google, IBM and so on). The U.S. is the leading energy producer. We have 15 (at least!) of the world’s top 20 universities, while Hollywood is as dominant as ever.

America is also quite good at change. The median age in the U.S. is 37.8, compared with 46.5 for both Germany and Japan. The newer a technology is, the more the U.S. is likely to dominate it — whether it’s the cloud or the sharing economy. According to The Economist, 91 percent of online searches are done through American companies’ services, and 99 percent of smartphones run on American-made operating systems.

Some American industries have declined, but others are rising. American fund managers handle 55 percent of the world’s assets. American businesses host 61 percent of the world’s social media users.

On the campaign circuit, global trade is portrayed as this great national disaster. We’re being destroyed by foreigners! The Trans-Pacific Partnership was the central dominating boogeyman at the Democratic National Convention, especially among people who have no clue what’s in it.

In fact, America succeeds in global trade about as well as at the Olympics. We rank third, behind Switzerland and Singapore, in global competitive rankings put out by the World Economic Forum. When trade is leveled by international agreements, American firms take advantage and win customers.

As Robert B. Zoellick noted recently in The Wall Street Journal, in the first five years after the U.S. has concluded free-trade agreements, the country’s exports to those places have risen three times faster than overall export growth.

Over the past five years, Zoellick wrote, the U.S. has run a $320 billion trade surplus in manufactured goods with its free-trade partners. The country’s farmers and ranchers boosted exports to free-trade partners by 130 percent between 2003 and 2013.

In one important way sports is not like economics. In Rio there were only three medals in each event. Global trade is not zero-sum. It spreads vast benefits across societies, while undeniably hurting some businesses in narrow fields along the way.

Of course, we have to take care of those who are hurt, but the biggest threat now is unmerited pessimism itself, and the stupid and fearful choices that inevitably flow from it.