Non-Linear Recurrence Relation

青春壹個敷衍的年華 提交于 2019-12-03 00:51:37

There's a trick. Let G(n) = F(n) + 1. The equation

F(n) = F(n-1) + F(n-2) + F(n-1)*F(n-2)

becomes

G(n) - 1 = G(n-1) - 1 + G(n-2) - 1 + (G(n-1) - 1) * (G(n-2) - 1)
         = G(n-1) - 1 + G(n-2) - 1 + G(n-1)*G(n-2) - G(n-1) - G(n-2) + 1
         = G(n-1)*G(n-2) - 1,

so adding 1 to both sides,

G(n) = G(n-1)*G(n-2).

This is the multiplicative equivalent of the familiar Fibonacci recurrence. The solution is

G(n) = G(0)^Fib(n-1) * G(1)^Fib(n),

by analogy with the theory of linear recurrences (where Fib(-1) = 1 and Fib(0) = 0 and Fib(1) = 1), since

G(n-1)*G(n-2) = G(0)^Fib(n-2) * G(1)^Fib(n-1)
              * G(0)^Fib(n-3) * G(1)^Fib(n-2)
              = G(0)^Fib(n-1) * G(1)^Fib(n)
              = G(n).

Hence,

F(n) = (F(0)+1)^Fib(n-1) * (F(1)+1)^Fib(n) - 1,

doing the Fib computations via the matrix power method mod p-1 per Fermat's little theorem and the exponentiation mod p.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!