5.1 #2,13,16,20,28,38
5.2 #3,7,11,25,28

5.1 #2. This is linear homogeneous. So once we check that 1 works (1 = -3+4) and that (-4)^n works ((-4)^n = -3*(-4)^(n-1) + 4*(-4)^(n-2), since (-4)^2 = -3*-4 + 4) then we know that every linear combination works.

5.1 #16. Call the answer S_n.

There are the sequences that use n-1 and the ones that don't. Notice that there's the same number of each, as long as n-1>1 - if a sequence doesn't use n-1, we can put it in, and if it does, we can take it out.

Let's count the ones that do use n-1, so they look like 1 < a_2 < a_3 < ... < n-1 < n. If we rip off the n at the end, we get a sequence from 1 to n-1. So the number of such sequences is S_{n-1}.

a. The recurrence is S_n = S_{n-1} + S_{n-1} = 2 S_{n-1}.

b. S_2 = 1. The only sequence is (1,2).

c. It's doubling each time, so it's some multiple of 2^n, and in fact it's 1/4 * 2^n = 2^{n-2}.

(Actually this should have been obvious - for each number strictly between 1 and n, either it's in or it's out. That's n-2 choices.)

5.1 #20. Call the answer B_n.

a. If we take a string of length n-1 that has 01, and add 0 or 1, we get one of length n. That (2 * B_{n-1}) gets us almost all of B_n. The only ones we're missing are the ones like 11100000001, that only have a 01 at the end, and otherwise never go from 0 to 1. There are n-1 of those (depending on where the first 0 is). So B_n = 2 B_{n-1} + n-1.

b. B_2 = 1, just "01" works.

c. B_7 = 120.

(In this case it's easier to count C_n = 2^n - B_n, the strings that don't contain 01. They must go all 1s then all 0s, so C_n = n+1.)

5.1 #28.

a. For this one, it's way easier to count the ones that don't satisfy the condition, and since it's doubled-starred I'm going to do it that way. The first digit is 0,1,2, and then each digit added after that has to be different from the previous one - so two choices. Therefore there are 3 * 2^{n-1} bad ones, and 3^n - 3 * 2^{n-1} good ones.

For a recurrence, let's compare T_n = 3^n - 3 * 2^{n-1} to 3 * T_{n-1} = 3^n - 9 * 2^{n-2}. I guess T_n = 3 * T_{n-1} + 3 * 2^{n-2}.

Looking at the recurrence, we can figure out where it could come from. To make one of these good strings, we could take one of the shorter good strings (of which there are T_{n-1}) and add any digit on the end (there are 3 ways to do that). But there are some good strings we miss this way: they're bad all the way to the end, and then finally have a double letter. There's 3*2^{n-2} that are bad all the way to end, and only one way to attach a last letter to make a double letter.

In fact that suggests another recurrence:
T_n = 3 * T_{n-1} + 1 * (3^{n-1} - T_{n-1}).
Each previous good one gives 3 good ones now, each previous bad one gives 1 good one now.

b. T_1 = 0.

c. T_6 = 3^6 - 3 * 2^5.

5.1 #38. f(n) = f(n-1) + f(n-2) = 2 f(n-2) + f(n-3) = 3f(n-3) + 2f(n-4) = 5f(n-4) + 3f(n-5), just by expanding the first term each time.

Therefore f(5k) = 3 f(5(k-1)) mod 5. Now we claim by induction that f(5k) is in fact = 0 mod 5. The base case is f(0), which is 0, so each time we triple it (mod 5) we still get 0 mod 5.

5.2 #28. a_n = 2 a_{n-1} + 2 n^2.

a. First thing, solve the homogeneous, A_n = 2 A_{n-1}. The general solution to this is A_n = C * 2^n.

Now find a particular solution to the inhomogeneous. Let's guess that some polynomial b n^2 + c n + d works.

b n^2 + c n + d = 2 (b (n-1)^2 + c (n-1) + d) + 2 n^2

Breaking into the n^2, n, and 1 parts:

  • b = 2b + 2, so b = -2
  • c = -4b + 2c, so c = -8
  • d = 2b - 2c + 2d, so d = c-b = -6.
  • So -2 n^2 - 8 n - 6 is a solution. Therefore every solution is of the form -2 n^2 - 8 n - 6 + C * 2^n, with any C possible.

    b. a_1 = -2 -8 -6 + C * 2^1 = 4. Therefore C = 10. So the solution is -2 n^2 - 8 n - 6 + 10 * 2^n.