Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Currently I calculate log as following:

#define MAXLOG 1001
double myloglut[MAXLOG];
void MyLogCreate()
{
    int i;
    double exp, expinc;
    expinc = (2.0 - 0.1) / MAXLOG;
    for (i = 0, exp = 0.1; i <= MAXLOG; ++i, exp += expinc)
            myloglut[i] = log(exp);
    myloglut[478] = 0; // this one need to be precise
}

double MyLog(double v)
{
    int idx = (int)((MAXLOG*(v - 0.1)) / (2.0 - 0.1));
    return myloglut[idx];
}

As you can see I'm interested only in range 0.1 - 2.0. However, I need more precision around 0. How can I achieve that non linear calculation? Also is there any way to use some interpolation in this function for better precision?

share|improve this question
    
What is the goal you're trying to achieve by writing these routines? –  Hurkyl Dec 6 '12 at 9:48
    
It's been used in Rhumb geo distance calculation. –  Pablo Dec 6 '12 at 10:00

1 Answer 1

up vote 1 down vote accepted

$$\log(m \cdot 2^e) = \log m + e \log 2$$

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.