# Best way to handle the ratio which cannot be represented as floating point numbers. I need to calculate the ratio of the form: s=sum_1^3 q_i p_i=(q_i)/(sum_1^3q_i} where q_i >0. One problem is that q_i are too small that they can not represented as floating point numbers, then I can try logarithms z_i=log(q_i) and log(pi)=log(q_i)−log(q_1+q_2+q_3), at this moment, I know log(q_1)=−2012,log(q_2)=−2013,log(q_3)=−2014, but how to deal with log(q_1+q_2+q_3), any one could give me some idea?

Best way to handle the ratio which cannot be represented as floating point numbers.
I need to calculate the ratio of the form:
$s=\sum _{1}^{3}{q}_{i}$, $\phantom{\rule{1em}{0ex}}$${p}_{i}=\frac{{q}_{i}}{\sum _{1}^{3}{q}_{i}}$
where ${q}_{i}>0$. One problem is that ${q}_{i}$ are too small that they can not represented as floating point numbers, then I can try logarithms ${z}_{i}=\mathrm{l}\mathrm{o}\mathrm{g}\left({q}_{i}\right)$ and $\mathrm{l}\mathrm{o}\mathrm{g}\left({p}_{i}\right)=\mathrm{l}\mathrm{o}\mathrm{g}\left({q}_{i}\right)-\mathrm{l}\mathrm{o}\mathrm{g}\left({q}_{1}+{q}_{2}+{q}_{3}\right)$, at this moment, I know $\mathrm{l}\mathrm{o}\mathrm{g}\left({q}_{1}\right)=-2012,\mathrm{l}\mathrm{o}\mathrm{g}\left({q}_{2}\right)=-2013,\mathrm{l}\mathrm{o}\mathrm{g}\left({q}_{3}\right)=-2014$, but how to deal with $\mathrm{l}\mathrm{o}\mathrm{g}\left({q}_{1}+{q}_{2}+{q}_{3}\right)$, any one could give me some idea?
thanks
You can still ask an expert for help

• Questions are typically answered in as fast as 30 minutes

Solve your problem for the price of one coffee

• Math expert for every subject
• Pay only if we can solve it

goffaerothMotw1
Hint
Let me suppose ${q}_{1}>{q}_{2}>{q}_{3}$. So,
${p}_{1}=\frac{{q}_{1}}{{q}_{1}+{q}_{2}+{q}_{3}}=\frac{1}{1+\frac{{q}_{2}}{{q}_{1}}+\frac{{q}_{3}}{{q}_{1}}}$
Now,
${p}_{2}={p}_{1}\frac{{q}_{2}}{{q}_{1}}$
${p}_{3}={p}_{2}\frac{{q}_{3}}{{q}_{2}}$
I suppose that this will give you your number for almost any accuracy (computing the required ratios from the logarithms).