# Zooming formula

I am sorry if this is a noob question, I need help with relatively simple math problem and assurance that I understand the problem correctly.

I have a map-like program that zooms in and zooms out if you press the + and - icons (much like google map). Every time you zoom the map size doubles or halves. I know the minimum and maximum size of the map, how do I calculate the number of the doubling steps?

I was thinking of this:

A on power of 2*x equals B, where A is the minimal zoom, B is the maximal zoom a x is the number of steps between them. Am I right?

How do I calculate x form that formula?

Many thanks

-
I see you have tagged logarithms - have you tried what happens when you take the logarithm of your formula? – Mark Bennet Jul 3 '11 at 19:55
@daniel.sedlacek: You are certainly right that if $x$ is the number of steps then $(2^x)A=B$. – André Nicolas Jul 3 '11 at 20:17

If I understand the question right, after the step $1$ you doubled $A$; after the step $2$, you have $2^{2}A$; after step $x$ you have $$2^{x}A=B.$$ Applying logarithms we get

$$\ln \left( 2^{x}A\right) =\ln B\Leftrightarrow \ln \left( 2^{x}\right) +\ln A=\ln B$$

$$\Leftrightarrow x\ln 2+\ln A=\ln B\Leftrightarrow x=\frac{\ln B-\ln A}{\ln 2}$$

If $x\notin \mathbb{Z}$, then you have to take

$$\left\lceil x\right\rceil =\left\lceil \frac{\ln B-\ln A}{\ln 2}% \right\rceil$$

or

$$\left\lfloor x\right\rfloor =\left\lfloor \frac{\ln B-\ln A}{\ln 2}\right\rfloor .$$

i.e. $n$ steps

$$\left\lfloor \frac{\ln B-\ln A}{\ln 2}\right\rfloor \leq n\leq \left\lceil \frac{\ln B-\ln A}{\ln 2}\right\rceil$$

-
I think that's exactly it. Many thanks. – daniel.sedlacek Jul 3 '11 at 22:26
You are welcome! – Américo Tavares Jul 3 '11 at 22:44
Does this formula have a name? I am trying it with my application, but it doesn't like that formula. – John Riselvato Apr 16 '12 at 17:30
@JohnRiselvato: I don't know if it has a name in this context. – Américo Tavares Apr 16 '12 at 17:37
For solving for a step, what can i look into? – John Riselvato Apr 16 '12 at 17:44