TITLE: Can I take $\log$ on both sides of inequality such way?
QUESTION [8 upvotes]: Can I take $\log$ on both sides of the following inequality
$$f(n) \leq cn^k$$ and get
$$\log (f(n)) \leq kc\log n$$ 
I know that by rules the result inequality should be like this
$$\log(f(n)) \leq \log(cn^k)$$
but I read in book where inequality (1) $\to$ in inequality (2) and want to know which way it was done
Edit: this is not general case, the questions relates to the algorithms and O-notation

REPLY [7 votes]: yes you can since $log$ is an increasing function and hence preserves the inequality. the main condition is that both sides lies in the domain of $log$ i.e. they are positive
$$\log(f(n)) \leq \log [cn^k]=\log c+\log n^k=\log c+k\log n
$$
If $c >1$ then $\log c>0$ and so
$$\log(f(n)) \leq k\log n\leq kc\log n
$$