computing recursive functions

40 Views Asked by At

I have a function $\alpha : \mathbb{N}\times\mathbb{N} \rightarrow\mathbb{N}$, defined recursively, as below:

$\forall n \in\mathbb{N}, \alpha(n,10) := \begin{cases} \alpha(n-1-9, 10) + 9 &\text{if}\ n \ge 10,\\ 0 &\text{if}\ n \lt 10 \end{cases}$.

When I compute $\alpha(10, 10)$ my answer is $\alpha(0,10)+9$. When I compute $\alpha(100, 10)$ I get $\alpha(90,10)+9$. When I compute $\alpha(1000, 10)$, I get $\alpha(990,10)+9$.

Are my answers correct, or is there something I'm not doing or a way I'm supposed to phrase it? Additionally, I'm asked "What does function alpha calculate?" to which I answered

$\forall n \in\mathbb{N}$ such that $n \ge 10, a_n = \alpha(n-10,10)+9$

Am I in any way correct? I apologize if this seems like I'm just asking for answers, but I don't really have any resources to check if my answers are correct, and I'm struggling to keep up with a class in which I'm expected to learn discrete mathematics in six weeks, with four $2$-hour lectures and one exam per week. Thank you for any help in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

First, since $10$ is the only value of the second argument that ever appears, and since $n-1-9=n-10$, you might as well get the clutter out of the way and look instead at the function

$$\beta:\Bbb N\to\Bbb N:n\mapsto\begin{cases} \beta(n-10)+9,&\text{if }n\ge 10\\ 0,&\text{if }n<10\;: \end{cases}$$

$\alpha(n,10)=\beta(n)$ for all $n\in\Bbb N$. Thus, for instance, the first value that you want is

$$\alpha(10,10)=\beta(10)=\beta(0)+9=9\;.$$

You stopped one step short of actually evaluating $\alpha(10,10)$ when you said that it’s $\alpha(0,10)$. This is correct as far as it goes, but it doesn’t go far enough: you’re supposed to come up with an actual numerical value.

Suppose that $10\le n\le 19$; then $0\le n-10\le 9$, so $\beta(n-10)=0$, and

$$\beta(n)=\beta(n-10)+9=0+9=9\;.$$

In other words, we now know that

$$\beta(n)=\begin{cases} 0,&\text{if }0\le n\le 9\\ 9,&\text{if }10\le n\le 19\;. \end{cases}$$

What about the next block of $10$? If $20\le n\le 29$, then $10\le n-10\le 19$, so

$$\beta(n)=\beta(n-10)+9=9+9=18\;.$$

Similarly, if $30\le n\le 39$, then $20\le n-10\le 29$, and

$$\beta(n)=\beta(n-10)+9=18+9=27\;.$$

We can now extend our partial description of $beta$:

$$\beta(n)=\begin{cases} 0,&\text{if }0\le n\le 9\\ 9,&\text{if }10\le n\le 19\\ 18,&\text{if }20\le n\le 29\\ 27,&\text{if }30\le n\le 39\;. \end{cases}$$

It appears that in each new block of $10$ consecutive inputs the output goes up by $9$. We might conjecture that

$$\beta(n)=9\left\lfloor\frac{n}{10}\right\rfloor$$

and try to prove it by induction on $n$. This turns out to be very easy: the induction step is just like the steps above in which I went from the tens block to the twenties and from the twenties block to the thirties.