Roronoa Zoro
Roronoa Zoro

Reputation: 1013

Is log(n^2)'s asymptotic order larger than or equals to log(5n)

To compare the asymptotic order of the two functions, I calculated the limit of first function over second function, when n goes to infinity.

The answer was 2 (I had to use l'hopital's rule), which means that for really high values of n, log(n^2) is larger than log(5n)

My question is: is it incorrect to say that log(n^2) is asymptotically larger than log(5n)?

My friend told me that when the limit of first function over the second function is a constant, that means that their asymptotic order is equal. Can someone confirm?

Upvotes: 2

Views: 2627

Answers (4)

Saeed Amiri
Saeed Amiri

Reputation: 22565

Actually log (5n) = log 5 + log n, and log (n^2) = 2 log n, so log(n^2) is larger than log 5n. In addition, we can say that log(n^2) is asymptotically larger than log 5n. One definition of Asymptotic is as follows.

The term asymptotic means approaching a value or curve arbitrarily closely (i.e., as some sort of limit is taken). A line or curve A that is asymptotic to given curve C is called the asymptote of C.

Depending on the context we may ignore constant factors, and write they are in the same order. We may express this by existing notations such as O, Θ and Ω. According to the widely accepted definition from the algorithmic standpoint, these two particular functions are asymptotically equivalent:

We say A(n) is asymptotically larger than B(n) if

lim n→∞A(n)/B(n) = ∞

In this case, the above limit converges to 2 (or reverse version 1/2) so they are asymptotically equal.

Upvotes: 9

sch
sch

Reputation: 27536

log(n^2) = 2 * log(n) and log(5n) = log(5) + log(n). So both are asymptotically equal when speaking about algorithms.

Upvotes: 4

tchap
tchap

Reputation: 1057

If the limit was 2, then it means that log(5n) belongs to O(log(n^2)), doesn't it...

Upvotes: 0

mbatchkarov
mbatchkarov

Reputation: 16099

log(n^2)=2*log(n)

Assuming log base 2

Upvotes: 0

Related Questions