According to this thread: To Compute log(a+b)
Sometimes log_sum is implemented like this:
log(a + b) = log(a * (1 + b/a)) = log a + log(1 + b/a)
I'm confused about why this approach is more efficient.. Does anyone have ideas about this?
This approach might be useful, when a
is constant (at least for some b
values), and b<<a
(significantly smaller). In this case log(1 + b/a)
could be calculated through Taylor series expansion fast and with good precision (log1p
function in some math libraries, another method)