09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7.3 SOLVING RECURRENCES 329<br />

And with chutzpah and luck we might even have been able to smoke out<br />

the constant $. But it sure is simpler and more reliable to have generating<br />

functions as a tool.<br />

Example 3: Mutually recursive sequences.<br />

Sometimes we have two or more recurrences that depend on each other.<br />

Then we can <strong>for</strong>m generating functions <strong>for</strong> both of them, and solve both by<br />

a simple extension of our four-step method.<br />

For example, let’s return to the problem of 3 x n domino tilings that we<br />

explored earlier this’ chapter. If we want to know only the total number of<br />

ways, Ll,, to cover a 3 x n rectangle with dominoes, without breaking this<br />

number down into vertical dominoes versus horizontal dominoes, we needn’t<br />

go into as much detail as we did be<strong>for</strong>e. We can merely set up the recurrences<br />

uo = 1 , Ul =o; vo = 0, v, =l;<br />

u, =2v,-, fl.lnp2, vn = LLl + vn4 ) <strong>for</strong> n 3 2.<br />

Here V, is the number of ways to cover a 3 x n rectangle-minus-corner, using<br />

(3n - 1)/2 dominoes. These recurrences are easy to discover, if we consider<br />

the possible domino configurations at the rectangle’s left edge, as be<strong>for</strong>e. Here<br />

are the values of U, and V,, <strong>for</strong> small n:<br />

nlO1234 5 6 7<br />

\ ,r<br />

i \ (7.34)<br />

Let’s find closed <strong>for</strong>ms, in four steps. First (Step l), we have<br />

U, = 2V,-1 + U-2 + [n=Ol , vll = b-1 +v,-2,<br />

<strong>for</strong> all n. Hence (Step 2),<br />

U(z) = ZzV(zj + z%l(z)+l , V(z) = d(z) + z2V(z)<br />

Now (Step 3) we must solve two equations in two unknowns; but these are<br />

easy, since the second equation yields V(z) = zU(z)/(l - 2’); we find<br />

l-22<br />

z<br />

U(z) = --. V(z] =<br />

l-422 +24' 1 - 422 + 24<br />

(We had this <strong>for</strong>mula <strong>for</strong> U(z) in (7.10), but with z3 instead of z2. In that<br />

derivation, n was the number of dominoes; now it’s the width of the rectangle.)<br />

The denominator 1 - 4z2 + z4 is a function of z2; this is what makes<br />

UI~+J = 0 and V2, = 0, as they should be. We can take advantage of this

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!