Solve $f(n)=\begin{cases} n-3 \ \ \ \ \ \ \ \qquad{\text{if $n\ge1000$}}\\ f\big(f(n+5)\big)\quad{\text{if $n<1000$}} \end{cases}$

315 Views Asked by At

Suppose I have a function $f(n)$ below, find $f(84)$ : $$f(n)=\begin{cases} n-3 \ \ \ \ \ \ \ \qquad{\text{if $n\ge1000$}}\\ f\big(f(n+5)\big)\quad{\text{if $n<1000$}} \end{cases}$$ My attempt: $$\begin{align} f(84)=&f\big(f(89)\big)\\ f(89)=&f\big(f(94)\big)\\ f(94)=&f\big(f(99)\big)\\ &\vdots\\ f(999)=&f\big(f(1004)\big)\\ f(1004)=&1001 \end{align} $$ Now: $$\begin{align} f(999)&=f(1001)=998\\ f(994)&=f\big(f(999)\big)=f(998)\Rightarrow f(998)=f\big(f(1003)\big)=f(1000)=997\\ &f(994)=f(998)=997\\ f(989)&=f\big(f(994)\big)=f(997)\Rightarrow f(997)=f\big(f(1002)\big)=f(999)=998\\ &f(989)=f(997)=998\\ f(984)&=f\big(f(989)\big)=f(998)=997\\ f(979)&=f\big(f(984)\big)=f(997)=998\\ \vdots && \end{align}$$ Obviously since it the value of $f(n)$ alternates between $997$ & $998$, depending on whether $n$ is odd or even, thus: $$\vdots\\ f(89)=998\\ \therefore\bbox[10px, border:1px solid black]{f(84)=997}\\ $$

My question: is there a more efficient way to solve this?

1

There are 1 best solutions below

0
On BEST ANSWER

Define $f^{h} = f(f(\cdots f(f(x))\cdots))$, where the function $f$ is performed $h$ times. We find that $f(84) = f(f(89)) = f^2(89) = f^3(94) = \ldots f^{y}(1004)$. $1004 = 84 + 5(y - 1) \Longrightarrow y = 185$. So we now need to reduce $f^{185}(1004)$.

Let’s write out a couple more iterations of this function: \begin{align*}f^{185}(1004)&=f^{184}(1001)=f^{183}(998)=f^{184}(1003)=f^{183}(1000)\\ &=f^{182}(997)=f^{183}(1002)=f^{182}(999)=f^{183}(1004)\end{align*} So this function reiterates with a period of 2 for $x$. On first thought it might seem that $f(1004) = 1001$ is the answer; however, that is not true since the solution occurs slightly before that. Start at $f^3(1004)$: $f^{3}(1004)=f^{2}(1001)=f(998)=f^{2}(1003)=f(1000)=\boxed{997}$