Solving recurrence relation in 2 variables plus constant

156 Views Asked by At

I've encountered this question, asking to solve the recurrence $$F(n,m) = F(n-1,m) + F(n,m-1)$$ for some initial conditions. I wonder how the solution would change if we add a constant, say

$ G(n,m) = G(n-1,m) + G(n,m-1)+2$.

One answer for the mentioned post suggested generating functions. What would change here? For simplicity, let's assume $G(1,m) = m − 1$ and $G(n, 1) = 0$.

1

There are 1 best solutions below

3
On

Let $H(n,m)=G(n,m)+2$, then $$\begin{aligned} H(n,m)&=G(n,m)+2 \\ &=G(n-1,m)+G(n,m-1)+4 \\&=(G(n-1,m)+2)+(G(n,m-1)+2) \\&=H(n-1,m)+H(n,m-1) \end{aligned}$$ You can now solve the recurrence for $H$ and deduce the recurrence for $G$ by writing $G(n,m)=H(n,m)-2$.