[Math] How to normalize a value in both linear and log scales

algebra-precalculuslogarithmslogic

I have two scales (linear and log) on a chart which can be interchangeable on both the X and Y axes. When both axes are in the linear scale, I take the maximum value of the data and the minimum value of the data to compute the data width. To minimize the confusion, lets say width for X axis and height for Y axis.
Now, I have a width "w" and height "h". I wrote an algorithm for Zoom on chart which keeps halving the width by 2 for every click of the zoom button. But instead of letting it zoom forever, I came up with a logic to restrict the zoom at 10th level i.e, 10th click. The logic is pretty straight forward, just take the default width and divide it by 2^10 and we get the width at the 10th level, lets say it's delta.

 δ = w/2^10

So, whenever the button is clicked, I check if the current width is greater than the delta, and if it is, then I will let the zoom happen and at the 10th zoom level, the current width becomes equal to the delta where the logic stops and the button gets disabled.

This logic works perfectly even for very large datasets (like in millions) in Linear Scale.
But, coming to the Log scale, this logic fails terribly.
I am currently using the following logic for log scale:

δ = Log10(width)/2^10.

And I also tried Log on both numerator and denominator.

With the above logic, sometimes by luck, I am able to disable zoom at 10th level as it hits the delta but most of the times, the delta value is reached at 8th zoom level itself or 3rd zoom level (with very large data). I have been breaking my head to come up with a logic where the calculation of minimum width(delta) would work correctly for all types of data and lets me disable it at the 10th level. How can I normalize this to work correctly in logarithmic scale?

Could anybody help me out with it. How can improve my logic, what kind of a stupid mistake am I doing here. Any help and direction would be hugely appreciated.

Thank you.

Best Answer

Seems that you want to take the logarithm of the equation $$\delta=\frac{w}{2^{10}}$$ In this case, you have to use $$\log_{10}({\delta})=\log_{10}(w)-10\cdot \log_{10}(2)$$