Non-Linear Recurrence Relation

前端 未结 1 1952
野性不改
野性不改 2021-02-03 16:10

How can I find Nth term for this recurrence relation

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

I have to find Nth term for this recurrence relatio

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-03 17:00

    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.

    0 讨论(0)
提交回复
热议问题