Simplify system of 3 equations of 3 recursive functions

390 Views Asked by At

Is it possible to simplify this system into one equation of f only?

f(N) = f(N-1) + f(N-2) + 2*g(N) + h(N)

g(N) = f(N-2) + g(N-1)

h(N) = f(N-2) + h(N-2)

Initial values if needed: f(1) = 2 f(2) = 5 g(2) = 1 g(3) = 2 h(2) = 1 h(3) = 1


I'm not sure it is possible. The simplification I have is:

()=(−1)+5(−2)+(−3)−(−4)

But it maybe includes some additional inputs.

1

There are 1 best solutions below

7
On BEST ANSWER

We start with $$\begin{align} &f(n) = f(n - 1) + f(n - 2) + 2·g(n) + h(n) \\&-\\ &f(n - 2) = f((n - 2) - 1) + f((n - 2) - 2) + 2·g(n - 2) + h(n - 2) \end{align}$$ And obtain $$ f(n) = - f(n - 4) - f(n - 3) + 2·f(n - 2) + f(n - 1) - 2·g(n - 2) + 2·g(n) - h(n - 2) + h(n) $$ We can substitute $h(n)-h(n-2)$ in the equation and get $$ f(n) = - f(n - 4) - f(n - 3) + 2·f(n - 2) + f(n - 1) - 2·g(n - 2) + 2·g(n)+f(n-2) $$

Now all that's left to eliminate are the summands $- 2·g(n - 2) + 2·g(n)$.

Using the recurrence $g(n) = f(n - 2) + g(n - 1)$ this becomes: $$- 2·g(n - 2) + 2·f(n - 2) + 2·g(n - 1)$$

Which, using the same recurrence (shifted by $n\mapsto n-1$) becomes $$ 2·f(n - 2) + 2·f(n-3)$$

And so, we obtain the recurrence:

$$ f(n) = - f(n - 4) - f(n - 3) + 2·f(n - 2) + f(n - 1)+ 2·f(n - 2) + 2·f(n-3)+f(n-2) $$

Or, simplified $$f(n) = f(n - 1)+ 5·f(n - 2)+ f(n - 3) - f(n - 4) $$

So, your reduction was correct.