NATIONS, like people, occasionally get the blues; and right now the United States, normally the world's most self-confident place, is glum. Eight out of ten Americans think their country is heading in the wrong direction. The hapless George Bush is partly to blame for this: his approval ratings are now sub-Nixonian. But many are concerned not so much about a failed president as about a flailing nation.

One source of angst is the sorry state of American capitalism (see article). The “Washington consensus” told the world that open markets and deregulation would solve its problems. Yet American house prices are falling faster than during the Depression, petrol is more expensive than in the 1970s, banks are collapsing, the euro is kicking sand in the dollar's face, credit is scarce, recession and inflation both threaten the economy, consumer confidence is an oxymoron and Belgians have just bought Budweiser, “America's beer”.

And it's not just the downturn that has caused this discontent. Many Americans feel as if they missed the boom. Between 2002 and 2006 the incomes of 99% rose by an average of 1% a year in real terms, while those of the top 1% rose by 11% a year; three-quarters of the economic gains during Mr Bush's presidency went to that top 1%. Economic envy, once seen as a European vice, is now rife. The rich appear in Barack Obama's speeches not as entrepreneurial role models but as modern versions of the “malefactors of great wealth” denounced by Teddy Roosevelt a century ago: this lot, rather than building trusts, avoid taxes and ship jobs to Mexico. Globalisation is under fire: free trade is less popular in the United States than in any other developed country, and a nation built on immigrants is building a fence to keep them out. People mutter about nation-building beginning at home: why, many wonder, should American children do worse at reading than Polish ones and at maths than Lithuanians?

The dragon's breath on your shoulder

Abroad, America has spent vast amounts of blood and treasure, to little purpose. In Iraq, finding an acceptable exit will look like success; Afghanistan is slipping. America's claim to be a beacon of freedom in a dark world has been dimmed by Guantánamo, Abu Ghraib and the flouting of the Geneva Conventions amid the panicky “unipolar” posturing in the aftermath of September 11th.

Now the world seems very multipolar. Europeans no longer worry about American ascendancy. The French, some say, understood the Arab world rather better than the neoconservatives did. Russia, the Gulf Arabs and the rising powers of Asia scoff openly at the Washington consensus. China in particular spooks America—and may do so even more over the next few weeks of Olympic medal-gathering. Americans are discussing the rise of China and their consequent relative decline; measuring when China's economy will be bigger and counting its missiles and submarines has become a popular pastime in Washington. A few years ago, no politician would have been seen with a book called “The Post-American World”. Mr Obama has been conspicuously reading Fareed Zakaria's recent volume.

America has got into funks before now. In the 1950s it went into a Sputnik-driven spin about Soviet power; in the 1970s there was Watergate, Vietnam and the oil shocks; in the late 1980s Japan seemed to be buying up America. Each time, the United States rebounded, because the country is good at fixing itself. Just as American capitalism allows companies to die, and to be created, quickly, so its political system reacts fast. In Europe, political leaders emerge slowly, through party hierarchies; in America, the primaries permit inspirational unknowns to burst into the public consciousness from nowhere.

Still, countries, like people, behave dangerously when their mood turns dark. If America fails to distinguish between what it needs to change and what it needs to accept, it risks hurting not just allies and trading partners, but also itself.

The Asian scapegoat

There are certainly areas where change is needed. The credit crunch is in part the consequence of a flawed regulatory system. Lax monetary policy allowed Americans to build up debts and fuelled a housing bubble that had to burst eventually. Lessons need to be learnt from both of those mistakes; as they do from widespread concerns about the state of education and health care. Over-unionised and unaccountable, America's school system needs the same sort of competition that makes its universities the envy of the world. American health care, which manages to be the most expensive on the planet even though it fails properly to care for the tens of millions of people, badly needs reform.

There have been plenty of mistakes abroad, too. Waging a war on terror was always going to be like pinning jelly to a wall. As for Guantánamo Bay, it is the most profoundly un-American place on the planet: rejoice when it is shut.

In such areas America is already showing its genius for reinvention. Both the Republican and Democratic presidential candidates promise to close Guantánamo. As his second term ticks down, even Mr Bush has begun to see the limits of unilateralism. Instead of just denouncing and threatening the “axis of evil” he is working more closely with allies (and non-allies) in Asia to calm down North Korea. For the first time he has just let American officials join in the negotiations with Iran about its fishy nuclear programme (see article).

That America is beginning to correct its mistakes is good; and there's plenty more of that to be done. But one source of angst demands a change in attitude rather than a drive to restore the status quo: America's relative decline, especially compared with Asia in general and China in particular.

The economic gap between America and a rising Asia has certainly narrowed; but worrying about it is wrong for two reasons. First, even at its present growth rate, China's GDP will take a quarter of a century to catch up with America's; and the internal tensions that China's rapidly changing economy has caused may well lead it to stumble before then. Second, even if Asia's rise continues unabated, it is wrong—and profoundly unAmerican—to regard this as a problem. Economic growth, like trade, is not a zero-sum game. The faster China and India grow, the more American goods they buy. And they are booming largely because they have adopted America's ideas. America should regard their success as a tribute, not a threat, and celebrate in it.

Many Americans, unfortunately, are unwilling to do so. Politicians seeking a scapegoat for America's self-made problems too often point the finger at the growing power of once-poor countries, accusing them of stealing American jobs and objecting when they try to buy American companies. But if America reacts by turning in on itself—raising trade barriers and rejecting foreign investors—it risks exacerbating the economic troubles that lie behind its current funk.

Everybody goes through bad times. Some learn from the problems they have caused themselves, and come back stronger. Some blame others, lash out and damage themselves further. America has had the wisdom to take the first course many times before. Let's hope it does so again.