Search code examples
mathlinear-algebraalgebralogarithmnatural-logarithm

Linear Scale vs. Log Scale


This may be a very simple question, but I haven't been in touch with Algorithms since a while.

I have a logarithmic scale of 20,100,500,2500,12500 which relates to 1,2,3,4,5 on the respectively. Now, I want to find out as to where the value 225 would lie on the scale above? And also, going the other way round, how would I find out as to what the value for 2.3 interpret to on the scale. Would be great if someone can help me with the answer and explanation for this.


Solution

  • Note that each step in the scale multiplies the previous step by 5.

    So the explicit formula for your output is

    y = 4 * 5^x
    

    or

    x = log-base-5(y/4)
    

    where

    log-base-5(n) = log(n)/log(5)
    

    if you want to compute it in code. That last line is called the change of base formula, and is explained here You can use either a natural log or common log on the right side of the formula, it doesn't matter.