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-2

Exercise 1.2.11.1-2

not stated yet in Lean solution written

RatingM10
MarkersM (mathematical)
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.11.1 of Volume 1. Companion chapter: The O-notation

The task

Find the error in the rule O(f(n))−O(f(n))=0O(f(n))-O(f(n))=0 and give the correct right side.

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

Each OO stands for some unknown quantity. Can the two unknowns differ?

Hint 2

Use (6) and (7).

Solution

Show the solution

The two symbols O(f(n))O(f(n)) denote two possibly different sequences, each bounded by a constant multiple of ∣f(n)∣|f(n)|. A difference of two different sequences is not 00. For example xn=f(n)x_n=f(n) and xn′=−f(n)x'_n=-f(n) are both O(f(n))O(f(n)), and xn−xn′=2f(n)x_n-x'_n=2f(n).

The correct statement is O(f(n))−O(f(n))=O(f(n))O(f(n))-O(f(n))=O(f(n)). Proof: let ∣xn∣≤M∣f(n)∣|x_n|\le M|f(n)| for n≥n0n\ge n_0 and ∣xn′∣≤M′∣f(n)∣|x'_n|\le M'|f(n)| for n≥n0′n\ge n_0'. For n≥max⁡(n0,n0′)n\ge\max(n_0,n_0'), ∣xn−xn′∣≤∣xn∣+∣xn′∣≤(M+M′)∣f(n)∣|x_n-x'_n|\le|x_n|+|x'_n|\le(M+M')|f(n)|.

The right side cannot be improved to o(f(n))o(f(n)) or to 00, because of the example above.

Check

For f(n)=nf(n)=n, xn=nx_n=n and xn′=−nx'_n=-n give xn−xn′=2n≤2⋅∣n∣x_n-x'_n=2n\le2\cdot|n|, so the constant M+M′=2M+M'=2 is reached.

Remarks

Equation (7) is the same rule for a sum. The sign does not matter, because OO is a bound on the absolute value.

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.