Some of us are scientists!
My answer to the question is... don't bother. What Terry is missing from his equation is the heat capacity for the contents in the numerator, which would be different for a mash than it would be for water, and would vary according to mash thickness. Further, the heat loss rate won't be constant, as it would vary with external temperature and air circulation. Plus, the very notion of mash temperature is misleading. If it isn't well insulated then the centre of the mash will be considerably warmer than the the parts nearest the wall. If you heat from below with an element, then the lower part will be hotter, perhaps much hotter. To get it even you will need to recirculate like an all-in-one system, and the rate of recirulation will also affect the rate of heat loss, and the rate of recirculation depends on mash thinkness, grain crush, the pump and how much it is throttled. You'll never balance the heat going and coming out with an equation, which is why all commercial and home-brew electronic setups that keep a constant mash temperature have a temperature probe and a thermostat to make small adjustments on the fly.