Exponentiation and Logarithms Jesper Larsson, IT University of Copenhagen Important basic knowledge required for the course Foundations of Computing – Algorithms and Data Structures.
Exponentiation Exponentiation is written x n , where x is called the base and n is the exponent. It is a shorthand for repeated multiplication: x n = |x · x · x · {z · · · n times
· x}
Clearly,
Verify that you are able to deduce these equations yourself!
x n · x m = x n+m and
xn = x n−m xm It is convenient to generalize to non-positive exponents, and define x0 = 1 for any x 6= 0, and x −n = 1/x n , which makes sense for the equations above. (Why?) Then, we can generalize exponentiation to fractions. We should have x1/2 · x1/2 = x1/2+1/2 = x, which is fulfilled if and only if we √ √ define x1/2 = x. By the same argument, x1/3 = 3 x.
Logarithm Applying a logarithm is the opposite of exponentiation. The base b logarithm of the number x is the number n such that bn = x: logb x = n
⇐⇒
bn = x
Memorize!
In other words: blogb x = x Another, perhaps more intuitive, way to think of logb x is “the number of times you can divide x by b before you get down to 1.” In algorithm analysis, we are usually concerned with the base two logarithm, also called binary logarithm. We use this special notation for the binary logarithm: lg x = log2 x When x = 2n for some integer n (in other words, x is a power of two), lg x is an integer. But the logarithm is well-defined for any √ positive number. For instance, lg 2 = 1/2, by the generalization above. The exact definition of the logarithm of any positive number is beyond our scope. But we can get an idea of the approximate value of, for example, lg 10, if we note that if a < b < c, for positive a, b, and c, then we should also have lg a < lg b < lg c (why?). Therefore,
Deduce and memorize!
exponentiation and logarithms
since 23 < 10 < 24 , we can conclude that lg 10 is some number between 3 and 4. Usually, that is all we need to know, and we can use the following notation for rounding numbers up or down:
bxc
the floor of x: the smallest integer ≥ x
dxe
the ceiling of x: the largest integer ≤ x
So we have, for instance:
blg 10c = 3 dlg 10e = 4 The following important equations follow from the definition of logarithms: lg x + lg y lg x
y
= lg( xy) = y lg x
You should be able to deduce these rules, or at least prove that they are correct, using the definitions and equations above. Then memorize the rules, so that you don’t have to deduce them every time you have to use them. The rules are stated here for the base two logarithm, which is likely to be the only case you need, but they hold for any base logarithm. We deduce one final important fact: since x = aloga x , logb x = logb aloga x = (loga x )(logb a) In other words, loga x and logb x differ only by a constant factor (1/logb a), independent of x. In algorithm analysis, we often disregard constant factors, and then it is insignificant which base logarithm we are talking about, as long as it’s a constant. “Order of growth loga x” is the same as “order of growth logb x”, so we can simply say “order of growth log x”.
Deduce and memorize!
2