taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.11.1-5

Exercise 1.2.11.1-5

not stated yet in Lean solution written

RatingM20
MarkersM (mathematical)
KindK2, decide: say whether a claim holds from the written solution
SectionSection 1.2.11.1 of Volume 1. Companion chapter: The O-notation

The task

Decide whether O(f(n)+g(n))=f(n)+O(g(n))O(f(n)+g(n))=f(n)+O(g(n)) holds for positive ff and gg.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Test with ff much larger than gg.

Solution

Show the solution

The statement is false. Take f(n)=n2f(n)=n^2 and g(n)=1g(n)=1. The sequence xn=nx_n=n is O(n2+1)O(n^2+1), since n≤n2+1n\le n^2+1. If it were in n2+O(1)n^2+O(1), then ∣n−n2∣≤M|n-n^2|\le M for large nn. But n2−n→∞n^2-n\to\infty. So xn=nx_n=n lies in the left side and not in the right side.

The inclusion in the other direction does hold: if ∣yn∣≤Mg(n)|y_n|\le M g(n) then ∣f(n)+yn∣≤f(n)+Mg(n)≤max⁡(1,M)(f(n)+g(n))|f(n)+y_n|\le f(n)+Mg(n)\le\max(1,M)(f(n)+g(n)).

Check

For n=10n=10: x10=10≤101=f+gx_{10}=10\le101=f+g. The distance from f=100f=100 is 9090, while g=1g=1.

Remarks

The correct general rule is f(n)+O(g(n))⊆O(f(n)+g(n))f(n)+O(g(n))\subseteq O(f(n)+g(n)). Equality needs, for example, that ff is bounded by a multiple of gg.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.