第 7 章 递推关系和生成函数
EX1
Let
, denote the Fibonacci sequence. By evaluating each of the following expressions for small values of n, conjecture a general formula and then prove it, using mathematical induction and the Fibonacci recurrence: (a)
(b)
(c)
(d)
EX1(a)(b)
先打表找规律,
打表程序
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int p = 0, q = 1;
vector<int> fibList {p, q};
for(int i = 0; i < 50; ++ i) {
fibList.emplace_back(p+q);
p = q;
q = fibList.back();
}
int odd_total = 0, even_total = 0, alter_total = 0, square_total;
int flag = 1;
printf("idx \t sum_odd \t sum_total \t sum_alter \t sum_square \n");
for(int i = 0; i < 10; ++ i) {
odd_total += fibList[max(2*i-1, 0)];
even_total += fibList[2*i];
alter_total += flag * fibList[i];
flag *= -1;
square_total += fibList[i] * fibList[i];
printf("%d \t %d \t %d \t %d \t %d\n", i, odd_total, even_total,
alter_total, square_total);
}
return 0;
}
可以发现:
数学归纳证明过程略。
EX1(c)
对于特殊的
EX1(d)
这个强调一下特殊的构造方法,辅助猜测递推公式,后面也会用到这个构造法。
EX2
Prove that the nth Fibonacci number In is the integer that is closest to the number
设
因此,
EX3
Prove the following about the Fibonacci numbers:
(a)
is even if and only if n is divisible by 3. (b)
is divisible by 3 if and only if n is divisible by 4. (c)
is divisible by 4 if and only if n is divisible by 6.
EX3(b)
下面使用数学归纳法证明,当 n 被 4 整除时,
设
因此
EX3PS
从周期性的角度入手,验证了当
EX4
Prove that the Fibonacci sequence is the solution of the recurrence relation
where ao = 0, al = 1, a2 = 1, a3 = 2, and U4 = 3. Then use this formula to show that the Fibonacci numbers satisfy the condition that
is divisible by 5 if and only if n is divisible by 5.
连续使用
因此
EX5
By examining the Fibonacci sequence, make a conjecture about when
is divisible by 7 and then prove your conjecture.
对斐波那契数列
EX6 ⭐
* Let m and n be positive integers. Prove that if m is divisible by n, then
is divisible by .
EX7 ⭐
* Let m and n be positive integers whose greatest common divisor is d. Prove that the greatest common divisor of the Fibonacci numbers
and is the Fibonacci number .
EX8
Consider a 1-by-n chessboard. Suppose we color each square of the chessboard with one of the two colors red and blue. Let
be the number of colorings in which no two squares that are colored red are adjacent. Find and verify a recurrence relation that hn satisfies. Then derive a formula for hn .
如果第一个方块着成红色,那么第二个方块只能着成蓝色,问题转化为
并且有初始项
EX9
Let
equal the number of different ways in which the squares of a 1-by-n chessboard can be colored, using the colors red, white, and blue so that no two squares that are colored red are adjacent. Find and verify a recurrence relation that satisfies. Then find a formula for .
考虑第一个方框放红色,那么第二个方块只能放白色或蓝色,问题转化为
求解方程
带入初始值
EX10
Suppose that, in his problem, Fibonacci had placed two pairs of rabbits in the enclosure at the beginning of a year. Find the number of pairs of rabbits in the enclosure after one year. More generally, find the number of pairs of rabbits in the enclosure after n months.
设第 t 个月时有
第一个月再过 n 个月是第 n+1 月,因此有
提示
本题以 n 作为一个常量(n 个月后),为了区分就需要把未知量设为 t。
EX11
The Lucas numbers
are defined using the same recurrence relation defining the Fibonacci numbers, but with different initial conditions: Prove that
(a)
(b)
EX11(a)
设
又因为
EX11(b)
因为
EX12
Let
be the sequence defined by Show that
is the recurrence relation for the sequence.
带入
EX13
Determine the generating function for each of the following sequences:
(a)
(b)
(c)
( is a real number) (d)
(e)
无穷数列
EX13(a)
EX13(b)
EX13(c)
EX13(d)
EX13(e)
EX14
Let S be the multiset
Determine the generating function for the sequence , where is the number of n-combinations of S with the following added restrictions: (a) Each
occurs an odd number of times. (b) Each
occurs a multiple-of-3 number of times. (c) The element
does not occur, and occurs at most once. (d) The element
occurs 1,3, or 11 times, and the element occurs 2,4, or 5 times. (e) Each
occurs at least 10 times.
EX14(a)
EX14(b)
EX14(c)
EX14(d)
EX14(e)
EX15
Determine the generating function for the sequence of cubes
由第 5 章 EX20 知,
由第 5 章 EX43 知,
因此,
EX16
Formulate a combinatorial problem for which the generating function is
果篮中苹果、香蕉、西瓜和桃子,求苹果不超过 2 个,香蕉为不超过 6 个且为偶数,西瓜是偶数个,桃子至少有 1 个的组合数。
EX17
Determine the generating function for the number hn of bags of fruit of apples, oranges, bananas, and pears in which there are an even number of apples, at most two oranges, a multiple of three number of bananas, and at most one pear. Then find a formula for hn from the generating function.
因此
翻译错误
注意黑皮书题干中的翻译错误,英文原意是至多有两个橙子。
不管怎么描述,本题都是可解的。在做题时需要认真读清题目。
EX18
Determine the generating function for the number
of nonnegative integral solutions of
令
EX19
Let
be the sequence defined by . Determine the generating function for the sequence.
简评
本题可以算是 EX15 的一个子问题
EX20
Let
be the sequence defined by . Determine the generating function for the sequence.
EX21 ⭐
* Let
denote the number of regions into which a convex polygonal region with n + 2 sides is divided by its diagonals, assuming no three diagonals have a common point. Define = 0. Show that Then determine the generating function and obtain a formula for
.
EX22
Determine the exponential generating function for the sequence of factorials:
.
EX23
Let
be a real number. Let the sequence be defined by , and . Determine the exponential generating function for the sequence.
EX24
Let S be the multiset
Determine the exponential generating function for the sequence , where and, for , (a)
equals the number of n-permutations of S in which each object occurs an odd number of times. (b)
equals the number of n-permutations of S in which each object occurs at least four times. (c)
equals the number of n-permutations of S in which occurs at least once, occurs at least twice, ... , occurs at least times. (d)
equals the number of n-permutations of S in which occurs at most once, occurs at most twice, ... , occurs at most times.
EX24(a)
EX24(b)
并且指数生成函数为
EX24(c)
指数生成函数为
EX24(d)
指数生成函数为
EX25
Let
denote the number of ways to color the squares of a 1-by-n board with the colors red, white, blue, and green in such a way that the number of squares colored red is even and the number of squares colored white is odd. Determine the exponential generating function for the sequence , and then find a simple formula for .
因此
EX26
Determine the number of ways to color the squares of a 1-by-n chessboard, using the colors red, blue, green, and orange if an even number of squares is to be colored red and an even number is to be colored green.
因此
EX27
Determine the number of n-digit numbers with all digits odd, such that 1 and 3 each occur a nonzero, even number of times.
问题等价于
指数生成函数为,
因此
EX28
Determine the number of n-digit numbers with all digits at least 4, such that 4 and 6 each occur an even number of times, and 5 and 7 each occur at least once, there being no restriction on the digits 8 and 9.
问题等价于
指数生成函数为,
因此
强调
需要根据题目的意义来决定初始项
EX29
We have used exponential generating functions to show that the number hn of n-digit numbers with each digit odd, where the digits 1 and 3 occur an even number of times, satisfies the formula
Obtain an laternative derivation of this formula.
根据 n 位数中 1 和 3 出现数量的奇偶性可以分类,
种类 | 1 的数量 | 3 的数量 |
---|---|---|
奇数 | 奇数 | |
奇数 | 偶数 | |
偶数 | 奇数 | |
偶数 | 偶数 |
对于
初始条件,
写出该式子的下一项
解方程略,可得其次递推关系的解
所以通解为
对于 1 位数,
EX30
We have used exponential generating functions to show that the number hn of ways to color the squares of a 1-by-n board with the colors red, white, and blue, where the number of red squares is even and there is at least one blue square, satisfies the formula
with
. Obtain an alternative derivation of this formula by finding a recurrence relation satisfied by and then solving the recurrence relation.
种类 | 红色 | 蓝色 |
---|---|---|
奇数 | 无限制 | |
偶数 | ||
偶数 |
以
对于
初始值
提示
- 利用好奇偶两种对立状态。
- 题目强调要写出
的递推式,实际上容易先求出 ,然后带入 求出 ,但这样不满足题目要求的解法。
EX31
Solve the recurrence relation
with initial values and .
带入初始值解得,
EX32
Solve the recurrence relation
with initial value .
EX33
Solve the recurrence relation
with initial values , and .
方程
EX34
Solve the recurrence relation
with initial values and .
EX35
Solve the recurrence relation
with initial values , and .
EX36
Solve the recurrence relation
with initial values , and .
方程
简评
分解方程和求解四元一次方程组的计算量很大。
EX37
Determine a recurrence relation for the number an of ternary strings (made up of 0s, 1s, and 2s) of length n that do not contain two consecutive 0s or two consecutive 1s. Then find a formula for
.
对长度为 n 且符合题目要求的字符串
因此得到递推公式:
因此求出
联想 💡
对比 EX37、EX40 和 EX9
EX38 👻
Solve the following recurrence relations by examining the first few values for a formula and then proving your conjectured formula by induction.
(a)
(b)
(c)
(d)
(e)
以 EX38(b) 为例,先求出通项,再用数学归纳法验证,其余同理。
EX38(b)
先求其次递推关系的解,
带入递推关系求出
数学归纳法证明过程略。
EX39
Let
denote the number of ways to perfectly cover a 1-by-n board with monominoes and dominoes in such a way that no two dominoes are consecutive. Find, but do not solve, a recurrence relation and initial conditions satisfied by .
容易验证初始值
综上有,
简评
头一次看到专门强调只推出关系不求解的题目。
EX40
Let
equal the number of ternary strings of length n made up of Os, ls, and 2s, such that the substrings 00, 01, 10, and 11 never occur. Prove that with
and . Then find a formula for .
按照第一字符是否为 2 进行划分,由题意,长度为 n 的串第一个字符是 2,问题变为
长度为 0 的串,长度为 1 的串显然都不含有 00、01、10 和 11,
EX41
* Let 2n equally spaced points be chosen on a circle. Let
denote the number of ways to join these points in pairs so that the resulting line segments do not intersect. Establish a recurrence relation for .
选择一端固定在 1 上的线段为基线,另一端指向 2k,圆上的 2n 个点被分为两组,一组有 2k-2 个, 另一组有 2n-2k 个,同时问题
显然
EX42 👻
Solve the monhomogeneous recurrence realtion
其次递推关系的解为
简评
虽然参考答案秀了技巧,把非齐次方程转化为
EX43 👻
Solve the monhomogeneous recurrence realtion
略。
EX44 👻
Solve the monhomogeneous recurrence realtion
略
EX45 👻
Solve the monhomogeneous recurrence realtion
略
EX46 👻
Solve the monhomogeneous recurrence realtion
略
EX47 👻
Solve the monhomogeneous recurrence realtion
略
EX48 👻
Solve the following recurrence relations by using the method of generating functions as described in Section 7.4:
(a)
(b)
(c)
(d)
(e)
(f)
以 EX48(b) 和 EX48(f) 为例,其余题目略。
EX48(b)
设生成函数为
两边求和化简得,
再由
其中,
因此,
EX48(f)
设生成函数为
因此可以得到方程组,
解得,
提示
从上面的过程可以看出使用生成函数求解的计算量极大,因此如果题目不是强调使用该方法,不要考虑使用它。
EX49
(q-binomial theorem) Prove that
where
is the q-factorial (cf. Theorem 7.2.1 replacing q in (7.14) with x) and
is the q-binomial coefficient.
采用数学归纳法证明,当 n=1 时,左边等于
假设取 n 时等式成立,那么取 n+1 时,左右两边同时乘
即取 n+1 时等式仍成立,综上,证毕。
EX49PS
下面验证,
EX49 参考
EX50
Call a subset S of the integers {1, 2, ... ,n} extmordinary provided its smallest integer equals its size:
For example, S = {3,7,8}, is extraordinary. Let
be the number of extraordinary subsets of {1, 2, ..., n}. Prove that with
and .
如果子集 S 是非凡的 k 子集,那么 S 中的最小元素是 k,其余 k-1 个元素均比 k 大,因此非凡 k 子集的个数为
由题意容易求出{1}的非凡集为{1},{1, 2}的非凡集为{1},因此
EX51
Solve the recurrence relation
from Section 7.6 using generating functions.
要求使用生成函数求解非齐次递推关系。生成函数为
所以
EX52 👻
Solve the following two recurrence relations:
(a)
with (a)
with
非齐次递推关系求解,略。
EX53
Suppose you deposit $500 in a bank account -that pays 6% interest at the end of each year (compounded annually). Thereafter, at the beginning of each year you deposit $100. Let hn be the amount in your account after n years (so h_0 = $500). Determine the generating function
and then a formula for .
因此,
提示
(*) 式不留常数凑成