You are on page 1of 5

1 A Master Theorem for Recurrences

Akra and Bazzi [AB98] recently gave a closed form solution for a large class of recurrences.

Theorem 1 Let (
h(x) for 1 ≤ x ≤ x0
f (x) = x (1)
a f ( b ) + g(x) for x > x0
where

1. a > 0, b > 1, and x0 ≥ b are constants,

2. x ≥ 1 is a real number,

3. d1 ≤ h(x) ≤ d2 for some positive constants d1 and d2 and all x with 1 ≤ x ≤ x0 , and

4. g is a nonnegative function satisfying the polynomial growth condition, i.e., there are pos-
itive constants c1 and c2 such that

c1 g(x) ≤ g(u) ≤ c2 g(x) for all x > x0 and u ∈ [x/b, x] .

5. (technical condition) Z x0
g(u)
I := du < ∞
1 u p+1
Let p be the unique real number for which a/b p = 1. Then
  Z x 
g(u)
f (x) = Θ x 1 +
p
p+1
du .
1 u

Before we enter the proof, we give some examples.

• If f (x) = 2 f (x/2) + x, then p = 1 and


x
 
u
Z
f (x) = Θ x(1 + du) = Θ(x log x) .
1 u2

• If f (x) = 3 f (x/2) + x2 , then p = log 3 and

u2
 Z x 
f (x) = Θ x (1 +
log 3
1+log 3
du) = Θ(xlog 3 (1 + x2−log 3 )) = Θ(x2 ) .
1 u

• If f (x) = f (x/2) + log x, then p = 0 and


 Z x 
log u
f (x) = Θ x (1 +
0
1
du) = Θ(1 + log2 x) = Θ(log2 x) .
1 u

1
Proof: For any x > x0 , we have x/b < x and x/b > x0 /b ≥ 1. Thus f (x) is well-defined. We
need to prove
 Z x   Z x 
p g(u) p g(u)
C·x 1+ p+1
du ≤ f (x) ≤ D · x 1 + p+1
du (2)
1 u 1 u

for positive constants C and D. We prove the upper bound and leave the lower bound to exer-
cise 1. The proof of the upper bound is by induction on the index of x, the smallest integer k such
that x/bk ≤ x0 .
Assume first that 1 ≤ x ≤ x0 . Then
 
p 1 + x g(u) du
R
x p x 1 u p+1
f (x) = h(x) ≤ d2 ≤ d2 p ≤ d2 p ,
min(1, x0 ) min(1, x0 )

since x p assumes its minimum in [1, x0 ] at either x = 1 (if p ≥ 0) or x = x0 (if p < 0) and since
the value of the integral is nonnegative. Thus the upper bound in equation (2) holds for any D
for which D ≥ d2 / min(1, x0p ).
Assume next that x > x0 . The index of x/b is one smaller than the index of x and hence we
may use the upper bound in equation (2) for x/b. We obtain:
x
f (x) = a f ( ) + g(x) definition of f
b
 x p  Z x/b 
g(u)
≤ a·D· 1+ du + g(x) induction hypothesis
b 1 u p+1
 Z x/b 
p g(u)
= D·x 1+ du + g(x) since a/b p = 1
1 u p+1
 Z x 
p g(u)
≤ D·x 1+ p+1
du
1 u

provided we can establish the inequality


Z x
g(u)
g(x) ≤ D · x p du .
x/b u p+1

The inequality is a simple consequence of the polynomial-growth assumption. Observe that


g(u) ≥ c1 g(x) for x/b ≤ u ≤ x and u p+1 ≤ max((x/b) p+1 , x p+1 ) and hence
Z x
p g(u) c1 g(x)
D·x du ≥ D · x p (x − x/b)
x/b u p+1 max((x/b) p+1, x p+1 )
c1 (1 − 1/b)
= D· g(x)
max((1/b) p+1, 1)
≥ g(x)

provided that D ≥ max((1/b) p+1, 1)/(c1(1 − 1/b)). This completes the induction step.

2
p
We satisfy both constraints on D by setting D = max(d2 , d2 /x0 , b/(c1 (b − 1)), 1/(c1(b −
1)b p)).
Rx
How does the value I := x p 1 g(u)/u p+1 du depend on the relation of g and p? Inspection of
a table of integrals1 yields:
 1 x
= Θ(1) ε >0
Rx 1
1 u1+ε du = − ε uε i1
R x lnk u h k+1 x
1 u du = ln u
k+1 = Θ(lnk+1 x) k≥0
1
ix 
R x uδ lnk h
1 u du = Θ uδ lnk u = Θ(xδ lnk x) δ > 0 and k ≥ 0
1

Thus

• f (x) = Θ(x p ), if g(x) = O(x p−ε ) for some ε > 0,

• f (x) = Θ(g(x) logk+1 x) if g(x) = Θ(x p logk ) for some k ≥ 0, and

• f (x) = Θ(g(x)) if g(x) = Θ(x p+δ logk ) for some δ > 0 and k ≥ 0.
R x/bi−1
It is instructive to inspect the value I∆ := x p x/bi
g(u)/u p+1 du. For g(x) = x p , we have

Z x/bi−1 Z x/bi−1
g(u) 1 x/bi−1
I∆ = x p du = x p du = x p [ln u]x/bi = x p ln b ,
x/bi u p+1 x/bi u

i.e., all levels of the recursion contribute essentially the same amount to f (x). If g(x) = ω (x p ),
the outermost level (i = 0) contributes most, and if g(x) = o(x p ), the bottommost level (i = logb x)
contributes most.

Exercise 1 Prove the lower bound of Theorem 1.

Let us see a second proof. We first express f (x) as a sum.

Lemma 1 Let k be the minimal integer with x/bk ≤ x0 . Then

f (x) = ak f (x/bk ) + ∑ ai g(x/bi ) = ak h(x/bk ) + ∑ ai g(x/bi ) .


0≤i<k 0≤i≤k

Proof: Either by repeated substitution or by induction on k.

Let us next study the two terms in the expression for f (x). Since 1 ≤ x/bk ≤ x0 , we have
d1 ≤ h(x/bk ) ≤ d2 and hence

ak h(x/bk ) = Θ(ak ) = Θ(x p )


1 See for example, the Wikipedia entry on lists of integrals.

3
where the last equality can be established by taking logarithms on both sides and observing that
k log a = (log x)/(log b) log a and p log x = (log a)/(log b) log x.
We turn to the sum S := ∑0≤i<k ai g(x/bi ) Define x∗ as x/bk . Then x/bi = x∗ bk−i and hence

g(x∗ bk−i ) g(x∗ b j ) g(x∗ b j )


S = ak ∑ ak−i = x p
∑ aj = x p
∑ (b p) j ==: x p S′
0≤i<k 1≤ j≤k 1≤ j≤k

where the second equality uses the substitution j = k − i and the third equality uses a = b p . Since
sums are harder to evaluate than integrals, we want to turn the sum into a integral. Consider a
single term g(x∗ b j )/(b j ) p . We want it to be the value of an integral from x∗ b j−1 to x∗ b j . The
length of this integral is x∗ (b j − b j−1 ) = x∗ b j (1 − 1/b). Thus
Z x∗ b j Z x∗ b j
g(x∗ b j ) (x∗ ) p g(x∗ b j ) ∗ p b g(x∗ b j ) ∗ p b g(x∗ b j )
= = (x ) du = (x ) du .
(b j ) p (x∗ b j ) p b−1 x∗ b j−1 (x∗ b j ) p · (x∗ b j ) b−1 x∗ b j−1 (x∗ b j ) p+1
With
g(x∗ b j )
Z x
∗ j−1 ∗ j b′ ∗ p
h(u) := ∗ j p+1 for x b < u ≤ x b , we have S = (x ) h(u) du .
(x b ) b−1 x∗

For x∗ b j−1 < u ≤ x∗ b j , we have


h(u) g(x∗ b j ) (x∗ b j ) p+1
= · = Θ(1) · Θ(1) = Θ(1) .
g(u)/u p+1 g(u) u p+1
For the first fraction, this follows from the polynomial growth property of g, and for the second
fraction, this follows from the polynomial growth property of x1+p . Thus
Z x Z x 
∗ p b g(u)

S = (x ) h(u) du = Θ p+1
du .
b − 1 x∗ x∗ u

and we completed the alternative proof of the AB-theorem. We should remark that the alternative
proof does not generalize.

We come to extensions. In Theorem 1, f (x) is defined as a times the value of f at x/b. More
generally, we can define f (x) as a linear combination of smaller values.
(
h(x) for 1 ≤ x ≤ x0
f (x) = (3)
∑i=1 ai f ( bi ) + g(x) for x > x0
k x

where k is an integer constant and ai > 0 and bi > 1 are real constants. In order to make f well
defined, we require x0 ≥ maxi bi . Then 1 ≤ x/bi < x for all x ≥ x0 and all i. We define p as the
unique real number for which ∑i ai (1/bi ) p = 1.

Theorem 2 (Akra-Bazzi) Under the assumptions stated above,


  Z x 
g(u)
f (x) = Θ x 1 +
p
p+1
du .
1 u

4
Proof: The proof is analogous to the proof of Theorem 1 and delegated to the exercises. It
again uses induction on the index of x, the smallest integer k such that x/(mini bi )k ≤ x0 .

Exercise 2 Prove Theorem 2

Although Theorem 2 handles a broad class of recurrences, it does not cover a common form
of recurrence arising in the analysis of algorithms. For example, in the recurrence for the running
time of Karatsuba’s algorithm, we reduced TK (n) to TK (⌈n/2⌉ + 1). The following extension of
Theorem 2 deals with these variations. Consider
(
h(x) for 1 ≤ x ≤ x0
f (x) = (4)
∑ki=1 ai f ( bxi + hi (x)) + g(x) for x > x0

where k is an integer constant and ai > 0 and bi > 1 are real constants. The hi are functions with
|hi (x)| ≤ x/(log1+ε x) for some ε > 0 and all x > x0 . In order to make f well defined, we require
1 ≤ x/bi + hi (x) < x/b for all i and x > x0 and some b > 1. As before, we define p as the unique
real number for which ∑i ai (1/bi ) p = 1.

Theorem 3 (Leighton) Under the assumptions stated above and some more technical condi-
tions on x0 (see [Lei])   Z x 
g(u)
f (x) = Θ x 1 +
p
p+1
du .
1 u

Proof: See [Lei]

For the Karatsuba recurrence we would use k = 3, ai = 1, bi = 2 and hi (x) = ⌈x/2⌉ + 1 − x/2
for 1 ≤ i ≤ k.

References
[AB98] M. Akra and L. Bazzi. On the solution of linear recurrence equations. Computational
Optimization and Applications, 10(2):195–210, 1998.

[Lei] T. Leighton. Notes on better master theorems for divide and conquer recur-
rences. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.
1.1.39.1636.

You might also like