【Combinatorics】Recursion relationship

1. Establishment of recursive relationship

Given a sequence of numbers f ( 0 ) , f ( 1 ) , . . . , f ( n ) , . . . , f (0), f( 1), ..., f(n ),... , f(0),f(1),...,f(n),..., Young existing integer n 0 n_0 n0 , envoy n ≥ n 0 n≥ n_0 nn0When , you can use the equal sign (or greater than sign or less than sign) to change f ( n ) f (n) f(n) A certain trivial matter f ( i ) ( 0 ≤ i < n ) f (i) (0 ≤ i< n) f(i)(0i<n) are connected, such a formula is called a recursion relationship
Establish a recursion relationship The steps are as follows:

  1. Find the relationship between the nth item and the nearest previous items
  2. Get the specific values ​​of the first few items, that is, the initial value

Exercise 1. How many sequences of n-digit quaternary numbers have an even number of 0s?
Solution: Let f ( n ) f(n) f(n) means n-digit four-digit There is an even number of 0 sequences in the system number, which can be generated by two parts:
(1) Add a non- The number 0 (i.e. 1,2,3) can produce 3 f ( n − 1 ) 3f (n −1) 3f(n1) pieces
(2) There are odd numbers among n −1 digit quaternary numbers Adding another 0 to the sequence of 0s can produce 4 n − 1 − f ( n − 1 ) 4^{n-1}-f(n-1) 4n1f(nf ( n ) = 3 f ( n − 1 ) + 4 n − 1 − f ( n − 1 ) = 4 n − 1 + 2 f ( n − 1 ) f(n)=3f(n-1)+4^{n -1}-f(n-1)=4^{n-1}+2f(n-1)
f(n)=3f(n1)+4n1f(n1)=4n1+2f(n1)显然 f ( 1 ) = 3 f(1)=3 f(1)=3 Therefore, a recurrence relation with an initial value is formed { f ( n ) = 4 n − 1 + 2 f ( n − 1 ) f ( 1 ) = 3 \left\{\begin{matrix} f(n)=4^{n-1}+2f(n-1)\\ f(1)=3 \end{matrix}\right . { f(n)=4n1+2f(n1)f(1)=3

Exercise 2. The 1×n chessboard is colored with three colors: red, white, and blue. Two adjacent squares are not allowed to be colored red. Find the number of coloring schemes
Solution: Suppose< /span> f ( n ) f (n ) f(n) represents the coloring that satisfies the condition Number of plans. Coloring schemes on this chessboard can be divided into the following 2 categories
(1) The first grid is colored white/blue, and the rest is a 1x(n-1) chessboard, which satisfies The number of shading schemes for the condition is: 2 f ( n − 1 ) 2f(n-1) 2f(n1)
(2) The first grid is colored red, the second grid is colored white/blue, and the remaining 1x(n- 2) For the chessboard, the number of coloring schemes is: 2 f ( n − 2 ) 2f(n-2) 2f(n2)

So the total number of coloring schemes is { f ( n ) = 2 f ( n − 1 ) + 2 f ( n − 2 ) f ( 1 ) = 3 , f ( 2 ) = 8 \left\{\begin{matrix} f(n)=2f(n-1)+2f(n- 2)\\ f(1)=3,f(2)=8 \end{matrix}\right. { f(n)=2f(n1)+2f(n2)f(1)=3,f(2)=8

Given the recurrence relation: f ( n ) = c 1 ( n ) f ( n − 1 ) + c 2 ( n ) f ( n − 2 ) + . . . + c k ( n ) f ( n − k ) + g ( n ) f(n)=c_1(n)f(n-1)+c_2(n)f(n-2)+...+c_k (n)f(n-k)+g(n) f(n)=c1(n)f(n1)+c2(n)f(n2)+...+ck(n)f(nk)+g(n)in c k ( n ) ≠ 0 c_k(n)\ne 0 ck(n)=0, then the relationship is called { f ( n ) } \{ f(n)\} { f(n)}目 k 逶线性递关腳系
因此 g ( n ) = 0 g(n)=0 g(n)=0 , it is called homogeneous

2. Solving the homogeneous recurrence relationship with constant coefficients

f ( n ) = c 1 ( n ) f ( n − 1 ) + c 2 ( n ) f ( n − 2 ) + . . . + c k ( n ) f ( n − k ) f(n)=c_1(n)f(n-1)+c_2(n)f(n-2)+...+c_k(n)f(n-k) f(n)=c1(n)f(n1)+c2(n)f(n2)+...+ck(n)f(nk)
方程 x k − c 1 x k − 1 − c 2 x k − 2 − . . . − c k = 0 x^k-c_1x^{k-1}-c_2x^{k-2}-...-c_k=0 xkc1xk1c2xk2...ck=0 is the characteristic equation of the above recursion relationship, and its k k k 个根 q 1 , q 2 , . . . , q k q_1,q_2,...,q_k q1,q2,...,qk (may have multiple roots) is called the characteristic root of the recurrence relationship, where q ​​i ( i = 1 , 2 , . . . , k ) q_i (i=1, 2,... , k ) qi(i=1,2,...,k)is the number.

Theorem 2.1: 设 q ​​q q is a non-zero complex number if and only if q is its characteristic root, f ( n ) = q n f(n)=q ^n f(n)=qn is the solution of the recurrence relation

Theorem 2.2: As a result h 1 ( n ) , h 2 ( n ) h_1(n),h_2(n) h1(n),h2(n)To is a systematic solution, b 1 b_1 b1 b 2 b_2 b2 is a constant, then b 1 h 1 ( n ) + b 2 h 2 ( n ) b_1h_1(n)+b_2h_2(n) b1h1(n)+b2h2(n)This is also a systematic solution

Theorem 2.3: Suppose q ​​1 , q 2 , . . . , q k q_1,q_2,...,q_k q1,q2,...,qk is a recursive relationship k unequal characteristic roots, b 1 b_1 < /span>b1 b 2 b_2 b2 is a constant, then f ( n ) = b 1 q 1 n + b 2 q 2 n + . . . + b k q k n f(n)=b_1q_1^n+b_2q_2^ n+...+b_kq_k^n f(n)=b1q1n+b2q2n+...+bkqkn is a recurrence relation general solution

Exercise 3. Solve the recurrence relationship { f ( n ) = 7 f ( n − 1 ) − 12 f ( n − 2 ) f ( 0 ) = 2 , f ( 1 ) = 7 \left\{\begin{matrix} f(n)=7f(n-1)-12f(n-2)\\ f(0)=2,f(1)=7 \end{ matrix}\right. { f(n)=7f(n1)12f(n2)f(0)=2,f(1)=7

Solution: First find the general solution of this recurrence relation. Its characteristic equation is x 2 − 7 x + 12 = 0 x^2-7x+12=0 x27x+12=0, the solution is as follows x 1 = 4 , x 2 = 3 x_1=4,x_2=3 x1=4,x2=3So the general solution is f ( n ) = c 1 ⋅ 4 n + c 2 ⋅ 3 n f(n)=c_1\cdot 4^n+c_2 \cdot 3^n f(n)=c14n+c23n
Bring in the initial value to determine c 1 , c 2 c_1,c_2 c1,c2,得 { c 1 + c 2 = 2 4 c 1 + 3 c 2 = 7 \left\{\begin{matrix} c_1+c_2=2\\ 4c_1+3c_2=7 \end{matrix}\right. { c1+c2=24c1+3c2=7
c 1 = 1 , c 2 = 1 c_1=1 ,c_2=1 c1=1,c2=1
Therefore understanding f ( n ) = 4 n + 3 n f(n)=4^n+3^n f(n)=4n+3n

Exercise 4. Solve the recurrence relationship { f ( n ) = f ( n − 1 ) + 9 f ( n − 2 ) − 9 f ( n − 3 ) f ( 0 ) = 0 , f ( 1 ) = 1 , f ( 2 ) = 2 \left\{\begin{matrix} f(n)=f(n-1)+9f(n-2)-9f(n -3)\\ f(0)=0,f(1)=1,f(2)=2 \end{matrix}\right. { f(n)=f(n1)+9f(n2)9f(n3)f(0)=0,f(1)=1,f(2)=2

Solution: First find the general solution of this recurrence relation. Its characteristic equation is x 3 − x 2 − 9 x + 9 = 0 x^3-x^2-9x+9=0 x3x29x+9=0, the solution is obtained x 1 = 1 , x 2 = 3 , x 3 = − 3 x_1=1,x_2= 3,x_3=-3 x1=1,x2=3,x3=3所以通解为 f ( n ) = c 1 ⋅ 1 n + c 2 ⋅ 3 n + c 3 ⋅ ( − 3 ) n f(n)=c_1\cdot 1^n+c_2 \cdot 3^n+c_3\cdot (-3)^n f(n)=c11n+c23n+c3(3)n
Bring in the initial value to determine c 1 , c 2 , c 3 c_1,c_2,c_3 c1,c2,c3,得 { c 1 + c 2 + c 3 = 0 c 1 + 3 c 2 − 3 c 3 = 1 c 1 + 9 c 2 + 9 c 3 = 2 \left\{\begin{matrix} c_1+c_2+c_3=0\\ c_1+3c_2-3c_3=1\\ c_1+9c_2+9c_3=2 \end{matrix}\right. c1+c2+c3=0c1+3c23c3=1c1+9c2+9c3=2
c 1 = − 1 4 , c 2 = 1 3 , c 3 = − 1 12 c_1=-\frac{1}{4} ,c_2=\frac{1}{3},c_3=-\frac{1}{12} c1=41,c2=31,c3=121

So the general solution is f ( n ) = − 1 4 ⋅ 1 n + 1 3 ⋅ 3 n − 1 12 ⋅ ( − 3 ) n f(n)=-\frac {1}{4}\cdot 1^n+\frac{1}{3} \cdot 3^n-\frac{1}{12}\cdot (-3)^n f(n)=411n+313n121(3)n

Theorem 2.4: Suppose q ​​1 , q 2 , . . . , q k q_1,q_2,...,q_k q1,q2,...,qk are all different characteristic roots of the recursive relationship, and their multiplicities are respectively e 1 , e 2 , . . . , e t e_1,e_2,...,e_t It is1,It is2,...,It ist ( e 1 + e 2 + . . . + e t = k ) (e_1+e_2+...+e_t=k) (e1+It is2+...+It ist=k), then the general solution of the recurrence relation is f ( n ) = f 1 ( n ) + f 2 ( n ) + . . . f t ( n ) f(n)=f_1(n)+f_2(n)+...f_t(n) f(n)=f1(n)+f2(n)+...ft(n)其中 f i ( n ) = ( b i 1 + b i 2 n + . . . + b i e i n e i − 1 ) ⋅ q i n ( 1 ≤ i ≤ t ) f_i(n)=(b_{i_1}+b_{i_2}n+...+b_{i_{e_i}}n^{e_i-1})\cdot q_i^n \quad(1\le i\le t) fi(n)=(bi1+bi2n+...+biIt isinIt isi1)qin(1it)

习题5、 求解递推关系 { f ( n ) = 3 f ( n − 2 ) − 2 f ( n − 3 ) ( n ≥ 3 ) f ( 0 ) = 1 , f ( 1 ) = 0 , f ( 2 ) = 0 \left\{\begin{matrix} f(n)=3f(n-2)-2f(n-3)\quad (n\ge3)\\ f(0)=1,f(1)=0,f(2)=0 \end{matrix}\right. { f(n)=3f(n2)2f(n3)(n3)f(0)=1,f(1)=0,f(2)=0

解: 先求这个递推关系的通解。其特征方程为 x 3 − 3 x + 2 = 0 x^3-3x+2=0 x33x+2=0,解这个方程得 x 1 = 1 , x 2 = 1 , x 3 = − 2 x_1=1,x_2=1,x_3=-2 x1=1,x2=1,x3=2所以通解为 f ( n ) = c 1 ⋅ 1 n + c 2 n ⋅ 1 n + c 3 ⋅ ( − 2 ) n f(n)=c_1\cdot 1^n+c_2n \cdot 1^n+c_3\cdot (-2)^n f(n)=c11n+c2n1n+c3(2)n
带入初值确定 c 1 , c 2 , c 3 c_1,c_2,c_3 c1,c2,c3,得 { c 1 + c 3 = 1 c 1 + c 2 − 2 c 3 = 0 c 1 + 2 c 2 + 4 c 3 = 0 \left\{\begin{matrix} c_1+c_3=1\\ c_1+c_2-2c_3=0\\ c_1+2c_2+4c_3=0 \end{matrix}\right. c1+c3=1c1+c22c3=0c1+2c2+4c3=0
c 1 = 8 9 , c 2 = − 2 3 , c 3 = 1 9 c_1=\frac{8}{9} ,c_2=-\frac{2}{3},c_3=\frac{1}{9} c1=98,c2=32,c3=91

所以通解为 f ( n ) = 8 9 ⋅ 1 n − 2 3 n ⋅ 1 n + 1 9 ⋅ ( − 2 ) n = 8 9 − 2 3 n + 1 9 ⋅ ( − 2 ) n f(n)=\frac{8}{9}\cdot 1^n-\frac{2}{3}n \cdot 1^n+\frac{1}{9}\cdot (-2)^n=\frac{8}{9}-\frac{2}{3}n+\frac{1}{9}\cdot (-2)^n f(n)=981n32n1n+91(2)n=9832n+91(2)n

3. 常系数非齐次递推关系的求解

f ( n ) = c 1 ( n ) f ( n − 1 ) + c 2 ( n ) f ( n − 2 ) + . . . + c k ( n ) f ( n − k ) + g ( n ) f(n)=c_1(n)f(n-1)+c_2(n)f(n-2)+...+c_k(n)f(n-k)+g(n) f(n)=c1(n)f(n1)+c2(n)f(n2)+...+ck(n)f(nk)+g(n)对应的齐次递推关系为 f ( n ) = c 1 ( n ) f ( n − 1 ) + c 2 ( n ) f ( n − 2 ) + . . . + c k ( n ) f ( n − k ) f(n)=c_1(n)f(n-1)+c_2(n)f(n-2)+...+c_k(n)f(n-k) f(n)=c1(n)f(n1)+c2(n)f(n2)+...+ck(n)f(nk)

定理 3.1:k 阶常系数线性非齐次递推关系的通解是递推关系的特解加上其相应的齐次递推关系的通解。即非齐次递推关系的解 = 特解 + 齐次方程通解

在这里插入图片描述

习题6、 求解递推关系 { f ( n ) = 4 f ( n − 1 ) − 3 f ( n − 2 ) + 3 n ( n ≥ 2 ) f ( 0 ) = 1 , f ( 1 ) = 2 \left\{\begin{matrix} f(n)=4f(n-1)-3f(n-2)+3^n\quad (n\ge2)\\ f(0)=1,f(1)=2 \end{matrix}\right. { f(n)=4f(n1)3f(n2)+3n(n2)f(0)=1,f(1)=2

解: 先求这个递推关系的通解。其特征方程为 x 2 − 4 x + 3 = 0 x^2-4x+3=0 x24x+3=0,解这个方程得 x 1 = 1 , x 2 = 3 x_1=1,x_2=3 x1=1,x2=3因为3是特征方程的一重根,所以该递推关系的非齐次特解为 a n 3 n an3^n an3n。将其代入递推关系,得 a n 3 n = 4 a ( n − 1 ) 3 n − 1 − 3 a ( n − 2 ) 3 n − 2 + 3 n an3^n=4a(n-1)3^{n-1}-3a(n-2)3^{n-2}+3^n an3n=4a(n1)3n13a(n2)3n2+3n化简得 a = 3 2 a=\frac{3}{2} a=23,特解为 f ′ ( n ) = 3 2 n 3 n f'(n)=\frac{3}{2}n3^n f(n)=23n3n

而相应齐次递推关系的通解为 f ′ ′ ( n ) = c 1 ⋅ 1 n + c 2 n ⋅ 3 n f''(n)=c_1\cdot 1^n+c_2n \cdot 3^n f′′(n)=c11n+c2n3n

通解为 f ( n ) = f ′ ( n ) + f ′ ′ ( n ) = c 1 + c 2 ⋅ 3 n + 3 2 n 3 n f(n)=f'(n)+f''(n)=c_1+c_2\cdot 3^n+\frac{3}{2}n3^n f(n)=f(n)+f′′(n)=c1+c23n+23n3n带入初值确定 c 1 , c 2 c_1,c_2 c1,c2,得 { c 1 + c 2 = 1 c 1 + 3 c 2 + 9 2 = 2 \left\{\begin{matrix} c_1+c_2=1\\ c_1+3c_2+\frac{9}{2}=2 \end{matrix}\right. { c1+c2=1c1+3c2+29=2

c 1 = 11 4 , c 2 = − 7 4 c_1=\frac{11}{4} ,c_2=-\frac{7}{4} c1=411,c2=47

所以通解为 f ( n ) = 11 4 − 7 4 ⋅ 3 n + 3 2 n 3 n f(n)=\frac{11}{4}-\frac{7}{4}\cdot3^n+\frac{3}{2}n3^n f(n)=411473n+23n3n

习题7、 求解递推关系 { f ( n ) = f ( n − 1 ) + n 2 f ( 1 ) = 1 , f ( 2 ) = 5 , f ( 3 ) = 14 \left\{\begin{matrix} f(n)=f(n-1)+n^2\\ f(1)=1,f(2)=5,f(3)=14 \end{matrix}\right. { f(n)=f(n1)+n2f(1)=1,f(2)=5,f(3)=14

解: 先求这个递推关系的通解。其特征方程为 x − 1 = 0 x-1=0 x1=0,解这个方程得 x = 1 x=1 x=1因为1是特征方程的一重根,所以该递推关系的非齐次特解为 n 1 ( b 2 n 2 + b 1 n 1 + b 0 ) n^1(b_2n^2+b_1n^1+b_0) n1(b2n2+b1n1+b0)。将其代入递推关系,得 n 1 ( b 2 n 2 + b 1 n 1 + b 0 ) = ( n − 1 ) ( b 2 ( n − 1 ) 2 + b 1 ( n − 1 ) + b 0 ) + n 2 n^1(b_2n^2+b_1n^1+b_0)=(n-1)(b_2(n-1)^2+b_1(n-1)+b_0)+n^2 n1(b2n2+b1n1+b0)=(n1)(b2(n1)2+b1(n1)+b0)+n2比较系数可得 { b 1 = − 3 b 2 + b 1 + 1 b 0 = 3 b 2 − 2 b 1 + b 0 0 = − b 2 + b 1 − b 0 \left\{\begin{matrix} b_1=-3b_2+b_1+1\\ b_0=3b_2-2b_1+b_0\\ 0=-b_2+b_1-b_0 \end{matrix}\right. b1=3b2+b1+1b0=3b22b1+b00=b2+b1b0,解得 { b 0 = 1 / 6 b 1 = 1 / 2 b 2 = 1 / 3 \left\{\begin{matrix} b_0=1/6\\ b_1=1/2\\ b_2=1/3 \end{matrix}\right. b0=1/6b1=1/2b2=1/3 特解为 f ′ ( n ) = n ( 1 3 n 2 + 1 2 n + 1 6 ) f'(n)=n(\frac{1}{3}n^2+\frac{1}{2}n+\frac{1}{6}) f(n)=n(31n2+21n+61)而相应齐次递推关系的通解为 f ′ ′ ( n ) = c 1 ⋅ 1 n f''(n)=c_1\cdot 1^n f′′(n)=c11n

通解为 f ( n ) = f ′ ( n ) + f ′ ′ ( n ) = c 1 ⋅ 1 n + n ( 1 3 n 2 + 1 2 n + 1 6 ) f(n)=f'(n)+f''(n)=c_1\cdot 1^n+n(\frac{1}{3}n^2+\frac{1}{2}n+\frac{1}{6}) f(n)=f(n)+f′′(n)=c11n+n(31n2+21n+61)带入初值确定 c 1 c_1 c1,得 c 1 + 1 ⋅ ( 1 3 + 1 2 + 1 6 ) = 1 c_1+1\cdot(\frac{1}{3}+\frac{1}{2}+\frac{1}{6})=1 c1+1(31+21+61)=1

c 1 = 0 c_1=0 c1=0

所以通解为 f ( n ) = n ( 1 3 n 2 + 1 2 n + 1 6 ) = 1 6 n ( n + 1 ) ( 2 n + 1 ) f(n)=n(\frac{1}{3}n^2+\frac{1}{2}n+\frac{1}{6})=\frac{1}{6}n(n+1)(2n+1) f(n)=n(31n2+21n+61)=61n(n+1)(2n+1)

4. 迭代法

但对于某些非线性的递推关系,不存在求解的公式,因此不能用上述方法。
碰到此类问题,不妨尝试用迭代归纳法来求解。

作业习题链接:作业 第三章 递推关系

Guess you like

Origin blog.csdn.net/cold_code486/article/details/134808721