Does this recursive function have a closed-form solution

closed-formrecursionrecursive algorithms

Consider the following recursive function:

$$
z(i) = \begin{cases}
z(i + 8) + 1 & i < 0 \\
z(i – 7) & i > 2 \\
0 & 0 \leq i \leq 2
\end{cases}
$$

Does this recursive function have a closed-form solution? I know that constant-recursive sequences have a closed-form solution. However, this function is not a sequence. Hence, I don't know where to begin in order to convert this function into a closed-form expression, if it's even possible.

Best Answer

This indeed has a closed form solution, but unfortunately it seems kinda hideous to write out.

what?

???

A strategy you could use is: Start with what values of the function you know, and try to build it up from there. For this problem, one could draw a number line and start marking values of the functions on various intervals. So, we start with $f(x) = 0$ for $x \in [0,2]$, then we use the recursion to find values for more intervals. So, we can derive $f(x) = 0$ for $x \in [7,9]$, as well as $f(x) = 1$ for $x \in [-8,-6]$. Then we can start working inwards, and get e.g. $f(x) = 1$ for $x \in [-1, 0]$. We see in deriving this function, we'll be sorta going back and forth from positive to negative, until we figure out all the values of the function between -8 and 9. After that, getting the rest of the function is pretty easy.

Related Question