How can I approximate the logarithm of the sum?

6.2k Views Asked by At

Consider $\alpha = \log a$ and $\beta = \log b$, $b>a$. Are there formulas for approximating $\gamma = \log (a+b)$? What about $\theta = \log (a-b)$?

If it makes it easier, assume that $|\alpha| \gg 300$ so the obvious solution $\gamma = \log (10^\alpha + 10^\beta)$ is infeasible using standard double-precision floating point arithmetic (you can't easily store $a$ and $b$ in memory to begin with!).

2

There are 2 best solutions below

3
On

you can try this here $\gamma=\log\left[a\left(1+\frac{b}{a}\right)\right]$= $\log(a)+\log\left(1+\frac{b}{a}\right)$

2
On

Working in other question I found that for positive $x,y$ you could approximate: $$\ln(x+y)\approx \begin{cases} \frac{x^{\frac{1}{\ln(2)}}\ln(x)-y^{\frac{1}{\ln(2)}}\ln(y)}{x^{\frac{1}{\ln(2)}}-y^{\frac{1}{\ln(2)}}}, \quad x\neq y\\ \ln(x)+\ln(2),\quad x=y \end{cases}$$

which is based in this other approximation: $$\ln(1+e^x) \approx \begin{cases} \frac{x}{1-e^{-\frac{x}{\ln(2)}}},\quad x\neq 0\\ \ln(2),\quad x=0\end{cases}$$

For the last one the maximum error is below $0.0092$, and the plot is quite close:

comparison of the plots