Can this ever be zero?  If so, you've got divide by zero --> NaN in the code below.