Richard Heathfield wrote:
> Dik T. Winter said:
>> rjh@see.sig.invalid writes:
>>
>>> It may the OP to recognise that the question, as asked (i.e.
>>> in the absence of big-O notation, which IMHO would in any case
>>> make the question meaningless), is looking for the integer value
>>> of n that is just higher than the real value that is the solution
>>> to the following equation:
>>>
>>> 2 to the power n = 100 * n * n
>>>
>>> This is a simple mathematical exercise.
>>
>> Finding the real value is not exactly a simple mathematical
>> exercise.
>
> It isn't? Using a simple iterative technique, I found the answer
> in nothing flat (actually about 3 milliseconds), getting agreement
> in 2^n and 100n^2 to ten decimal places. Given that we only *need*
> it to one decimal place, I'd have thought that was an adequate
> solution.
Taking log2() function of both sides, we have:
n = log2(100) + 2 * log2(n)
which makes it fairly easy to divide integers into two classes,
i.e. those where "n < log2(100) + 2*log2(n)" and those where "n >
log2(100) + 2*log2(n)". Note that the equality condition cannot
occur since 2 does not contain all the factors of 100. We can go
close to exactness by considering 100 as 2*2*5*5, so that log2(100)
= 2 + 2* log2(5), and that result is obviously greater than 6 and
less than 7.
All this should be obvious to any child of 10 who has passed the
kindergarten class on logarithms.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from
http://www.teranews.com