3
$\begingroup$

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

  • 0
    @daniel.sedlacek: You are certainly right that if $x$ is the number of steps then $(2^x)A=B$.2011-07-03

1 Answers 1

2

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 $

  • 0
    Given $A$ and $B$ you compute $x=\frac{\ln B-\ln A}{\ln 2}$, and choose the integer $n$ equal to $n=\left\lfloor \frac{\ln B-\ln A}{\ln 2}\right\rfloor$ or $n=\left\lceil \frac{\ln B-\ln A}{\ln 2}\right\rceil $2012-04-16