Stocks gained Tuesday in a volatile session in which investors considered better-than-expected corporate profits with Federal Reserve (Fed) Chairman Ben Bernanke's warning that the U.S. economic recovery would be slow. Stocks opened higher on Caterpillar's positive outlook before declining in the morning and earl afternoon. Stocks rose in the second half of the session. Bernanke told lawmakers the pace of economic decline has “slowed significantly” but the labor market has deteriorated. He warned that improvement is uncertain and likely to be gradual. Light sweet crude oil for August delivery rose 74 cents to $64.72 a barrel on the New York Mercantile Exchange. The U.S. dollar gained versus the euro, the yen, and the British pound. The Dow Jones industrial average rose 67.79, or 0.8 percent, to 8,915.94. Caterpillar, considered a gauge of the global economy, saw its shares rise 8 percent after it reported signs of stabilization in the global economy. It posted better-than-expected quarterly profits but warned it could post a loss in the current third quarter. The broader Standard & Poor's 500 index rose 3.45, or 0.4 percent, to 954.58. The technology-heavy Nasdaq composite index rose 6.91, or 0.4 percent, to 1,916.20. The New York Stock Exchange composite index rose 13.09 to 6,154.39. The American Stock Exchange composite index fell 1.49 to 1,635.45. And the Russell 2000 index fell 1.74 to 525.22.