1

This is a homework problem and I'm not sure if I am doing it correctly.

Show that $\log(n^2+1)\in \Theta(\log n)$.

I got:

$$ \log (n^2) \leq \log(n^2+1) \leq \log (n^2+n^2) $$ $$ 2\log n \leq \log(n^2+1) \leq \log(2\cdot n^2) $$ $$ 2\log n \leq \log (n^2+1) \leq \log 2 + \log(n^2)$$ $$ 2\log n \leq \log(n^2+1) \leq 1 + 2\cdot\log n$$

I'm not sure if I have proved it according to the definition that a function $f(x)$ is in $Θ(g(x))$ if there exist positive constants $a,b$, and $n_0$ such that $a\cdot g(x) ≤ f(x) ≤ b\cdot g(x)$ for all $n > n_0$.

I feel like I did something wrong here.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
Zach
  • 11
  • 1

2 Answers2

4

In order to prove that $\log(n^2+1) \in \Theta(\log n)$ according to your definition, you have to produce $a,b,n_0$ such that $a \log n \leq \log(n^2+1) \leq b\log n$ for all $n \geq n_0$. This is not what you did. What you have shown is some other inequality.

To help you in future such questions, here is a complete proof. We choose $a = 2$, $b = 3$, and $n_0 = 2$. So we have to show that for $n \geq 2$, $$ 2\log n \leq \log(n^2+1) \leq 3\log n. $$

The first inequality follows from $$ \log(n^2+1) \geq \log(n^2) = 2\log n. $$ You did that part correctly.

The second inequality follows from $$ \log(n^2+1) \leq \log(n^2+n^2) = \log(2n^2) \leq \log(n^3) = 3\log n. $$ This is the part you did incorrectly.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
0

Remember that Θ doesn't care about constant factors, and $log (x^k) = k·log (x)$, so replacing $x$ with $x^k$ doesn't change Θ. Θ also only cares about large n.

If n ≥ 2 then $n^2 + 1 ≤ n^3$, so $log (n^2 + 1) ≤ log (n^3) ≤ 3 log (n)$, therefore $log (n^2 + 1) = Θ (3 log n)$.

gnasher729
  • 29,996
  • 34
  • 54