1. Solve a recurrence
Let T(n) be defined by the recurrence
- T(0) = 1.
- T(1) = 0.
- T(2) = 7.
- For n≥3, T(n) = 6 T(n-3) + 7 T(n-2).
Give a closed-form expression for T(n).
1.1. Solution
Multiplying each equation by zn and summing over all n gives the generating function equation
Solving for F gives
The cover-up method gives A = 1/((1-2)(1+3)) = -1/4, B = 1/((1-1/2)(1+3/2)) = 4/5, and C = 1/((1+1/3)(1+2/3)) = 9/20. So we have
From this we can immediately read off the solution
The first few values of this function are given in the table below. It is not hard to check that these satisfy the recurrence.
n |
T(n) |
0 |
1 |
1 |
0 |
2 |
7 |
3 |
6 |
4 |
49 |
5 |
84 |
6 |
379 |
2. Triplets
Suppose you have a collection of objects of varying weights, and there are exactly ways to make a sequence of three of these objects with total weight n. How many objects are there with weight n?
2.1. Solution
Let an be the number of objects in S with weight n, and let F = ∑ anzn be the generating function for these quantities. Then we have
One solution to this equation is F = (1-z)-2, which generates the sequence an = n+1. (The other solutions generate complex numbers for an—we don't want these.) So there are n+1 objects of weight n.
Check: Call the objects 0, 1a, 1b, 2a, 2b, 2c, etc. Then we get triplet 000 of weight 0, triplets of weight 2. The last are a pain to enumerate completely, but we can observe that there are 3*3=9 ways to build a triplet out of two 0's and a 2 (3 choices of where to put the 2 and 3 choices of 2's), plus another 3*2*2 ways to build a triplet out of one 0 and two 1's (3 choices of where to put the zero plus 2 choices each of the 1 labels). So this gives a total of 21.
3. Birthdays
Suppose that P and Q each have birthdays that are equally likely to be any of the 365 days of the year,1 and that the two birthdays are independent. What is the probability that both birthdays occur on the same day of the week in a non-leap year?
3.1. Solution
We can think of P and Q's birthdays as independent integer-valued random variables drawn uniformly from the range 1..365. We can determine the weekday of each birthday by computing P mod 7 and Q mod 7; the question then asks how likely it is that P mod 7 = Q mod 7. Note that this will not be exactly 1/7 because there is a slight variation in the number of values that produce each remainder.
Recalling that a year has approximately 52 weeks, we note that the first 52*7 = 364 days of the year produces exactly 52 of each weekday. The last day of the year gives one extra copy of some weekday. So
This is an example of an answer where the second-to-last step may be more informative that the last one. Further calculation shows that the probability is greater than 1/7, but not by much.
We are conditioning on the event that neither of them is born on February 29th. (1)