10

What would be the time complexity for Babylonian Method? is it log(n) where n is the number we want to find the squared root for? If so, why is this so?

4

2 回答 2

14

Looking at the wikipedia section for the Babylonian method we can see that the relative error at step k, ek, satisfies the equation ek < 2-f(k), where f(k) is defined recursively as follows:

f(1) = 2 and f(k+1) = 2 * f(k) + 1 for n > 1

By induction, f(k) = 3 * 2k-1 - 1

Let n be the input to our algorithm, which stops when we are sure that the total error is less than a constant m

The error at step k, Ek, satisfies the equation Ek = ek * n

Therefore the algorithm will terminate once ek * n < m

This will occur when 2f(k) > n/m which is equivalent to f(k) > log2(n/m)

That equation is true when 2k-1 > (log2(n/m) - 1)/3 which is true when k > log2((log2(n/m) - 1)/3)+ 1

Therefore the algorithm will terminate in O(log(log(n/m)+1)) steps.

Using this logarithmic summation formula you can show that log(log(x)+c)) = O(log(log(x)).

Therefore the Babylonian method takes O(log(log(n/m)) steps

于 2013-08-23T14:27:57.357 回答
0

I guess steps would be O(log2(log to the base E0 (m/n)) where E0 is the error at zeroth iteration i.e when we choose seed value m is error allowed in the ans and n is the input to the algorithm. You can refer to this for complete explanation for recursive function of error :http://www.math.harvard.edu/library/sternberg/slides/lec1.pdf

于 2016-04-03T13:26:57.810 回答