I'm using R and have the following task. Let's say I have access to log(a) and log(b), and I want to compute a/(a+b). Further suppose that log(a) and log(b) are very negative, e.g. -1000, then how do I compute a/(a+b) in the most numerically efficient way? Keep in mind that due to underflow, exp(log(a)) will output a 0.
How should I do this in R?
Consider the following test case:
log_a = log(2e-100)
log_b = log(4e-100)
I want a function which can take these as log scores and output 0.33.