# Thread: large numbers in log space -- dividing summations

1. ## large numbers in log space -- dividing summations

Hi, I originally posted this is Calculus (it was my first post, probably a mistake, maybe still a mistake to post here, I am not sure). I tried to get help in Chat, but it wasn't coming up, and I tried to post in the Questions/Comments section, but I wasn't allowed. So, I realize I am somewhat double posting here, so I apologize.

Let's say I have:

N = Σ Σ p^a * q^b ...for p = 0 to 1 (non-inclusive), q = 0 to 1 (non-inclusive), and a = very large number, b = very large number
D = Σ r^c ...for r = 0 to 1 (non-inclusive), and c = very large number

and, I want to take N/D

However, because a,b,c are all very large, I'd like to take these into logarithms in order to make it tractable on a computer.

So, I can do:

N = Σ Σ e^(a*log(p) + b*log(q))
D = Σ e^(c*log(r))

and, then I can take N/D

This is equivalent, but still does not solve the computer limitation problem, since I have to take e^ before dividing N and D, and the computer just says those are 0

So, I'd like to do something like the following, but it doesn't seem right. This is where I am getting hung up

N/D = Σ Σ Σ e^(a*log(p) + b*log(q) - c*log(r))

This doesn't seem to be equivalent. In fact, I know it's not equivalent, because you can't divide summations in that way. Is there a better way?

Thanks!

2. ## Re: large numbers in log space -- dividing summations

Originally Posted by timfoea
Hi, I originally posted this is Calculus (it was my first post, probably a mistake, maybe still a mistake to post here, I am not sure). I tried to get help in Chat, but it wasn't coming up, and I tried to post in the Questions/Comments section, but I wasn't allowed. So, I realize I am somewhat double posting here, so I apologize.

Let's say I have:

N = Σ Σ p^a * q^b ...for p = 0 to 1 (non-inclusive), q = 0 to 1 (non-inclusive), and a = very large number, b = very large number
D = Σ r^c ...for r = 0 to 1 (non-inclusive), and c = very large number
would you like to reword this, as it is these seem to be empty summations.

CB

3. ## Re: large numbers in log space -- dividing summations

I would like to approximate/compute:

$\frac{\sum_{p=0.01}^{.99} \sum_{q=0.01}^{.99} p^a q^b}{\sum_{p=0.01}^{.99} r^c}$

where a,b,c are very large constants, (e.g., a = 10000, b = 20000, c = 30000), and I step the summations by, say, 0.01

thus, i use log space so this is tractable on a computer:

$\frac{\sum_{p=0.01}^{.99} \sum_{q=0.01}^{.99} e^{a \log p + b \log q}}{\sum_{p=0.01}^{.99} e^{c \log r}}$

the problem is that in order to do the final division, i have to take $e^{n}$ where n is a very small number for both the numerator and denominator, and thus the computer considers this to be 0. I would like to be able to do the all the math in log space before having to come out of it with $e^{n}$

Does that make sense?

4. ## Re: large numbers in log space -- dividing summations

May be you could change this sum to Riemann integral.

5. ## Re: large numbers in log space -- dividing summations

Originally Posted by timfoea
I would like to approximate/compute:

$\frac{\sum_{p=0.01}^{.99} \sum_{q=0.01}^{.99} p^a q^b}{\sum_{p=0.01}^{.99} r^c}$

where a,b,c are very large constants, (e.g., a = 10000, b = 20000, c = 30000), and I step the summations by, say, 0.01

thus, i use log space so this is tractable on a computer:

$\frac{\sum_{p=0.01}^{.99} \sum_{q=0.01}^{.99} e^{a \log p + b \log q}}{\sum_{p=0.01}^{.99} e^{c \log r}}$

the problem is that in order to do the final division, i have to take $e^{n}$ where n is a very small number for both the numerator and denominator, and thus the computer considers this to be 0. I would like to be able to do the all the math in log space before having to come out of it with $e^{n}$

Does that make sense?
For $a$ "very large":

$\sum_{k=1}^{99} \left( k \times 0.01 \right)^a \approx 0.99^a$

That is all the terms in the summation are negligable compared to the largest.

But I doubt that what you posted is the real question, which is what you should have posted.

CB