[Math] take $\log$ on both sides of inequality such way

algorithmslogarithms

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

Best Answer

You can take the logarithm on both sides of the inequality, if you know the numbers are positive. This produces $\log(f(n))\le \log(cn^k)$.

However $\log(cn^k)$ is not the same thing as $kc\log n$, so your second inequality doesn't follow. What you do have is $\log(cn^k) = \log(c) + k\log(n)$, so you can get $$ \log(f(n)) \le \log(c) + k\log(n)$$