Skip to main content

All Questions

0 votes
1 answer
43 views

Compute $\frac{\sum_{i=1}^nx_iy_i}{\sum_{i=1}^nx_i}$ in logarithmic space

Let $x,y\in(0,\infty)^n$. Is there a clever way to compute $$\frac{\sum_{i=1}^nx_iy_i}{\sum_{i=1}^nx_i}\tag1$$ by calculating $\ln\frac{\sum_{i=1}^nx_iy_i}{\sum_{i=1}^nx_i}$ instead? My problem is ...
0xbadf00d's user avatar
  • 13.9k
1 vote
2 answers
1k views

Integer part of natural logarithm

Please, does anyone know of a algorithm to compute the integer part $n$ of natural logarithm of an integer $x$? $$n = \lfloor \ln(x) \rfloor$$ Preferably using integer arithmetic only (akin to ...
Ecir Hana's user avatar
  • 995
4 votes
2 answers
613 views

How to convert $\ln x - \ln y$ into a more accurate floating point representation?

I have an equation $\ln(x) - \ln(y)$ where x and y are very close to eachother. For example if $x = 5.1234$ then something like $fl(\ln(5.1234)) = 1.6338$ (with 4 significant digits). If $y = 5.1233$ ...
Josh Susa's user avatar
  • 153
2 votes
2 answers
310 views

How can I rearrange this logarithmic formula to be computer friendly?

I've had a look through the logarithmic identities on Wikipedia, but nothing fits the bill. Basically, I have a formula which shows how much more 'risky' one number is compared to another, where 0 = ...
Dan W's user avatar
  • 645
2 votes
1 answer
1k views

How are floating-point numbers logarithmically distributed?

From what I remember from a lecture I had of a course I'm attending called "introduction to computational science", floating-point numbers are distributed logarithmically. What does it mean? ...
user avatar
4 votes
2 answers
756 views

How to understand or derive the formula "Mantissa bits${}/\log_2 10 ={}$ Decimal digits of precision"?

I asked a question a couple days ago about floating point precision on stackoverflow called, "Is floating point precision mutable or invariant?" and I received the following response. The formula ...
Wandering Fool's user avatar
2 votes
2 answers
3k views

Converting base2 scientific notation to base10 scientific notation

I would now like to know how to convert a value in base2 scientific notation (is that the correct terminology?), say 1.93 * 2 ^ 88, into the form of A * 10 ^ B. I want to do this without expressing ...
Damien's user avatar
  • 23
8 votes
1 answer
2k views

Explain this code to compute $\log(1+x)$

It's well known that you need to take care when writing a function to compute $\log(1+x)$ when $x$ is small. Because of floating point roundoff, $1+x$ may have less precision than $x$, which can ...
Chris Taylor's user avatar
  • 29.2k