Goldman Sachs (GS 0.83%) reported its second quarter earnings on Thursday, and at first glance the numbers don't look great. Although revenue beat expectations, the firm's earnings plunged to just $1.98 per share from $4.10 in the same quarter a year ago. However, Goldman Sachs' second quarter was much better than it appears.

The reason for the earnings drop
During the second quarter, Goldman Sachs had $1.45 billion in expenses stemming from provisions for mortgage-related litigation and regulatory issues, a sharp increase from just $284 million in the second quarter of 2014. Excluding this, Goldman actually earned $4.75 per share -- which is more than it made a year ago, even though its revenue fell slightly.

In fact, once you back out these expenses, Goldman's numbers look more respectable all around. The company's return on equity rises from a dismal 4.8% to a solid 11.5%, and non-compensation expenses actually fell by about 1%, as opposed to the 48% year-over-year increase that appears in the company's press release.

Good results all around
In reality, Goldman actually did quite well during the second quarter. As chairman and CEO Lloyd Blankfein said in the company's press release, "While uncertainty in the EU weighed on investors' level of conviction, many of our businesses continued to benefit from generally improving economic conditions and healthy client activity."

For starters, Goldman Sachs' Investment Banking business capped off a record first half with 13% higher revenues than a year ago. The high level of merger and acquisition activity contributed to a 62% boost in advisory revenue, which was partially offset by a decline in underwriting volumes.

As far as trading goes, fixed income, currency, and commodities revenue fell by 28% year over year, similar to the numbers we've seen from other institutions this quarter, but equity revenue spiked by 24% on higher customer balances and strong activity in Europe and Asia.

The company's Investing and Lending division's revenue dropped 13% from last year mainly because of lower income from Goldman's equity investments, but improved from this year's first quarter.

Finally, Goldman's investment management revenue posted its second-best quarter ever, with revenue up 13% year over year, and assets under supervision increased to an all-time high of $1.18 trillion. Perhaps more importantly to Goldman's long-term health, the firm's long-term assets saw net inflows of $14 billion.

Is Goldman a buy after earnings?
Goldman Sachs managed to increase its earnings and its share price, despite the fact that the S&P 500 was essentially flat for the quarter.

^SPX Chart

Part of this is capitalizing on industry trends (such as strong M&A activity), and part of it is expense management. Total revenue fell by less than 1% compared to the year-ago period, but overall expenses fell by 2.3%, excluding the effect of the increased provisions.

In a nutshell, Goldman Sachs is growing its assets under management, controlling its expenses, and taking advantage of industry trends. Because of all this, as the U.S. economy begins to expand, Goldman Sachs will be in a strong position to profit. At a historically low price-to-book valuation of 1.2, Goldman Sachs is still a solid long-term pick, despite the fact that shares are trading at a seven-year high. I would view any weakness in the share price that results from this quarter's earnings as a potential buying opportunity to invest in the smartest guys on Wall Street.