Big O notation sum rule

Given $T_1(n)=O(f(n))$ and $T_2(n)=O(g(n))$, we are to prove $$T_1(n)+T_2(n)=O(\max(f(n),g(n))\tag0$$

  • Write down exactly what the first assumption says: there exists a constant $C_1$ and an index $N_1$ such that $$|T_1(n)| \le C_1f(n)\quad \text{when } n\ge N_1 \tag1$$

  • Write down exactly what the second assumption says: there exists a constant $C_2$ and an index $N_2$ such that $$|T_2(n)| \le C_2g(n)\quad \text{when } n\ge N_2 \tag2$$

  • Prepare to combine (1) and (2) by introducing $N=\max(N_1,N_2)$ and $C=\max(C_1,C_2)$.

  • Add (1) and (2): $$ |T_1(n)|+|T_2(n)|\le C_1f(n)+C_2g(n) \le C(f(n)+g(n))\quad \text{when } n\ge N \tag3 $$

  • Check that for any two real numbers $a,b$ we have $$a+b\le 2\max(a,b)\tag4$$

  • Use (4) in (3) to obtain $$ |T_1(n)|+|T_2(n)|\le 2C\max(f(n),g(n))\quad \text{when } n\ge N \tag5 $$

  • Conclude that (0) holds.