I have two sets of large positive numbers $a_1,\ldots,a_n$ and $b_1,\ldots,b_n$. By 'large' I mean of the order of $10^{10}$. I want to calculate the ratio $$R = \frac{a_1 - a_2 + \cdots +(-1)^{n+1}a_n}{b_1 - b_2 + \cdots +(-1)^{n+1}b_n}.$$ It is already known that the exact value of $R$ is between $0$ and $1$. Each of the numerator and denominator is expected to be of the order of $10^{-1}$ to $10^1$.I would like to know if there is an algorithm to compute ratios like $R$ stably (exactly or approximately), so that the numbers involved in each step are not too large to cause overflow errors using finite-precision arithmetic. I am using the usual 64-bit 'double' data type in Matlab.I am aware of the Kahan summation algorithm, but using it to compute the numerator and denominator separately may not guarantee that their ratio is also as accurate.
Stable computation of ratio of sums of large numbers
algorithms;stability;precision