Evaluating a recursive function

In summary, the problem involves evaluating a function with a specific pattern, using repeated subtraction to reduce a number to either 1, 2, or 3, and using the trick that a number is divisible by 3 if its digits sum to a multiple of 3. The solution involves performing a certain number of subtractions of 3 to get the desired number.
  • #1
Bashyboy
1,421
5
Hello everyone,

Here is the problem:

Let ##\displaystyle f_0() = \frac{1}{1-x}##, and ##f_n(x) = f_0(f_{n-1}(x))##, where ##n \in \mathbb{N}##. Evaluate ##f_{2014}(2014)##.

I first sought after a pattern, and then tried to make a conjecture. Here is what I found:

##\displaystyle f_1(x) = f_0(f_(x)) = \frac{1}{1 - \frac{1}{x-1}} = \frac{1-x}{-x} = \frac{(f_0(x))^{-1}}{-x}##

##\displaystyle f_2(x) = f_0(f_1(x)) = \frac{1}{1- \left(\frac{(f_0(x))^{-1}}{-x} \right)} = \frac{x}{x + (f_0(x))^{-1}}##

##\displaystyle f_3(x) = f_0(f_2(x)) = \frac{1}{1 - \left(\frac{x}{x + (f_0(x))^{-1}} \right)} = \frac{ x + (f_0(x))^{-1} }{x + (f_0(x))^{-1} - x } = \frac{x + (f_0(x))^{-1} }{(f_0(x))^{-1}}##

##\displaystyle f_4(x) = f_0(f_3(x)) = \frac{1}{1 - \left(\frac{x + (f_0(x))^{-1} }{(f_0(x))^{-1} } \right)} = \frac{(f_0(x))^{-1}}{-x} = f_1(x)##

##f_5(x) = f_2(x)##

##f_6(x) = f_3(x)##

So, after the functions ##f_1,~f_2,~f_3##, a pattern begins to emerge, and therefore these three functions are the base functions. The conjecture is that, if you begin with the ##j##-th function, the function will not repeat until the ##(j+3)##-th function.

So, I need to figure out how to "reduce" the number 2014 to either 1,2, or 3 by repeatedly subtracting 3 from 2014 until I arrive at 1,2, or 3. Equivalently, I could repeatedly add 3 to 1,2, and 3, until I reached 2014, and then I would know which function ##f_{2014}## is equivalent to. But I am having difficulty figuring out exactly how to do this without actually doing the addition or subtraction. I know that multiplication of integers is defined in terms of addition; it is repeated addition. So, asking how many times I can add 3 to a number until I get 2014 is related to multiplication, which in turn is related to division, because division is defined in terms of multiplication.

I hope you can help!
 
Physics news on Phys.org
  • #2
Try reducing your [itex]f_1(x)[/itex] a bit more. In particular, reduce that [itex]f_0(x)[/itex] term to something more basic. Do the same for [itex]f_2(x)[/itex] and then [itex]f_3(x)[/itex]. Done right, you should only operations involving numbers and the letter [itex]x[/itex] in the expressions for your [itex]f_n(x)[/itex].

You should see one more pattern emerge in addition to what you've already seen. This should help you find the answer to your question.
 
  • #3
Bashyboy said:
Hello everyone,

Here is the problem:

Let ##\displaystyle f_0() = \frac{1}{1-x}##, and ##f_n(x) = f_0(f_{n-1}(x))##, where ##n \in \mathbb{N}##. Evaluate ##f_{2014}(2014)##.

I first sought after a pattern, and then tried to make a conjecture. Here is what I found:

##\displaystyle f_1(x) = f_0(f_(x)) = \frac{1}{1 - \frac{1}{x-1}} = \frac{1-x}{-x} = \frac{(f_0(x))^{-1}}{-x}##

##\displaystyle f_2(x) = f_0(f_1(x)) = \frac{1}{1- \left(\frac{(f_0(x))^{-1}}{-x} \right)} = \frac{x}{x + (f_0(x))^{-1}}##

##\displaystyle f_3(x) = f_0(f_2(x)) = \frac{1}{1 - \left(\frac{x}{x + (f_0(x))^{-1}} \right)} = \frac{ x + (f_0(x))^{-1} }{x + (f_0(x))^{-1} - x } = \frac{x + (f_0(x))^{-1} }{(f_0(x))^{-1}}##

##\displaystyle f_4(x) = f_0(f_3(x)) = \frac{1}{1 - \left(\frac{x + (f_0(x))^{-1} }{(f_0(x))^{-1} } \right)} = \frac{(f_0(x))^{-1}}{-x} = f_1(x)##

##f_5(x) = f_2(x)##

##f_6(x) = f_3(x)##

So, after the functions ##f_1,~f_2,~f_3##, a pattern begins to emerge, and therefore these three functions are the base functions. The conjecture is that, if you begin with the ##j##-th function, the function will not repeat until the ##(j+3)##-th function.

So, I need to figure out how to "reduce" the number 2014 to either 1,2, or 3 by repeatedly subtracting 3 from 2014 until I arrive at 1,2, or 3. Equivalently, I could repeatedly add 3 to 1,2, and 3, until I reached 2014, and then I would know which function ##f_{2014}## is equivalent to. But I am having difficulty figuring out exactly how to do this without actually doing the addition or subtraction. I know that multiplication of integers is defined in terms of addition; it is repeated addition. So, asking how many times I can add 3 to a number until I get 2014 is related to multiplication, which in turn is related to division, because division is defined in terms of multiplication.

I hope you can help!

You can figure it out for yourself: when you subtract 3 once you get 2014 - 3. Two subtractions give you 2014 - 2*3. So, when perform n subtractions of 3 you get 2014 - 3*n. You want this to give you either 0, 1 or 2.
 
  • #4
Bashyboy said:
So, I need to figure out how to "reduce" the number 2014 to either 1,2, or 3 by repeatedly subtracting 3 from 2014 until I arrive at 1,2, or 3.

There are many ways to do this. Firstly you can calculate 2014/3 by long division to determine the remainder. Or you can use the trick that a number is divisible by 3 if its digits sum to a multiple of 3: 2 + 0 + 1 + 4 = 7, so 2 + 0 + 1 + 3 = 6...
 
  • #5
I was hoping the OP could figure that out on his own.
 

Related to Evaluating a recursive function

1. What is a recursive function?

A recursive function is a function that calls itself within its own definition. This allows for repetitive tasks to be broken down into smaller, simpler tasks, making it easier to solve a complex problem.

2. How do you evaluate a recursive function?

To evaluate a recursive function, you need to understand the base case (or stopping condition), which is the condition that determines when the function should stop calling itself and return a value. Then, you need to identify the recursive case, which is the condition that allows the function to call itself again with a smaller input. You can then use a tracing method or a debugger to track the function's execution and determine the final output.

3. What is the purpose of evaluating a recursive function?

The purpose of evaluating a recursive function is to check if it is working correctly and efficiently. By evaluating the function, you can ensure that it will terminate at the base case and produce the desired output. It also allows you to identify any potential errors or inefficiencies in the code and make improvements.

4. What are some common mistakes when evaluating a recursive function?

Some common mistakes when evaluating a recursive function include forgetting to include a base case, causing the function to enter an infinite loop. Other mistakes include not updating the input parameters correctly in the recursive case, leading to incorrect output, or not considering all possible scenarios in the base case, resulting in incorrect or unexpected output.

5. Are there any best practices for evaluating a recursive function?

Yes, there are some best practices for evaluating a recursive function. These include choosing a suitable base case, ensuring that the recursive case reduces the input towards the base case, and testing the function with different inputs to ensure it works correctly for all possible scenarios. It is also helpful to use a tracing method or a debugger to track the function's execution and identify any potential issues.

Similar threads

Replies
3
Views
939
  • Precalculus Mathematics Homework Help
Replies
13
Views
352
  • Introductory Physics Homework Help
Replies
17
Views
421
  • Precalculus Mathematics Homework Help
Replies
11
Views
571
  • Classical Physics
Replies
1
Views
737
  • Precalculus Mathematics Homework Help
Replies
4
Views
560
  • Precalculus Mathematics Homework Help
Replies
15
Views
1K
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
366
  • Special and General Relativity
Replies
10
Views
629
Back
Top