lsum function

Properly Compute the Logarithm of a Sum (of Exponentials)