Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

recurrence relation with offset techinique

$
0
0

A recurrence relation of this type: $F_n = 2F_{n - 1} + 3F_{n - 2} + 3$ , where sum of the coefficient of recurring terms on both side of the equation is not equal.

I have seen a codechef video ( by Kevin ) where they explain the offset adding to solve this type of recurrence by removal of the constant term. The recurrence can be converted to $G_n = 2G_{n-1} + 3G_{n-2}$ and later use matrix exponentiation to solve it with matrix $\begin{bmatrix} 2&3\\ 1&0\\ \end{bmatrix}$ to obtain the value of $G_n \textit{ mod }M$. For example,

$\begin{align*} &\text{Let, }F_n = G_n + C\\ &\Rightarrow G_n + C = 2\left [ G_{n - 1} + C \right ] + 3\left [ G_{n - 2} + C \right ] + 3 \\ &\Rightarrow G_n + C = 2G_{n - 1} + 3G_{n - 2} + 5C + 3 \\ &\Rightarrow G_n= 2G_{n - 1} + 3G_{n - 2} + 4C + 3 \\ &\Rightarrow C = -\frac{3}{4} \\ \end{align*}$

Now after calculating the value of $G_n \textit{ mod }M$ how to recover $F_n$?

Thanks!


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>