考虑递归定义的数列
{
a
n
=
a
n
−
1
+
a
n
−
2
n
≥
3
a
n
=
1
n
=
1
,
2
\left\{\begin{matrix}a_n=&a_{n-1}+a_{n-2}&n\geq3\\a_n=&1&n=1,2\\\end{matrix}\right.
{an=an=an−1+an−21n≥3n=1,2
将上述数列延拓到
a
0
a_0
a0,可以得到
a
0
=
a
2
−
a
1
=
0
a_0=a_2-a_1=0
a0=a2−a1=0,这个后面会用到。
当
n
≥
2
n\ge2
n≥2时,可以用传递矩阵表示为
(
a
n
+
1
a
n
)
=
(
1
1
1
0
)
(
a
n
a
n
−
1
)
\begin{pmatrix} a_{n+1}\\ a_n \end{pmatrix} = \begin{pmatrix} 1 & 1\\ 1&0 \end{pmatrix} \begin{pmatrix} a_n\\ a_{n-1} \end{pmatrix}
(an+1an)=(1110)(anan−1)
则
(
a
n
+
1
a
n
)
=
(
1
1
1
0
)
n
(
a
1
a
0
)
\begin{pmatrix} a_{n+1}\\ a_n \end{pmatrix} = \begin{pmatrix} 1 & 1\\ 1&0 \end{pmatrix}^n \begin{pmatrix} a_1\\ a_{0} \end{pmatrix}
(an+1an)=(1110)n(a1a0)
令
A
=
(
1
1
1
0
)
A=\begin{pmatrix} 1 &1 \\ 1&0 \end{pmatrix}
A=(1110)
虽然
A
n
A^n
An可以在
O
(
log
(
n
)
)
O(\log(n))
O(log(n))时间内计算完成,但是我们希望更快。
现在我们先把矩阵对角化,分解为
A
=
P
Λ
P
−
1
A=P\Lambda P^{-1}
A=PΛP−1的形式,其中
Λ
\Lambda
Λ是对角阵,
P
P
P是特征向量阵,通过Mathematica可计算
P=Transpose[Eigenvectors[A]]
得到
P
=
(
1
+
5
2
1
−
5
2
1
1
)
P= \begin{pmatrix} \frac{1+\sqrt{5}}{2}& \frac{1-\sqrt{5}}{2}\\ 1 & 1 \end{pmatrix}
P=(21+5121−51)
从而
Λ
=
P
−
1
A
P
=
(
1
+
5
2
0
0
1
−
5
2
)
\Lambda= P^{-1}AP= \begin{pmatrix} \frac{1+\sqrt{5}}{2} & 0\\ 0 & \frac{1-\sqrt{5}}{2} \end{pmatrix}
Λ=P−1AP=(21+50021−5)
对角化之后,
A
n
A^n
An就有了显式的计算公式,
(
a
n
+
1
a
n
)
=
A
n
(
a
1
a
0
)
=
(
P
Λ
P
−
1
)
n
(
a
1
a
0
)
=
P
Λ
n
P
−
1
(
a
1
a
0
)
=
P
Λ
n
P
−
1
(
1
0
)
\begin{align} \begin{pmatrix} a_{n+1}\\ a_n \end{pmatrix} = A^n \begin{pmatrix} a_1\\ a_{0} \end{pmatrix} =(P\Lambda P^{-1})^n \begin{pmatrix} a_1\\ a_0 \end{pmatrix} =P \Lambda^n P^{-1} \begin{pmatrix} a_1\\ a_0 \end{pmatrix} =P \Lambda^n P^{-1} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \end{align}
(an+1an)=An(a1a0)=(PΛP−1)n(a1a0)=PΛnP−1(a1a0)=PΛnP−1(10)
其中
P
Λ
n
P
−
1
=
Λ
=
P
−
1
A
P
=
(
1
+
5
2
1
−
5
2
1
1
)
(
1
+
5
2
0
0
1
−
5
2
)
n
(
1
+
5
2
1
−
5
2
1
1
)
−
1
=
(
2
−
1
−
n
(
−
(
1
−
5
)
1
+
n
+
(
1
+
5
)
1
+
n
)
5
−
(
1
2
(
1
+
5
)
)
n
(
−
1
+
(
1
2
(
−
3
+
5
)
)
n
)
5
−
(
1
2
(
1
−
5
)
)
n
+
(
1
2
(
1
+
5
)
)
n
5
(
−
1
+
5
)
(
1
2
(
1
+
5
)
)
n
+
(
1
2
(
1
−
5
)
)
n
(
1
+
5
)
2
5
)
P\Lambda^n P^{-1}= \Lambda= P^{-1}AP= \begin{pmatrix} \frac{1+\sqrt{5}}{2}& \frac{1-\sqrt{5}}{2}\\ 1 & 1 \end{pmatrix} \begin{pmatrix} \frac{1+\sqrt{5}}{2} & 0\\ 0 & \frac{1-\sqrt{5}}{2} \end{pmatrix}^n \begin{pmatrix} \frac{1+\sqrt{5}}{2}& \frac{1-\sqrt{5}}{2}\\ 1 & 1 \end{pmatrix}^{-1} = \begin{pmatrix} \frac{2^{-1-n} \left(-\left(1-\sqrt{5}\right)^{1+n}+\left(1+\sqrt{5}\right)^{1+n}\right)}{\sqrt{5}} & -\frac{\left(\frac{1}{2} \left(1+\sqrt{5}\right)\right)^n \left(-1+\left(\frac{1}{2} \left(-3+\sqrt{5}\right)\right)^n\right)}{\sqrt{5}} \\ \frac{-\left(\frac{1}{2} \left(1-\sqrt{5}\right)\right)^n+\left(\frac{1}{2} \left(1+\sqrt{5}\right)\right)^n}{\sqrt{5}} & \frac{\left(-1+\sqrt{5}\right) \left(\frac{1}{2} \left(1+\sqrt{5}\right)\right)^n+\left(\frac{1}{2} \left(1-\sqrt{5}\right)\right)^n \left(1+\sqrt{5}\right)}{2 \sqrt{5}} \\ \end{pmatrix}
PΛnP−1=Λ=P−1AP=(21+5121−51)(21+50021−5)n(21+5121−51)−1=
52−1−n(−(1−5)1+n+(1+5)1+n)5−(21(1−5))n+(21(1+5))n−5(21(1+5))n(−1+(21(−3+5))n)25(−1+5)(21(1+5))n+(21(1−5))n(1+5)
代入
(
1
)
(1)
(1)式得,
a
n
=
(
1
2
(
5
+
1
)
)
n
−
(
1
2
(
1
−
5
)
)
n
5
a_n=\frac{\left(\frac{1}{2} \left(\sqrt{5}+1\right)\right)^n-\left(\frac{1}{2} \left(1-\sqrt{5}\right)\right)^n}{\sqrt{5}}
an=5(21(5+1))n−(21(1−5))n