14 篇文章 0 订阅

9-17_算法实验报告

斐波那契数列

f ( n ) = { f ( n − 1 ) + f ( n − 2 ) ； ( n > 2 ) 1 ； ( n = 1 , n = 2 ) f(n) = \begin{cases}f(n-1) + f(n - 2)；(n > 2)\\ 1；(n = 1, n = 2)\end{cases}

解答

f ( n ) = f ( n − 1 ) + f ( n − 2 ) ； ( n > 2 ) f(n) = f(n - 1) + f(n-2)；(n > 2)

G ( x ) = f ( 1 ) x + f ( 2 ) x 2 + . . . + f ( n ) x n + . . . G(x) = f(1)x + f(2)x^2 + ... + f(n)x^n+ ...

G ( x ) − x G ( x ) − x 2 G ( x ) = f ( 1 ) x + f ( 2 ) x 2 + . . . + − f ( 1 ) x 2 − f ( 2 ) x 3 − . . . − − f ( 1 ) x 3 − f ( 2 ) x 4 − . . . − G(x) - x G(x) - x^2G(x) = f(1)x + f(2)x^2 + ...+ \\ - f(1)x^2 - f(2)x^3 - ... - \\ - f(1)x^3 - f(2)x^4 - ... - \\

G ( x ) − x G ( x ) − x 2 G ( x ) = f ( 1 ) x + ( f ( 2 ) − f ( 1 ) ) x 2 + ( f ( 3 ) − f ( 2 ) − f ( 1 ) ) x 3 + . . . + G(x) - x G(x) - x^2G(x) = f(1)x + (f(2)-f(1))x^2 + (f(3)-f(2)-f(1))x^3 + ... +

G ( x ) − x G ( x ) − x 2 G ( x ) = x G(x) - x G(x) - x^2G(x) = x

G ( x ) = x 1 − x − x 2 G(x) = \frac{x}{1-x-x^2}

G ( x ) = a 1 − r x + b 1 − s x G ( x ) = a ( 1 − s x ) + b ( 1 − r x ) ( 1 − r x ) ( 1 − s x ) = ( a + b ) − ( a s + b r ) x 1 − ( r + s ) x + r s x 2 G(x) = \frac{a}{1-rx} + \frac{b}{1-sx}\\ G(x) = \frac{a(1-sx) + b(1-rx)}{(1-rx)(1-sx)} = \frac{(a + b) - (as+br)x}{1-(r+s)x+rsx^2}

x 1 − x − x 2 = ( a + b ) − ( a s + b r ) x 1 − ( r + s ) x + r s x 2 \frac{x}{1-x-x^2}= \frac{(a + b) - (as+br)x}{1-(r+s)x+rsx^2}

{ a + b = 0 a s + b s = − 1 r + s = 1 r s = − 1 { a = 1 5 b = − 1 5 r = 1 + 5 2 s = 1 − 5 2 \begin{cases} a+b = 0\\ as + bs = -1\\ r+s = 1\\ rs = -1 \end{cases} \\ \begin{cases} a = \frac{1}{\sqrt{5}}\\ b = - \frac{1}{\sqrt{5}}\\ r = \frac{1+\sqrt{5}}{2}\\ s = \frac{1-\sqrt{5}}{2} \end{cases}

G ( x ) = a 1 − r x + b 1 − s x = a ( 1 + r x + r 2 x 2 + . . . ) + b ( 1 + s x + s 2 x 2 + . . . ) G(x) = \frac{a}{1-rx} + \frac{b}{1-sx}\\ = a(1+rx+r^2x^2+...) + b(1+sx+s^2x^2+...)

G ( x ) = ( a + b ) + ( a r + b s ) x + ( a r 2 + b s 2 ) x 2 + . . . + ( a r n + b s n ) x n + . . . G(x) = (a + b) + (ar+bs)x+(ar^2+bs^2)x^2 + ... + (ar^n + bs^n)x^n + ...

G ( x ) = f ( 1 ) x + f ( 2 ) x 2 + . . . + f ( n ) x n + . . . G(x) = f(1)x + f(2)x^2 + ... + f(n)x^n+ ...

f ( n ) = a r n + b s n = 1 5 [ ( 1 + 5 2 ) n − 1 − 5 2 ) n ] f(n) = ar^n+ bs^n = \frac{1}{\sqrt{5}}[(\frac{1+\sqrt{5}}{2})^n - \frac{1-\sqrt{5}}{2})^n]

f ( n ) = 1 5 [ ( 1 + 5 2 ) n − ( 1 − 5 2 ) n ] f(n) = \frac{1}{\sqrt{5}}[(\frac{1+\sqrt{5}}{2})^n - (\frac{1-\sqrt{5}}{2})^n]

• 3
点赞
• 7
收藏
• 打赏
• 1
评论
12-06 14万+
01-01 2万+
11-27 96
05-22 2021
03-19 5930
08-13 212
01-28 1万+
06-28 1142
09-06 3573
08-23 1474
03-20 2032
09-05 3905
05-24 6712
01-27 2264

“相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。