Timothy Geithner was one of the fathers of $700 billion worth of unpopular federal bailouts in 2008 and 2009.

But as "Stress Test," his memoir of those troubled years, hits bookstores this week, current accounting shows that taxpayers made a $51.8 billion profit on the bailouts.

About half of that profit came from the bailout of Fannie Mae and Freddie Mac, the two mortgage finance companies that the government took over in September 2008. As of their most recent earnings reports, the two firms' payments back to Treasury has reached $213 billion, exceeding the combined $187.5 billion in government support by about $25 billion.

Related: Geithner's book recounts crisis

The government also made a $22.7 billion profit on the bailout of AIG (AIG), which Geithner oversaw, first as the president of the New York Fed in September 2008, then as the Obama administration's first Treasury Secretary.

The bailout of the nation's banks, from giants such as Bank of America (BAC) and Citigroup (C) down to small community banks, cost the government $250.5 billion. But the sale of the stock the government got as part of the bailouts brought in a $22.3 billion profit.

The government didn't do as well with the rescue of automakers General Motors (GM) and Chrysler Group, or with the auto loan company GMAC, now known as Ally Financial (ALLY). Taxpayers came up $11.2 billion short when all those bailouts are added together.

Other bailouts, including some direct help to homeowners, cost another $7.5 billion.

Related: Five years later, TARP price tag hits $40 billion

The lion's share of the money came from the Troubled Asset Relief Program, or TARP.

The current accounting shows a narrow loss just under $3 billion from TARP when comparing total bailouts of $423.7 billion from the fund to total payments back to Treasury. But some critics of the bailout suggest that about $38 billion of the payments -- those that came in the form of interest, dividends, and profits on sales -- shouldn't be counted towards TARP's profit or loss.

The money to Fannie and Freddie came straight from Treasury, while AIG received a large chunk of its bailout from the Federal Reserve.