Quote:
Originally Posted by Victor
well, if you have the opportunity to research then fine, but I doubt many ppl know the equation to calculate a logarithm off hand.
If you went to college and got a CS degree and don't know what a logarithm is, you either cheated on every course from CS 101 and Calculus on up, or your school is running a massive education scam and the entire staff should be sent to prison. Log2 is so fundamental to CS that the study couldn't exist without it.
The research is literally clicking the first random search result:
given a^x = b, solve for x. This is translated to log_a (b) = x.
For example, log2(8) = x translates to 2^x = 8, which means x = 3.
Even if you know nothing about logarithms, you can deduce a few facts. To keep it simple, we'll assume the base is a positive integer greater than 1.
-- x = 0 if and only if b = 1.
This follows from n^0 = 1
-- if b = a; x = 1
2^1 = 2. This is an inflection point.
-- if b is a fraction, x must be negative.
This follows from 2^-1 = 1/2.
Using this inflection point, we can deduce:
-- if b = a; x = 1
-- if b > a; x > 1
-- if b < a; x < 1
we now have some lower bounds, but before continuing, we can see a relationship here:
-- if x^1 = 1/x, then it stands to reason that, if b < 1, we can compute the reciprocal of b and change x to negative.
if log2(32) = 5, then log(1/32) = -5.
now for an upper bound. We know that x can't be greater than b if b > 1. In fact, the upper bound is going to be smaller than b, perhaps much smaller, but let's just assume we can go up to one infinitesimal pip below b.
With the above facts in place, creating a log calculator isn't that difficult. In fact, we already divided the space with the reciprocal statement, but we can divide the space to smaller segments by using the bisection method, fixed point methods, Newton's method, etc. (I'd probably look for a Taylor series, but at a white board, I'd just go along with the bisection method).
Kind of ironic, because the bisection method is logarithmic, so we end up using log to solve log.