Mathematics of Geothermal Energy