How can true altitude be calculated from pressure altitude, temperature and altimeter setting? The manual that came with my Jeppensen E6B has the following sample...


  If an aircraft is flying at 12,500 feet with an outside air
  temperature of -20C and the altimeter is set on 30.42 inches of
  mercury, what is the true altitude?


The explanation goes on to find a pressure altitude of 12,000 feet.  After placing -20C over 12,000 we find 12,500 (12.5) on the B scale and read the true altitude of 12,000 (12.0) on the outer ring.  

Looking closely at the outer ring, I see that the true altitude is actually just slightly below 12,000.  Now for practical purposes I realize we don't worry about differences like this and round the result.  But I'm working on a project in which I need to calculate the true altitude precisely.  I'm having a difficult time finding the formula.  The closest thing I have found says the correction is 4 feet per thousand feet indicated per degree off of ISA.

When I attempt to apply that formula to our sample problem I get 4 * 12.5 * -35 = -1750.   Applying that correction gives a value far below expected so obviously I'm doing something wrong.  Can someone straighten me out here?  References to documentation with educational value are especially welcome.
I would think the OAT in the example is what your on-board thermometer is showing, so at 12,500 ft, not at sea level. ISA is +15°C at sea level, but at 12,500 ft it is -9.8°C, so you are just -10 off ISA. Let's see. 4 ⋅ 12.5 ⋅ (−10) = −500, so the formulas match.

Note though, that this is still just an approximation. The temperature lapse rate might also differ and that would have to be taken into account as well. The more precise equation is also nonlinear.