Weak oil prices battered oil and gas companies during the third quarter after oil fell more than 20% during the quarter. However, while that plunge in crude prices had a significant impact on Occidental Petroleum's (NYSE:OXY) results, the company actually performed rather well. In fact, it turned in a surprising profit to go along with rising cash flow.

After all the noise, Occidental Petroleum made money
On the surface, Occidental Petroleum reported a pretty abysmal quarter, turning in a loss of $3.42 per share, after taking $2.6 billion in after-tax charges relating to the sharp decline in oil prices. However, after adjusting for those charges, the company actually earned $24 million, or $0.03 per share, which was quite a surprise after analysts had expected the company to lose $0.01 per share.

Even more impressive was the fact that operating cash flow increased from $800 million last quarter to $1 billion in the third quarter in spite of the decline in oil and gas prices.

A formula that works
Fueling this unexpected profit and stronger cash flow was robust production growth of 16% year over year to 689,000 barrels of oil equivalent per day, or BOE. Nearly all of that growth was fueled by the company's Permian Resources division as well as from the start-up of the Al Hosn project in the UAE, which alone contributed 50,000 BOE/d to the company's production this quarter.

Having said that, the real highlight was the Permian Resources division, which saw production spike 72% year over year to 74,000 BOE/d. However, not only was production higher, but costs within this division are coming way down. Well costs for a Wolfcamp well are down 40% over the year-ago quarter, while unit operating costs are down 18% over that same time frame. That combination of stronger production and lower costs is the formula for producing higher cash flow in a low oil price environment.

Getting rid of what's not working
The other thing the company is doing amid lower oil prices is reducing its exposure to areas that aren't as strong in the current oil price environment. That's why the company recently made the decision to exit the Williston Basin and reduce its involvement in non-core operations in the Middle East and North Africa.

While a lot has been made of the low reported sales price of the company's Williston Basin acreage, the fact of the matter is that Occidental isn't in a prime spot, and that's why its production is slumping. In fact, over the past year, its production has fallen 4,000 BOE/d to just 17,000 BOE/d. This is because the company simply can't earn strong returns on the new wells needed to keep production from declining.

This is big difference between Occidental and a competitor like Whiting Petroleum (NYSE: WLL), which leads the basin in production -- and is doing so because Whiting's acreage is in the sweet spot of that play, meaning there is more oil saturating the rocks beneath its acreage. Because of that factor, and its lower well costs, Whiting can earn an internal rate of return of 31% at a $50 oil price, while Occidental struggled to make an economic return on its acreage even when oil was north of $100 per barrel.

Investor takeaway
Occidental Petroleum found a formula that works, which is to push its production higher while pushing its costs lower. The net result of this is a company that generated more cash flow this quarter despite the fact that oil prices were lower. Having said that, the company isn't growing production for the sake of growth, which is evident by its decision to let higher-cost production in places like the Williston Basin decline. Because it can't earn returns on par with what rivals like Whiting Petroleum are enjoying, it's choosing to walk away and use the cash from that sale to bolster its more profitable operations.

Matt DiLallo has no position in any stocks mentioned. The Motley Fool has no position in any of the stocks mentioned. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.